0

So right now I'm working on reading in a single character from the keyboard and displaying its hex value. At the moment I believe I'm getting the correct hex value, but it is not being displayed correctly. For example, 'k' is 6F in hex, but it's displaying as '6;'. I know that the correction must be made in my DIS16 procedure, but I'm not sure when and what to do. If anyone can help, I'd really appreciate it.

DIS16   PROC

    mov cx, 0   


    mov bx, 16


numdiv:     

    mov dx, 0   


    div bx


    push dx


    add cx, 1


    cmp ax, 0   


    jne numdiv      


dispnum:


    pop dx


    add dl, 30h



    mov ah, 02h
    int 21h


    loop    dispnum

RET
DIS16   ENDP
1
  • "'k' is 6F in hex". No, 'k' is 6B in hex. Commented Mar 6, 2015 at 11:59

1 Answer 1

2

Since the characters 'A' thru 'F' do not immediately follow '9', you have to adjust for that.

; as you have it
pop dx
add dl, 30h
cmp dl, '9'
jbe skip
add dl, 7 ; bump up to 'A' - 'F'
skip:
; print it... as you were

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.