
Data Segment
P1	DB " * 2 = $"			; P1 is the string " * 2 = "

New_Line  DB 0Dh, 0Ah, "$"		; New_Line is a caridge return & line feed

Data Ends

Working_Storage Segment Stack
	DW 100H DUP(?)
Working_Storage Ends

Code Segment
;---------------
Push_R Macro			; Macro definition 'Push_R'
	Push AX			; Put AX onto the top of the stack
	Push BX			; Put BX onto the top of the stack
	Push CX			; Put CX onto the top of the stack
	Push DX			; Put DX onto the top of the stack
EndM				; end Macro
;---------------
Pop_R Macro			; Macro definition 'Pop_R'
	Pop DX			; copy the top of the stack into DX
	Pop CX			; copy the top of the stack into CX
	Pop BX			; copy the top of the stack into BX
	Pop AX			; copy the top of the stack into AX
EndM				; end Macro
;---------------
OK Macro LFs			; Macro definition 
      Local CLLoop		; goto CLLoop
	Push_R			; Call the Push_R Macro (essentially saving the data for now)
	Mov  BX, LFs		; move LFs (2D) to BX
CLLoop:  Mov  DX, Offset New_Line  ; move the caridge return line feed to DX
	Mov  AH, 9		; Echo out the caridge return
	Int 21H			; call the interupt to echo out New_Line
	Sub  BX, 1		; subtract 1 from BX
	JA  CLLoop		; if BX is greater than 0 loop CLLoop again. if not continue
	Pop_R			; Call the pop_R macro (retrieving the data)
EndM				; end Macro
;-----------------

Assume DS:Data,SS:Working_Storage,CS:Code

Start: Mov  AX, Data		;Setup the data in the data register
	Mov  DS, AX
M_Loop:
	Mov  AH, 1H		; accept keystrokes, place them in AL and echo them to the screen
	Int  21H

	Cmp AL, 27D		; Check to see if the user has hit excape.
	JE  Done		; If AL is 27 goto 'Done'

	Call Home_ET		; call the function 'Home_ET'

	OK 2			; pass 2D to the OK macro as the LFs parameter.

	Jmp  M_Loop		; Begin again just after the data register is set.
				; loop until 'Esc' is pressed.

;Return to DOS
Done:  Mov  AX, 4C00H		; Return to Dos
	Int 21H

;------------------
Home_ET: Push_R
	Mov  BL, AL		; Moves AL to BL
	Add  BL, BL		; double BL
	Mov  DX, Offset P1	; move the string P! to DX
	Mov  AH, 9		; move 9 to AH
	Int  21H		; echo out the P1 string
	Mov  DL, BL		; Move BL to DL
	Mov  AH, 2		; echo out BL
	Int  21H		; do the actual echo
	Pop_R			; Call the Pop_R macro
	Ret			; return to the line that called this function.
;------------------

Code EndS
End Start

