Assembling SIA

筅森魡賤 提交于 2020-02-25 19:26:03


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 或邮箱:99515681@qq.com 微信:codehelp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!