.ORIG X3000 JSR PrntEOL ;; Start with a blank line AND R2,R2,#0 ;; NUMTST <- 0 ST R2,NUMTST LEA R3,TESTS ;; NXTTST <- &TESTS ST R3,NXTTST TSTLOOP LD R3,NXTTST ;; HALT if *NXTTST==0 LDR R3,R3,#0 BRnp x1 HALT LEA R0,TstNmMsg ;; print test number message PUTS LD R0,NUMTST ;; R0 <- NUMTST+1 ADD R0,R0,#1 ST R0,NUMTST ;; NUMTST <- NUMTST+1 JSR PrntHex JSR PrntEOL LD R0,NXTTST ;; R0 <- address of next packet LDR R0,R0,#0 LD R1,TSTFUNC JSRR R1 LEA R0,ResltMsg ;; Print the actual result PUTS ADD R0,R1,#0 JSR PrntHex JSR PrntEOL LEA R0,ExpecMsg ;; Print the expected result PUTS LD R0,NXTTST LDR R0,R0,#1 JSR PrntHex JSR PrntEOL JSR PrntEOL LD R1,NXTTST ;; ++NXTTST (advances two words) ADD R1,R1,#2 ST R1,NXTTST BR TSTLOOP TSTFUNC .FILL x3400 ;; location of function to test NXTTST .BLKW 1 ;; pointer to next Test set NUMTST .BLKW 1 TstNmMsg .STRINGZ "Running Test x" ResltMsg .STRINGZ " Result is x" ExpecMsg .STRINGZ " Should be x" ;; Test sets in two-word packages TESTS .FILL PACK1 ;; Word 0, address of packet .FILL x409F ;; Word 1, expected result .FILL PACK2 .FILL xF45E .FILL PACK3 .FILL x409F .FILL PACK4 .FILL xFFFE .FILL PACK5 .FILL x0000 .FILL x0000 MSG1 .STRINGZ "Running test x" PACK1 .FILL x0054 ;; Version=4, Length=5, TOS=0 .FILL xBEEF ;; length of packet .FILL xFADE ;; fragment ID .FILL x7774 ;; frag offset = x7770, Don't fragment .FILL x2011 ;; UDP protocol, TTL=32 .FILL x0 ;; checksum field .FILL x1298 ;; 152.18 source penrose.cs.unca.edu .FILL x2845 ;; 69.40 .FILL x1298 ;; 152.18 dest newton.engr.unca.edu .FILL x2043 ;; 67.32 ;; Packet one manual check ;; PACK1 .FILL x0054 ;; x0000 + x0054 -> 0,x0054 ;; .FILL xBEEF ;; x0054 + xBEEF -> 0,xBF43 ;; .FILL xFADE ;; xBF43 + xFADE -> 1,xBA21 -> xBA22 ;; .FILL x7774 ;; xBA22 + x7774 -> 1,x3196 -> x3197 ;; .FILL x2011 ;; x3197 + x2011 -> 0,x51A8 ;; .FILL x0 ;; always ignore this field ;; .FILL x1298 ;; x5148 + x1298 -> 0,x6440 ;; .FILL x2845 ;; x6400 + x2845 -> 0,x8C85 ;; .FILL x1298 ;; x8C85 + x1298 -> 0,x9F1D ;; .FILL x2043 ;; x9F1D + x2043 -> 0,xBF60 ;; NOT(xBF60) -> x409F PACK2 .FILL x0074 ;; Version=4, Length=7, TOS=0 .FILL xBEEF ;; length of packet .FILL x5161 ;; fragment ID .FILL x7774 ;; frag offset = x7770, Don't fragment .FILL x2011 ;; UDP protocol, TTL=32 .FILL x0 ;; checksum field .FILL x1298 ;; 152.18 source penrose.cs.unca.edu .FILL x2845 ;; 69.40 .FILL x1298 ;; 152.18 dest newton.engr.unca.edu .FILL x2043 ;; 67.32 .FILL x0789 ;; possibly a strict source route??? .FILL x9804 .FILL x4512 .FILL x10FE ;; PACK2 .FILL x0074 ;; x0000 + x0074 -> 0,x0074 ;; .FILL xBEEF ;; x0074 + xBEEF -> 0,xBF63 ;; .FILL x5161 ;; xBF63 + x5161 -> 1,x10C4 -> x10C5 ;; .FILL x7774 ;; x10C5 + x7774 -> 0,x8839 ;; .FILL x2011 ;; x8839 + x2011 -> 0,xA84A ;; .FILL x0 ;; always ignore this field ;; .FILL x1298 ;; xA84A + x1298 -> 0,xBAE2 ;; .FILL x2845 ;; xBAE2 + x2845 -> 0,xE327 ;; .FILL x1298 ;; xE327 + x1298 -> 0,xF5BF ;; .FILL x2043 ;; xF5BF + x2042 -> 1,x1602 -> x1603 ;; .FILL x0789 ;; x1603 + x0789 -> 0,x1D8C ;; .FILL x9804 ;; x1D8C + x9804 -> 0,xB590 ;; .FILL x4512 ;; xB590 + x4512 -> 0,xFAA2 ;; .FILL x10FE ;; xFAA2 + x10FE -> 1,x0BA0 -> x0BA1 ;; NOT(x0BA1) -> xF45E PACK3 .FILL x0054 ;; Version=4, Length=5, TOS=0 .FILL xBEEF ;; length of packet .FILL xFADE ;; fragment ID .FILL x7774 ;; frag offset = x7770, Don't fragment .FILL x2011 ;; UDP protocol, TTL=32 .FILL x0 ;; checksum field .FILL x1298 ;; 152.18 source penrose.cs.unca.edu .FILL x2845 ;; 69.40 .FILL x1298 ;; 152.18 dest newton.engr.unca.edu .FILL x2043 ;; 67.32 ;; Packet three manual check -- Same as packet one, but with non-zero checksum ;; PACK3 .FILL x0054 ;; x0000 + x0054 -> 0,x0054 ;; .FILL xBEEF ;; x0054 + xBEEF -> 0,xBF43 ;; .FILL xFADE ;; xBF43 + xFADE -> 1,xBA21 -> xBA22 ;; .FILL x7774 ;; xBA22 + x7774 -> 1,x3196 -> x3197 ;; .FILL x2011 ;; x3197 + x2011 -> 0,x51A8 ;; .FILL x409F ;; always ignore this field ;; .FILL x1298 ;; x5148 + x1298 -> 0,x6440 ;; .FILL x2845 ;; x6400 + x2845 -> 0,x8C85 ;; .FILL x1298 ;; x8C85 + x1298 -> 0,x9F1D ;; .FILL x2043 ;; x9F1D + x2043 -> 0,xBF60 ;; NOT(xBF60) -> x409F PACK4 .FILL x0074 ;; Version=4, Length=7, TOS=0 .FILL xBEEF ;; length of packet .FILL x5161 ;; fragment ID .FILL x7774 ;; frag offset = x7770, Don't fragment .FILL x2011 ;; UDP protocol, TTL=32 .FILL x0 ;; checksum field .FILL x1298 ;; 152.18 source penrose.cs.unca.edu .FILL x2845 ;; 69.40 .FILL x1298 ;; 152.18 dest newton.engr.unca.edu .FILL x2043 ;; 67.32 .FILL x0789 ;; possibly a strict source route??? .FILL x9804 .FILL x4512 .FILL x055E ;; PACK4 .FILL x0074 ;; x0000 + x0074 -> 0,x0074 ;; .FILL xBEEF ;; x0074 + xBEEF -> 0,xBF63 ;; .FILL x5161 ;; xBF63 + x5161 -> 1,x10C4 -> x10C5 ;; .FILL x7774 ;; x10C5 + x7774 -> 0,x8839 ;; .FILL x2011 ;; x8839 + x2011 -> 0,xA84A ;; .FILL x0 ;; always ignore this field ;; .FILL x1298 ;; xA84A + x1298 -> 0,xBAE2 ;; .FILL x2845 ;; xBAE2 + x2845 -> 0,xE327 ;; .FILL x1298 ;; xE327 + x1298 -> 0,xF5BF ;; .FILL x2043 ;; xF5BF + x2042 -> 1,x1602 -> x1603 ;; .FILL x0789 ;; x1603 + x0789 -> 0,x1D8C ;; .FILL x9804 ;; x1D8C + x9804 -> 0,xB590 ;; .FILL x4512 ;; xB590 + x4512 -> 0,xFAA2 ;; .FILL x055E ;; xFAA2 + x055E -> 1,x0000 -> x0001 ;; NOT(x0001) -> xFFFE PACK5 .FILL x0074 ;; Version=4, Length=7, TOS=0 .FILL xBEEF ;; length of packet .FILL x5161 ;; fragment ID .FILL x7774 ;; frag offset = x7770, Don't fragment .FILL x2011 ;; UDP protocol, TTL=32 .FILL x0 ;; checksum field .FILL x1298 ;; 152.18 source penrose.cs.unca.edu .FILL x2845 ;; 69.40 .FILL x1298 ;; 152.18 dest newton.engr.unca.edu .FILL x2043 ;; 67.32 .FILL x0789 ;; possibly a strict source route??? .FILL x9804 .FILL x4512 .FILL x055D ;; PACK5 .FILL x0074 ;; x0000 + x0074 -> 0,x0074 ;; .FILL xBEEF ;; x0074 + xBEEF -> 0,xBF63 ;; .FILL x5161 ;; xBF63 + x5161 -> 1,x10C4 -> x10C5 ;; .FILL x7774 ;; x10C5 + x7774 -> 0,x8839 ;; .FILL x2011 ;; x8839 + x2011 -> 0,xA84A ;; .FILL x0 ;; always ignore this field ;; .FILL x1298 ;; xA84A + x1298 -> 0,xBAE2 ;; .FILL x2845 ;; xBAE2 + x2845 -> 0,xE327 ;; .FILL x1298 ;; xE327 + x1298 -> 0,xF5BF ;; .FILL x2043 ;; xF5BF + x2042 -> 1,x1602 -> x1603 ;; .FILL x0789 ;; x1603 + x0789 -> 0,x1D8C ;; .FILL x9804 ;; x1D8C + x9804 -> 0,xB590 ;; .FILL x4512 ;; xB590 + x4512 -> 0,xFAA2 ;; .FILL x055D ;; xFAA2 + x055D -> 0,xFFFF ;; NOT(xFFFF) -> x0000 ;; PrntHex ;; Input ;; R0 -- value to be printed in hex ;; Saved registers ;; None PrntHex ST R7,PHRA ;; Save R7 which would be overwritten by OUT ADD R4,R0,#0 ;; R4 <- 0 AND R2,R2,#0 ;; R2 <- 4 ADD R2,R2,#4 ;; Execute PHL1 loop for each nibble (4 bits) of the word PHL1 AND R1,R1,#0 ADD R3,R1,#4 ;; R3 <- 4 ;; Execute PHL2 loop for each bit of the nibble PHL2 ADD R1,R1,R1 ;; circular shift of R1, R4 ADD R4,R4,#0 BRzp x1 ADD R1,R1,#1 ADD R4,R4,R4 ADD R3,R3,#-1 BRp PHL2 ;; Print R1 in hex LD R0,K48 ADD R3,R1,#-10 BRn x1 ADD R0,R0,#7 ;; need to print as letter ADD R0,R0,R1 OUT ADD R2,R2,#-1 BRp PHL1 LD R7,PHRA RET PHRA .BLKW 1 K48 .FILL #48 ;; Prints an EOL ;; Putting it as a routine makes it easier to deal ;; with difference between Windows and Unix line formats PrntEOL ST R7,PERA LEA R0,EOL PUTS LD R7,PERA RET PERA .BLKW 1 EOL .STRINGZ "\r" .END