The basic Hawk instruction execution cycle is:
repeat IR = M[PC] (fetching a halfword) PC = PC + 2 decode and execute IR foreverThis is given in more detail in the Hawk Architecture Overview section on the Instruction Execution Cycle. The actual instruction set is defined by the decode and execute step. This breaks IR into 4 fields.
_______________________________ |_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_| |15 12|11 8|7 4|3 0| | op | dst |For all Hawk instructions, the op field gives the basic or class of operations to be performed by this instruction. For example, all memory reference isntructions use op=1111. Most Hawk instructions use the dst field to specify the register to be manipulated (usually, this is the destination register).
The most elementary memory reference instructions are LOADS and STORES (load and store, short format). These are fully defined in the Load and Store sections of the Hawk Architecture Manual. These instructions have the following format:
_______________________________ |_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_| |15 12|11 8|7 4|3 0| |1 1 1 1| dst | op1 | x |A short load moves a 32 bit word from the memory location pointed to by r[x] to r[dst]; this is coded with op1=0110. A short store moves from r[dst] to the memory location pointed to by r[x]; this is coded with op1=0010. More formally:
LOADS: r[dst] = m[r[x]] STORES: m[r[x]] = r[dst]To put the instruction LOADS R3,R2 in memory, it would be legal to write the SMAL assembly code:
H #F362However, a file of standard definitions is provided so that this instruction can be written as:
LOADS R3,R2
It is important to be able to load constants into memory! The Hawk architecture provides three basic instructions for loading constants; the first of these is Load Immediate Long, or LIL. This is documented in the Hawk manual section on Long Immediate Format Instructions.
_______________________________ |_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_| |15 12|11 8|7 4|3 0| |1 1 1 0| dst | const | _______________________________ |_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_| |15 0| | const |This instruction is 32 bits long; the 8 bits from bits 7 to 0 of the first halfowrd of the instruction go in bits 23 to 16 of the destination register, while the second halfowrd of the instruction goes in the low halfword of the destination register. The constant is sign extended to fill the full destination register.
Sign extension of 2's complement numbers involves repeating the sign bit of the number to fill all bit positions above that number. Thus, to sign extend a 24 bit constant to fill a 32 bit register, the most significant bit of the 24 bit constant (bit 23) is duplicated into the high 8 bits of the 32 bit register (bits 32 to 24).
The Load Immediate Short instruction is faster and more compact; it is used to load a sign extended 8 bit value into a register. The Or Register Immediate Shifted instruction is designed to finish off the loading process started by a Load Immediate Long instruction, shifting an additional 8 bit constant into place. These are fully documented in the Hawk manual section on Short Immediate Format Instructions.
Once you type the command:
source /group/22c018/setuptwo commands are enabled, the smal command, which runs our symbolic macro assembly language, and the hawk command, which runs the Hawk computer emulator.
Your first assembly language program for the Hawk computer should begin with the following text:
TITLE -your name and program purpose here- USE "/group/22c018/hawk.macs" . = #1000 S .All of these assembly directives are documented in the Miscelaneous Assembly Directives section of the SMAL manual. The TITLE directive adds a title to each page of the assembly listing. The USE directive inserts the text from the named file before your own program text, and the S directive sets the starting address.
The file /group/22c018/hawk.macs contains a set of standard definitions, including names of registers (R1 to R15) symbolic names for the starting addresses of ROM and RAM, and, most important, a set of macro definitions for the machine instructions of the Hawk!
The line in the standard header that reads . = #1000 is an example of an assembly-time assignment. This assigns the the value #1000 (4096) to the special symbol . (dot), which stands for the assembly time location counter. The effect of this is to cause the output of the assembler to be stored starting in location #1000 in the Hawk memory. This is discussed in the section on Directives in the Basic Syntax section of the SMAL32 Manual.
As a general rule, low addresses in the Hawk memory should not be used for user code!
To assemble and run a SMAL Hawk program stored in a file called test.a, first type:
smal test.aIf the assembler indicates any errors, fix them. You may need to look at test.l, the assembler listing, to find the errors. When there are no assembly errors, the assembler output test.o can be run by typing:
hawk test.oThis starts the Hawk emulator; it will begin by displaying the state of the Hawk machine, with your program in memory and the program counter set to the starting address specified in your code. If your program began as suggested above, PC should be 00001000, an address in ROM:
HAWK EMULATOR /------------------CPU------------------\ /----MEMORY----\ PC: 00001000 R8: 00000000 000FFA: #0000 PSW: 00000000 R1: 00000000 R9: 00000000 000FFC: #0000 NZVC: 0 0 0 0 R2: 00000000 RA: 00000000 000FFE: #0000 R3: 00000000 RB: 00000000 ->001000: LIL #1,#001000 R4: 00000000 RC: 00000000 001004: LIS #2,#20 R5: 00000000 RD: 00000000 001006: LIL #3,#012345 R6: 00000000 RE: 00000000 00100A: ORIS #3,#67 R7: 00000000 RF: 00000000 00100C: LIL #4,#00101C **HALTED** r(run) s(step) q(quit) ?(help)The menu at the bottom shows the commands that are currently active. Typing ? will display other available commands. When the emulator is halted, the following commands are available: