TITLE "mp4t2.a by Douglas Jones" ; Produces output if something is wrong, otherwise no output ; This particular test program just initializes three ; long variables and compares them to see if comparison ; can detecet the > = and < conditions ; It uses INT2LONG and LONGCMP USE "hawk.macs" USE "monitor.h" USE "mp4.h" S START EXT UNUSED SUBTITLE "CHECKCMP Support routine" ; Output only if there's an unexpected result, for example: ; Compared > but expected =! ; Compared < but expected >! CMPEXP = 4 CMPACT = 8 ARSIZE = 12 CHECKCMP: ; support routine to check compare ; expects R3 pointer to long a ; expects R4 pointer to long b ; expects R5 expected return from compare STORES R1,R2 STORE R5,R2,CMPEXP ; save expected value ADDI R2,R2,ARSIZE LIL R1,LONGCMP JSRS R1,R1 ADDI R2,R2,-ARSIZE ; longcmp(a,b) LOAD R4,R2,CMPEXP CMP R3,R4 BEQ CHKCPQ ; if (longcmp() != expected value) { STORE R3,R2,CMPACT ; save actual value LEA R3,CMPARD ADDI R2,R2,ARSIZE LIL R1,DSPST JSRS R1,R1 ADDI R2,R2,-ARSIZE ; dspst( " Compared " ) LOADCC R3,R2,CMPACT ; recover actual value BEQ CHKCPAE BNS CHKCPAL LIS R3,">" ; actually > BR CHKCPAQ CHKCPAE: LIS R3,"=" ; actually = BR CHKCPAQ CHKCPAL: LIS R3,"<" ; actually < CHKCPAQ: ADDI R2,R2,ARSIZE LIL R1,DSPCH JSRS R1,R1 ADDI R2,R2,-ARSIZE ; dspch( actual ) LEA R3,CMPXPD ADDI R2,R2,ARSIZE LIL R1,DSPST JSRS R1,R1 ADDI R2,R2,-ARSIZE ; dspst( " but expected " ) LOADCC R3,R2,CMPEXP ; recover expected value BEQ CHKCPEE BNS CHKCPEL LIS R3,">" ; expected > BR CHKCPEQ CHKCPEE: LIS R3,"=" ; expected = BR CHKCPEQ CHKCPEL: LIS R3,"<" ; expected < CHKCPEQ: ADDI R2,R2,ARSIZE LIL R1,DSPCH JSRS R1,R1 ADDI R2,R2,-ARSIZE ; dspch( expected ) LIS R3,"!" ADDI R2,R2,ARSIZE LIL R1,DSPCH JSRS R1,R1 ADDI R2,R2,-ARSIZE ; dspch( ! ) CHKCPQ: ; } LOADS R1,R2 JUMPS R1 ; return CMPARD: ASCII " Compared ",0 CMPXPD: ASCII " but expected ",0 ALIGN 2 SUBTITLE "Main program" ; --------------------- ; some long variables COMMON X,LONGSIZE COMMON Y,LONGSIZE COMMON Z,LONGSIZE ; --------------------- START: LIL R2,UNUSED LIL R1,DSPINI JSRS R1,R1 ; initialize some long variables LIL R3,X LIL R4,10000 LIL R1,INT2LONG JSRS R1,R1 ; X = 10000 LIL R3,Y LIS R4,-1 LIL R1,INT2LONG JSRS R1,R1 ; Y = -1 LIL R3,Z LIS R4,-1 LIL R1,INT2LONG JSRS R1,R1 ; Z = -1 ; -- can add arithmetic code (LONGADD, LONGSUB, etc) ; here to test more interesting stuff LIL R3,X LIL R4,Y LIS R5,1 JSR R1,CHECKCMP ; check that 10000 > -1 LIL R3,Y LIL R4,X LIS R5,-1 JSR R1,CHECKCMP ; check that -1 < 10000 LIL R3,Y LIL R4,Z LIS R5,0 JSR R1,CHECKCMP ; check that -1 = -1 LIL R1,EXIT JSRS R1,R1 ; call exit() END