1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2007
Posts
2
Rep Power
0

HELLO,,,, IM NEW IN THIS FORM AND I WANT HELP

I HAVE 2 WRITE ACODE CONVERTING FROM DECIMAL TO BINARY AND TO HEX IF THE USER IN SERT NUMBER GRAETER THAT 15,,, I TRIED TO WRITE IT BUT I COULD'T COMBINE BETWEEN THEM,,

SO IF ANY BODY CAN PLEASE HELP ME ,, I SPENT ALOT OF TIME IN CHANGING AND MODIFYING

HERE IS THE CODE
=======================================

newchar:
mov ah, 1h ; keyboard input function
int 21h ; execute ^ with dos
sub al, 30h ; ascii to binary
jl endinpt ; jump if < 0
cmp al, 15d ; is it > 9d?
jg endinpt ; yes, not decimal digit
cbw ; byte in al to word in ax

;
; digit is now in AX
; multiply number in BX by 10d
;
xchg ax, bx ; trade digit and number
mov cx, 10d ; put 10d in CX
mul cx ; number times 10d
xchg ax, bx ; trade number and digit

;
; add digit in AX to number in BX
;
jmp newchar ; get next digit

;
; check to see what they entered
; if nothing, exit
; otherwise, return from process
;
endinpt:
cmp bx, 0h ; is it 0?
jne return ; nope, return from process
;.exit ; yup, exit program

return:

ret

; *********************************************
; print_hex
; prints in hex to the screen the contents of
; BX
; *********************************************

print_hex :

mov ch, 5h ; number of digits to print

; register

rotate:
mov cl, 5h ; set count to 4 bits
rol bx, cl ; left digit to right

; convert to number

mov al, bl ; mov to AL
and al, 0fh ; mask off left digit
add al, 30h ; convert hex to ascii
cmp al, 3ah ; is it > 9?
jl printit ; jump if digit =0 to 9
add al, 27h ; digit is A to F

; print the digit in
; the AL register

printit:
mov dl, al ; put ASCII char in DL
mov ah, 2h ; display output function
int 21h ; call DOS
dec ch ; done 4 digits?
jnz rotate ; not yet

; fallthrough and return

ret

print_me:
MOV AL, [SI]
INT 10h ; print in teletype mode.
DEC SI
LOOP print_me

; Procedure to convert number in CX
; to its binary equivalent. Result is
; store in "Result" string.

===================================
THANKS ALOT MOONA
2. No Profile Picture
Contributing User
Devshed Intermediate (1500 - 1999 posts)

Join Date
Feb 2004
Location
San Francisco Bay
Posts
1,939
Rep Power
1316
What part of it doesn't work? Be specific, please.
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2007
Posts
2
Rep Power
0

#### specific the part

the next part didnt work starting from newchar