简体   繁体   中英

assembly8086 print a number at procedure

I made a little QUIZ on assembly8086 I can not print the score of the Quiz, it's a number between 1 and 10.

During the program, I add one number to the register BX like that:

proc Grade
    mov bx, offset score
    add [bx], 1
ret

At the end of the program I want to print the value of the register BX at base 10, And I need it to be in procedure.

I would be happy if you could help me, good day (:

it's a number between 1 and 10.

Since you have this very limited range, you can get by with this simple solution:

    mov  dl, [bx]      ;Score from 1 to 10
    cmp  dl, 10
    jb   IsBelow10
    mov  dl, 49        ;Display character "1"
    mov  ah, 02h
    int  21h
    mov  dl, 0         ;Prepare to display character "0"
IsBelow10:
    add  dl, 48        ;Converts number into character
    mov  ah, 02h
    int  21h

You tagged it so I think DOS calls for outputting are what you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM