TITLE "mp4t1.a by Douglas Jones" ; Produces output if something's wrong, otherwise no output ; This particular test program just initializes two ; long variables and complains if they don't match ; their expected initial values ; It uses INT2LONG and LONG2INT USE "hawk.macs" USE "monitor.h" USE "mp4.h" S START EXT UNUSED SUBTITLE "CHECKVAL Support routine" ; Output only if there's an unexpected value: ; Undefined when EEE expected! -- if there is an overflow ; VVV found when EEE expected! -- if the value is wrong VALUE = 4 ARSIZE = 8 CHECKVAL: ; support routine to check long value ; expects R3 pointer to long (with value VVV above) ; expects R4 expected integer value of long (EEE above) STORES R1,R2 STORE R4,R2,VALUE ; save value ADDI R2,R2,ARSIZE LIL R1,LONG2INT JSRS R1,R1 ADDI R2,R2,-ARSIZE ; get long value and error flag TESTR R4 BZS CHECKV ; if (error flag != 0) LEA R3,UNDEF ADDI R2,R2,ARSIZE LIL R1,DSPST JSRS R1,R1 ADDI R2,R2,-ARSIZE ; dspst( "Undefined when " ) BR CHECKEX CHECKV: LOAD R5,R2,VALUE CMP R3,R5 BEQ CHECKQT ; or if (long value != expected value) LIS R4,0 ADDI R2,R2,ARSIZE LIL R1,DSPDEC JSRS R1,R1 ADDI R2,R2,-ARSIZE ; dspdec( long value, 0 ) LEA R3,FOUND ADDI R2,R2,ARSIZE LIL R1,DSPST JSRS R1,R1 ADDI R2,R2,-ARSIZE ; dspst( " found when " ) CHECKEX: LOAD R3,R2,VALUE LIS R4,0 ADDI R2,R2,ARSIZE LIL R1,DSPDEC JSRS R1,R1 ADDI R2,R2,-ARSIZE ; dspdec( expected value, 0 ) LEA R3,EXPECT ADDI R2,R2,ARSIZE LIL R1,DSPST JSRS R1,R1 ADDI R2,R2,-ARSIZE ; dspst( " expected! " ) CHECKQT: LOADS R1,R2 JUMPS R1 ; return UNDEF: ASCII "Undefined when ",0 FOUND: ASCII " found when ",0 EXPECT: ASCII " expected! ",0 ALIGN 2 SUBTITLE "Main program" ; --------------------- ; some long variables that will be used for computation COMMON X,LONGSIZE COMMON Y,LONGSIZE ; --------------------- START: LIL R2,UNUSED LIL R1,DSPINI JSRS R1,R1 ; initialize some long variables LIL R3,X LIS R4,1 LIL R1,INT2LONG JSRS R1,R1 ; X = 1 LIL R3,Y LIL R4,-1000000 LIL R1,INT2LONG JSRS R1,R1 ; Y = -1000000 ; -- can add arithmetic code (LONGADD, LONGSUB, etc) ; here to test more interesting stuff LIL R3,X LIS R4,1 JSR R1,CHECKVAL ; check that X = 1 LIL R3,Y LIL R4,-1000000 JSR R1,CHECKVAL ; check that Y = -1000000 LIL R1,EXIT JSRS R1,R1 END