TITLE "main.a to test mp6 by Douglas Jones" USE "hawk.h" MACRO LOADNA =dst,=x,=const qNZREGq dst qMEMREFq #F010,dst,x,const ENDMAC USE "stdio.h" USE "ascii.h" S MAIN INT MAIN ; AR format for main RETAD = 0 PNEG = 4 ; #FFFFFFFF output of this means negative addr error S1 = 8 ; #89ABCDEF S1A = 12 ; #01234567 PPOS = 16 ; #11111111 output of this means positive addr error ARSIZE = 20 S2 = S1+1 S3 = S1+2 S4 = S1+3 ALIGN 4 ; to be accessed at a PC-relative negative displacement W #FFFFFFFF ; output of this means negative addressing err A6: W #33221100,#77665544 W #11111111 ; output of this means positive addressing err MAIN: STORES R1,R2 LIW R3,#FFFFFFFF STORE R3,R2,PNEG LIW R3,#89ABCDEF STORE R3,R2,S1 LIW R3,#01234567 STORE R3,R2,S1A LIW R3,#11111111 STORE R3,R2,PPOS ADDI R2,R2,ARSIZE LIS R3,0 H #13F3 ; LOADNA R3,R3,SMALLVALUE BR NOINC ; displacement detects increment PC by 2 BR INCOK ; normal NOINC: LEA R3,INCMSG LIL R1,PUTS JSRS R1,R1 ; complain about wrong PC increment BR OTHRTRP ; go test other issues, can't test LOADNA INCOK: LOADNA R3,A1 LIS R4,8 LIL R1,PUTHEX ; expect 76543210 JSRS R1,R1 LIS R3,' ' LIL R1,PUTCHAR JSRS R1,R1 LOADNA R5,A2 MOVE R3,R5 LIS R4,8 LIL R1,PUTHEX ; expect 98765432 JSRS R1,R1 LIS R3,' ' LIL R1,PUTCHAR JSRS R1,R1 LOADNA R7,A3 MOVE R3,R7 LIS R4,8 LIL R1,PUTHEX ; expect BA987654 JSRS R1,R1 LIS R3,' ' LIL R1,PUTCHAR JSRS R1,R1 LOADNA R9,A4 MOVE R3,R9 LIS R4,8 LIL R1,PUTHEX ; expect CDBA9876 JSRS R1,R1 LEA R3,XPECT0 LIL R1,PUTS JSRS R1,R1 LOADNA R10,A6+2 MOVE R3,R10 LIS R4,8 LIL R1,PUTHEX ; expect 55443322 JSRS R1,R1 LEA R3,XPECT1 LIL R1,PUTS JSRS R1,R1 LOADNA R3,R2,S1-ARSIZE LIS R4,8 LIL R1,PUTHEX ; expect 89ABCDEF JSRS R1,R1 LIS R3,' ' LIL R1,PUTCHAR JSRS R1,R1 MOVE R5,R2 LOADNA R11,R5,S2-ARSIZE MOVE R3,R11 LIS R4,8 LIL R1,PUTHEX ; expect 6789ABCD JSRS R1,R1 LIS R3,' ' LIL R1,PUTCHAR JSRS R1,R1 MOVE R10,R2 LOADNA R15,R10,S3-ARSIZE MOVE R3,R15 LIS R4,8 LIL R1,PUTHEX ; expect 456789AB JSRS R1,R1 LIS R3,' ' LIL R1,PUTCHAR JSRS R1,R1 MOVE R11,R2 LOADNA R7,R11,S4-ARSIZE MOVE R3,R7 LIS R4,8 LIL R1,PUTHEX ; expect 23456789 JSRS R1,R1 LEA R3,XPECT2 LIL R1,PUTS JSRS R1,R1 LOADNA R0,A5 ; should force trap NOTRAP: LEA R3,NOEX0 LIL R1,PUTS JSRS R1,R1 OTHRTRP: B #F0,#00 ; should force trap NOP LEA R3,NOEX1 LIL R1,PUTS JSRS R1,R1 B #10,#80 ; should force trap NOP LEA R3,NOEX2 LIL R1,PUTS JSRS R1,R1 B #08,#00 ; should force trap NOP LEA R3,NOEX3 LIL R1,PUTS JSRS R1,R1 ADDI R2,R2,-ARSIZE LOADS R1,R2 JUMPS R1 ALIGN 4 W #FFFFFFFF ; output of this means negative addressing err A1: W #76543210,#FEDCBA98 W #11111111 ; output of this means positive addressing err A2 = A1+1 A3 = A1+2 A4 = A1+3 A5: W NOTRAP INCMSG: ASCII "Increment LOADNA increments PC by wrong amount",LF ASCII "Instr trap expected next",0 XPECT0: ASCII "",LF,"76543210 98765432 BA987654 DCBA9876 < pc-rel",LF,0 XPECT1: ASCII "",LF,"55443322 < pc-rel negative displacement",LF,0 XPECT2: ASCII "",LF,"89ABCDEF 6789ABCD 456789AB 23456789 < on stack top",LF ASCII "Instr trap expected next",0 NOEX0: ASCII "",LF,"F0 1x did not trap",0 NOEX1: ASCII "",LF,"Fx 0x did not trap",0 NOEX2: ASCII "",LF,"1x 8x did not trap",0 NOEX3: ASCII "",LF,"08 xx did not trap",0