#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# moving inputted value to ax register (newbie gets lost)

Member Posts: 16
ok, here's the deal. this program is to display an inputted decimal number to hex and octal and display. I've got two steps away from being done and I hit the wall.

in the sections called 'convert_hex' and 'convert_oct', there's a statement: mov ax, in_buff[2] -> I'm trying to move the inputted value (now converted to decimal from ASCII) to ax to do the conversion to the other number systems. however I know this isn't right (obviously), but I don't know what is! can somebody help with that??

also, if you see something else I don't know about that isn't going to work please tell me. much appreciated. thanks!!!!

.MODEL SMALL
.586

.STACK 100h

.DATA
REQUEST DB 'Please enter a number between 0 and 65535 to convert: \$'
HEX DB 'Hex Representation: \$'
OCT DB 'Oct Representation: \$'
RFeed DB 13, 10, '\$'
in_buff DB 04h, 06h dup(00h) ; to hold exactly 16-bits

.CODE
Two PROC

string_input:
mov ax, @data
mov ds, ax; move data to DS register

mov ah, 0ah
mov dx, offset in_buff
int 21h; call for string input

call crlf

mov bx, 0000h
mov cl, 12
mov si, offset in_buff + 2
cmp in_buff[1], 00h
jz string_input

do_char:
mov al, [si]
cmp al, 0Dh
jz convert_hex
sub al, 30h
cmp al, 09h
mov ah, 00h
mov cx, ax
mov ax, 000ah
mul bx
mov bx, ax
inc si
jmp do_char

mov ah, 02h
mov dl, 07h
int 21h
jmp string_input

convert_hex:
mov ax, in_buff[2]
shr ax, cl
and al, 000Fh
cmp al, 10
jl under_ten
jmp show_hex

under_ten:

show_hex:
mov ah, 02h
mov dl, al
int 21h
sub cl, 4
inc bx
cmp bx, 4
je reset_for_oct
jmp convert_hex

reset_for_oct:
call crlf
mov bx, 0000h
mov cl, 15

convert_oct:
mov ax, in_buff[2]
shr ax, cl
and al, 07h

show_oct:
mov ah, 02h
mov dl, al
int 21h
sub cl, 3
inc bx
cmp bx, 6
je done
jmp convert_oct

done:
mov al, 0
mov ah, 4ch
int 21h

two ENDP

crlf PROC

mov dx, OFFSET RFeed
mov ah, 09h
int 21h;
RET

crlf ENDP

END Two