Assembling SIA
Assembling SIA is similar to assembling other assembly languages. With SIA, almost every instruction is aligned with a 4 bit nibble, so all assembly should be presented in hexadecimal.
Step 1: Determine the opcode. Use the SIA documentation to find the opcode. Note that these are in decimal; convert to hexadecimal. That will be the first “digit” of the first byte.
Step 2: Find the format. The SIA documentation lists the format for an instruction. For example, add uses the “3R” format. Find the “3R” section of the document.
Assembling SIA 代写Step 3: Determine the remaining portions of the hexadecimal. This depends on the opcode. Make sure to note instructions that require 32 bits instead of 16 bits (jump and branches).
Example:
add R3 R7 R12
Step1: add (opcode 1)
Step 2: Instruction format: 3R
Step 3:
4 bits 4 bits 4 bits 4 bits
OPCODE register 1 register 2 destination (register 3)
1 3 7 C
Thus, the complete assembly is 13 7C
Example:
jump 48
Step 1: Jump (opcode 7)
Step 2: Instruction format br2
br2
4 bits 4 bits 8 bits
OPCODE Branch type Top 8 bits of address
Bottom 16 bits of address
Thus, the complete assembly is: 77 00 00 18
Example:
push r2
Step 1: push (opcode 10)
Step 2: Instruction format: stack
4 bits 4 bits 2 bits 6 bits
OPCODE register 00 = return, 01 = push, 10 = pop Unused (set to 0)
Thus the complete assembly is A2 40
Example:
move R2 100
Step 1: move (opcode 11)
Step 2: Instruction format: Move
4 bits 4 bits 8 bits
OPCODE register 1 immediate value (signed)
Thus the completed assembly is B2 64
如有需要,请加QQ:99515681 或邮箱:[email protected] 微信:codehelp