;** disp_str.asm -- example of defining and using nested macros
;** You should assemble this and look at how the macros get expanded
;* inner macro--displays the character char on the screen
putchar macro char
mov ah,2 ;DOS single char output service
mov dl,char
int 21h
endm
;* outer macro--displays string of length lng, at offset str
disp_str macro str,lng
local top
mov si,0 ;point to start of string
mov cx,lng ;counter
top: putchar str[si] ;display the character
inc si ;point to next one
loop top ;do it again
endm
stk segment stack
dw 16 dup(?)
stk ends
data segment
msg db 'Hello',0dh,0ah
msg1 db 15 dup('*')
data ends
code segment
assume cs:code,ds:data
main proc far
mov ax,data
mov ds,ax
disp_str msg,7 ;display first string
mov bx,length msg1
disp_Str msg1,bx
mov ax,4c00h ;return to DOS
int 21h
main endp
code ends
end main