联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Python编程Python编程

日期:2020-02-21 09:14

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.

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 bits4 bits4 bits4 bits

OPCODEregister 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 bits4 bits2 bits6 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 bits4 bits8 bits

OPCODEregister 1 immediate value (signed)

Thus the completed assembly is B2 64


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp