我是装配编程的新手,
ADD A,Rn
是1字节指令和
ADD A,direct
是2字节指令。为什么呢?
答案 0 :(得分:1)
ADD A,Rn
可以在一个唯一字节中编码操作码+寄存器号,因此是1字节指令。
有8个不同的操作码保存在1个字节上,由
组成base_operand = 0x28 (only 6 bits are required)
R_register_index = 0->7 (only 3 bits are required)
instruction = base operand OR R_register_index
ADD A,R0 0x28
ADD A,R1 0x29
ADD A,R2 0x2A
ADD A,R3 0x2B
ADD A,R4 0x2C
ADD A,R5 0x2D
ADD A,R6 0x2E
ADD A,R7 0x2F
ADD A,direct
需要1个字节用于操作码,至少需要另一个字节来保存参数,这解释了大小> 1(例如:MOV RO,#12H
:2个字节)
指令大小范围为1到3个字节,但没有关于指令大小的绝对规则。 (对于一些带有2个参数的指令,从内存中读取)
更好地检查参考here,在那里您可以获得所有说明&记忆中的所有大小。
计算大小的更可靠方法是构建指令大小表(IST):opcode =>大小
这就是调试器如何“预测”下一个指令地址。
为了完整起见,请允许我提供此表(注意$A5
是保留的而不是指令:我将大小设置为0)
op sz
$00 => 1
$01 => 2
$02 => 3
$03 => 1
$04 => 1
$05 => 2
$06 => 1
$07 => 1
$08 => 1
$09 => 1
$0A => 1
$0B => 1
$0C => 1
$0D => 1
$0E => 1
$0F => 1
$10 => 3
$11 => 2
$12 => 3
$13 => 1
$14 => 1
$15 => 2
$16 => 1
$17 => 1
$18 => 1
$19 => 1
$1A => 1
$1B => 1
$1C => 1
$1D => 1
$1E => 1
$1F => 1
$20 => 3
$21 => 2
$22 => 1
$23 => 1
$24 => 2
$25 => 2
$26 => 1
$27 => 1
$28 => 1
$29 => 1
$2A => 1
$2B => 1
$2C => 1
$2D => 1
$2E => 1
$2F => 1
$30 => 3
$31 => 2
$32 => 1
$33 => 1
$34 => 2
$35 => 2
$36 => 1
$37 => 1
$38 => 1
$39 => 1
$3A => 1
$3B => 1
$3C => 1
$3D => 1
$3E => 1
$3F => 1
$40 => 2
$41 => 2
$42 => 2
$43 => 3
$44 => 2
$45 => 2
$46 => 1
$47 => 1
$48 => 1
$49 => 1
$4A => 1
$4B => 1
$4C => 1
$4D => 1
$4E => 1
$4F => 1
$50 => 2
$51 => 2
$52 => 2
$53 => 3
$54 => 2
$55 => 2
$56 => 1
$57 => 1
$58 => 1
$59 => 1
$5A => 1
$5B => 1
$5C => 1
$5D => 1
$5E => 1
$5F => 1
$60 => 2
$61 => 2
$62 => 2
$63 => 3
$64 => 2
$65 => 2
$66 => 1
$67 => 1
$68 => 1
$69 => 1
$6A => 1
$6B => 1
$6C => 1
$6D => 1
$6E => 1
$6F => 1
$70 => 2
$71 => 2
$72 => 2
$73 => 1
$74 => 2
$75 => 3
$76 => 2
$77 => 2
$78 => 2
$79 => 2
$7A => 2
$7B => 2
$7C => 2
$7D => 2
$7E => 2
$7F => 2
$80 => 2
$81 => 2
$82 => 2
$83 => 1
$84 => 1
$85 => 3
$86 => 2
$87 => 2
$88 => 2
$89 => 2
$8A => 2
$8B => 2
$8C => 2
$8D => 2
$8E => 2
$8F => 2
$90 => 3
$91 => 2
$92 => 2
$93 => 1
$94 => 2
$95 => 2
$96 => 1
$97 => 1
$98 => 1
$99 => 1
$9A => 1
$9B => 1
$9C => 1
$9D => 1
$9E => 1
$9F => 1
$A0 => 2
$A1 => 2
$A2 => 2
$A3 => 1
$A4 => 1
$A5 => 0
$A6 => 2
$A7 => 2
$A8 => 2
$A9 => 2
$AA => 2
$AB => 2
$AC => 2
$AD => 2
$AE => 2
$AF => 2
$B0 => 2
$B1 => 2
$B2 => 2
$B3 => 1
$B4 => 3
$B5 => 3
$B6 => 3
$B7 => 3
$B8 => 3
$B9 => 3
$BA => 3
$BB => 3
$BC => 3
$BD => 3
$BE => 3
$BF => 3
$C0 => 2
$C1 => 2
$C2 => 2
$C3 => 1
$C4 => 1
$C5 => 2
$C6 => 1
$C7 => 1
$C8 => 1
$C9 => 1
$CA => 1
$CB => 1
$CC => 1
$CD => 1
$CE => 1
$CF => 1
$D0 => 2
$D1 => 2
$D2 => 2
$D3 => 1
$D4 => 1
$D5 => 3
$D6 => 1
$D7 => 1
$D8 => 2
$D9 => 2
$DA => 2
$DB => 2
$DC => 2
$DD => 2
$DE => 2
$DF => 2
$E0 => 1
$E1 => 2
$E2 => 1
$E3 => 1
$E4 => 1
$E5 => 2
$E6 => 1
$E7 => 1
$E8 => 1
$E9 => 1
$EA => 1
$EB => 1
$EC => 1
$ED => 1
$EE => 1
$EF => 1
$F0 => 1
$F1 => 2
$F2 => 1
$F3 => 1
$F4 => 1
$F5 => 2
$F6 => 1
$F7 => 1
$F8 => 1
$F9 => 1
$FA => 1
$FB => 1
$FC => 1
$FD => 1
$FE => 1
$FF => 1
答案 1 :(得分:0)
在大多数情况下,操作码为1字节,#data为1字节,如果有地址或相对加法则为1字节
谢谢