简体   繁体   中英

How to declare counter in assembly language / emu8086?

I am new in assembly language. I just need some advice or tips on how can I declare counter loop that decrement the input number. For example, input = 5, print = 55555.5555.555.55.5

include emu8086.inc
org 100h

print 'Input a number: '

MOV AH,01H ;input
INT 21H
MOV BL,AL

MOV DL,BL

SUB BL,30H
MOV CL,BL

printn

print 'Output: '
DISP:
MOV AH,02H
INT 21H

DEC CL
JNZ DISP

MOV AH,4CH
INT 21H
Input: 5
Output: 55555

This is very basic for you guys, and for me it is very hard to learn but I won't stop learning. I just need some advice for this one.

The solution can be so

include emu8086.inc
org 100h

print 'Input a number: '

MOV AH,01H ;input digit to output 
INT 21H
MOV DL,AL

MOV AH,01H ;input number of times to output 
INT 21H
MOV CL,AL
SUB CL,30H

printn

print 'Output: '
DISP:
MOV AH,02H
INT 21H

DEC CL
JNZ DISP

MOV AH,4CH
INT 21H

This solves the problem of different inputs, but there is no checking if input is valid.

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