I have a program I am working on for school.  It inputs a valid hex digit and gives the decimal equivalent.  I have the hex to decimal equivalen working, but I am having problems with the continue function.  After the decimal equivalen is output, it is to ask if you want to continue.  The user inputs either Y or y to continue or N or n to end the program.  Here is my code thus far...  Thanks you for any input, I have went to look it tutorial, but could not make anything out.  This is my first post here.

.model small
.stack 100h
.data

;prompts
msg db 10,13, 'Please enter a valid hex digit:', '$'
error_mes db 10,13, 'Entry not legal! Only A-F and numerical digits 1-9 accepted!', '$'
echo_char db 10,13, 'Your entry in decimal notation is: ','$'
continue db 10,13, 'Would you like to continue? ','$'

char db ?


.code

MAIN PROC
mov ax, @data ;get data segment address
mov ds, ax ;initalize ds


again:
mov ah,9
lea dx, msg
int 21h
mov ah, 1 ;ah= 0-9
int 21h

mov char, al




;if:if character is between '0' and '9'

cmp al, '0' ;char greater or equal to '0'?
jl Not_Digit ;illegal character
cmp al, '9' ;char less than or equal to '9'?
jle then


cmp al, 'A'
jl Not_char
cmp al, 'F'
Ja Not_char


mov ah, 9
lea dx, echo_char ;input digit
int 21h
mov dl, '1'
mov ah, 2
int 21h
mov al, char
sub al, 11h
mov char, al
mov dl, al
int 21h
jmp again



then:



mov ah,9
lea dx, echo_char
int 21h
        mov ah, 2
        mov dl,char
        int 21h
jmp eoj



not_digit:
mov ah, 9
lea dx, error_mes
int 21h

not_char:
mov ah,9
lea dx, error_mes
int 21h

eoj:
mov ah,9
lea dx, continue
int 21h
;cmp ah,'Y'      ;compare the value in al with Y
      ;jmp again    ;if it is equal then jump to ItsYES


mov ah, 4ch ;return to dos
int 21h

MAIN ENDP
END MAIN
Posted on 2007-02-19 21:08:09 by ahoway