macro/hw2-1.mac

57 lines
1.5 KiB
Plaintext

TITLE HW2 DIAMOND - Homework 2
SEARCH MONSYM
Comment $ (Gorin p. 65) $
START: RESET ;begin execution here
;UPPER TRIANGLE ...
MOVEI 12,6 ;initial line countdown
MOVEI 14,5 ;initial line length
; here to print each line
ULINE: MOVEI 13,0 ;initial character count
AOS 14 ;increment line length
; print one character on a line
UCHAR: CAML 13,12 ;skip if printing spaces
JRST UPSTAR ;go print a star
HRROI 1,BLANK ;print a blank
PSOUT
JRST UELIN ;test for end of line
UPSTAR: HRROI 1,ASTER ;print a star
PSOUT
UELIN: CAMGE 13,14 ;have we reached the end of line?
AOJA 13,UCHAR ;print the next character
HRROI 1,NEWLIN ;print the carriage return & line feed
PSOUT
CAILE 12,1 ;finished all lines yet?
SOJA 12,ULINE ;no. do more.
;LOWER TRIANGLE ...
MOVEI 12,0 ;initial line count
MOVEI 14,15 ;initial line length
; here to print each line
LLINE: MOVEI 13,0 ;initial character count
SOS 14 ;decrement line length
; print one character on a line
LCHAR: CAML 13,12 ;skip if printing spaces
JRST LPSTAR ;go print a star
HRROI 1,BLANK ;print a blank
PSOUT
JRST LELIN ;test for end of line
LPSTAR: HRROI 1,ASTER ;print a star
PSOUT
LELIN: CAMGE 13,14 ;have we reached the end of line?
AOJA 13,LCHAR ;print the next character
HRROI 1,NEWLIN ;print the carriage return & line feed
PSOUT
CAIGE 12,6 ;finished all lines yet?
AOJA 12,LLINE ;no. do more.
HALTF ;all done
BLANK: ASCIZ / /
ASTER: ASCIZ /*/
NEWLIN: ASCIZ /
/
END START