include 'emu8086.inc'
ORG 100h
LEA SI, msg1 ; ask for the number
CALL print_string ;
CALL scan_num ; get number in CX.
MOV AX, CX ; copy the number to AX.
; print the following string:
CALL pthis
DB 13, 10, 'You have entered: ', 0
CALL print_num ; print number in AX.
RET ; return to operating system.
msg1 DB 'Enter the number: ', 0
DEFINE_SCAN_NUM
DEFINE_PRINT_STRING
DEFINE_PRINT_NUM
DEFINE_PRINT_NUM_UNS ; required for print_num.
DEFINE_PTHIS
END ; directive to stop the compiler.
First compiler processes the declarations (these are just regular the
macros that are expanded to procedures). When compiler gets to CALL
instruction it replaces the procedure name with the address of the code
where the procedure is declared. When CALL instruction is executed
control is transferred to procedure. This is quite useful, since even if you
call the same procedure 100 times in your code you will still have
relatively small executable size. Seems complicated, isn't it? That's ok,
with the time you will learn more, currently it's required that you
understand the basic principle.