; demo.a -- Demonstration of what the SMAL assembler does ; with Hawk machine instructions. ; It's useful to assemble this and look at the listing file, ; and it's useful to then run the Hawk emulator on the object file. ; the following code is a greatly simplified version of hawk.h ; the definitions here are incompatible with hawk.h ; but should be easier to understand. R1 = 1 R2 = 2 R3 = 3 R4 = 4 R5 = 5 R6 = 6 R7 = 7 R8 = 8 R9 = 9 R10 = 10 R11 = 11 R12 = 12 R13 = 13 MACRO LIS r,c B #D0 + r B c ENDMAC MACRO ADD rd,rs1,rs2 B #30 + rd B rs1 << 4 + rs2 ENDMAC MACRO LIL r,c B #E0 + r T c ENDMAC MACRO ORIS r,c B #C0 + r B c ENDMAC MACRO LIW r,c LIL r,c >> 8 ORIS r,c & #FF ENDMAC MACRO LOADS r,x B #F0 + r B #D0 + x ENDMAC MACRO STORES r,x B #F0 + r B #A0 + x ENDMAC ; end of simplified hawk.h file ; the following code uses the above macros to assemble Hawk code ; different ways to put LIS instructions in memory B 2#11010011, 2#00000001 B #D4,#02 H #03D5 LIS R6,-1 ; different ways to put ADD instructions in memory B 2#00110111, 2#00110100 ADD R8,R5,R6 ; different ways to put LIL instructions in memory B 2#11101000, 2#11101111, 2#11001101, 2#10101011 LIL R9,#012345 ; different ways to load 32 bit constants LIL R10,#012345 ORIS R10,#67 LIW R11,#01234567 ; move something to and from memory LIL R12,#00010000 ; first address in RAM STORES R11,R12 LOADS R13,R12 END