.sbttl Define macros from IN:CLEMAC.MAC .nlist ; Include file for command line editor (CLE) cr = 15 ; a lonely carriage return lf = 12 ; it's normal companion bs = 10 ; backspace esc = 33 ; and at last, escape r0 = %0 r1 = %1 r2 = %2 r3 = %3 r4 = %4 r5 = %5 sp = %6 pc = %7 .macro .chksp arg .ntype $$5 ,arg .iif eq,<$$5 & 7>-6, .error arg ; Illegal use of SP(r6) in call .endm .chksp .macro message txt,docr .save .psect $pdata $$ = . .if b , .ift .byte 15,12,0 .iff .asciz @txt@ .endc .even .restore mov #$$ ,-(sp) ; dump the text next please call mout ; to the terminal .globl mout ; perhaps .if nb , .ift .iif nb,docr, message .endc .endm message .macro strcat dst,src mov src ,-(sp) mov dst ,-(sp) jsr pc ,strcat .globl strcat .endm strcat .macro strcmp s1,s2 mov s2 ,-(sp) mov s1 ,-(sp) call strcmp .globl strcmp .endm strcmp .macro strcpy dst,src mov src ,-(sp) mov dst ,-(sp) jsr pc ,strcpy .globl strcpy .endm strcpy .macro strlen string mov string ,r0 call l$len global .endm strlen .macro scan ch,str mov str ,-(sp) clr -(sp) bisb ch ,@sp call scanch .globl scanch .endm scan .macro save list .if b , .ift save .iff .irp x, mov x,-(sp) .endr .endc .endm save .macro unsave list .if b , .ift unsave .iff .irp x, mov (sp)+,x .endr .endc .endm unsave .macro PRINT addr mov addr ,-(sp) call TTYOUT .endm PRINT .macro CLRXRB call $CLRXRB .endm CLRXRB .macro CLRFQB call $CLRFQB .endm CLRFQB ; CALLS macro ; ; subroutine call with arguements passed in an area ; pointed to by R5 (similiar to F4 and BP2). All args ; are pushed onto the stack, with the first args at ; the lower address and the last ones at the higher ; addresses. R5 will point to the SP before the call. ; R5 is saved and restored. .macro calls name,arglst,gbl ; standard call macro using ; the hardware stack (%6) for .if b, gbl .ift .globl name .iff .iif dif, 'gbl ,nogbl, .globl name .iif dif, 'gbl ,NOGBL, .globl name .endc $$ = 0 ; arguement transmission with .irp x , ; r5 passed as a pointer to $$ = $$ + 1 ; to the arguement list. The .endr ; called name is declared globl .if eq ,$$ ; No args present ? If so, gen .ift ; a simple jsr pc call to sub. jsr pc ,name ; No argument list given. .iff push r5 ; At least one arg in .if eq , $$ - 1 ; One arguement in the list .ift mov arglst ,-(sp) ; One arg. Generate less code .chksp arglst ; Check for SP modes on param. mov sp ,r5 ; Set pointer to argument list jsr pc ,name ; call the subroutine tst (sp)+ ; pop parameter list from stack pop r5 ; restore r5 pointer .iff ; argcount > 1 $$2 = $$ ; more than 1 arguement. Thus .rept $$ ; extract the args in reverse $$1 = 0 ; order so that we might save .irp x , ; a little core (4 words). $$1 = $$1 + 1 ; Scan the arg list until we .if eq , $$2 - $$1 ; we come to the last one we .ift ; before the one we just did. .chksp x ; Check for SP addressing mode. mov x ,-(sp) ; Push it, and exit the .irp. .mexit ; exit .endc .endr $$2 = $$2 - 1 ; backwards to previous arg. .endr mov sp ,r5 ; Set up the argument lst ptr. jsr pc ,name ; and go to the routine. .if ne , $$ - 2 ; Gen 'Add 2*argnum, sp' ? .ift ; yes, else gen CMP (sp)+,(sp)+ add #$$*2 ,sp ; fix the stack up, restore r5 .iff cmp (sp)+ ,(sp)+ .endc unsave ; restore r5 pointer .endc .endc .endm calls ; thats all UNKNWN = 0 ; unknown terminal type TTY = 1 ; hardcopy VT5X = 2 ; VT5x series VT1XX = 3 ; VT1xx/2xx/3xx series .list