I have the following program that would print from A to Z with a space in between them. In the following program I understood the rest of the code but didn't understand why the PUSH DX
and POP DX
instructions are used. If I run the code without using PUSH DX
and POP DX
, it would just print "!" instead of the characters.
.model small
.stack
.data
VAL DB 'A'
.code
MAIN PROC
SPACE MACRO
MOV DL, ' '
MOV AH, 02h;
INT 21H
ENDM
MOV AX, @DATA
MOV DS, AX
MOV CL, 26
MOV DL, 65 ; MOV DL, VAL
PRINT:
MOV AH, 02H
INT 21H
PUSH DX
SPACE
POP DX
INC DL
DEC CL
JNZ PRINT
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN