how to accept input with a large (multi-digit) number

前端 未结 2 1278
抹茶落季
抹茶落季 2021-01-07 08:46

How to accept input with a large number then compare it for example

mov ah,01h
int 21h

i want to accept more than one characters and move

2条回答
  •  长情又很酷
    2021-01-07 08:56

    To input a 2-digit number you simply repeat the input for 1 character 2 times and combine the results:

    mov ah, 01h
    int 21h
    sub al, '0'
    mov bl, al     ;1st digits "tens"
    mov ah, 01h
    int 21h
    sub al, '0'    ;2nd digit "units"
    xchg al, bl
    mov ah, 10
    mul ah
    add al,bl
    

    Here AL will hold your number 32 if the first input was character "3" and the second input was character "2".


    Without re-initializing the CX register, your Z-loop will iterate 65536 times because at the end of the X-loop the CX register will be 0! Is this intentional?

提交回复
热议问题