6502中的$#和%有什么意义?
What is the significance of $ # and % in 6502?
平台
- 6502 模拟器
- DASM 汇编程序
- Windows 10
我的号码从
开始
#2
$2F
%0000111
不明白为什么6502的汇编代码里要用#$%?
有时 ldx #$FF
用#$FF
加载x寄存器
这里为什么用两个符号?
这些符号是许多平台上的许多汇编程序使用的常见语法糖,旨在使人们更容易以 2、10 和 16(二进制、十进制和十六进制)为基数向汇编程序提供数值):
%00001100 means 12 in binary
12 means 12 in decimal
[=10=]C means 12 in hexadecimal
#
符号在包括 DASM 在内的众多汇编语法中作为寻址指示符具有进一步的意义:
LDA #%00001100 loads 12 into the Accumulator
LDA #12 loads 12 into the Accumulator
LDA #[=11=]C loads 12 into the Accumulator
LDA [=11=]C loads the contents of memory location 12 into the Accumulator
DASM 允许用二进制、八进制、十进制和十六进制表示数字。
- 二进制数使用
%
前缀(例如 %1101
)。
- 八进制数使用
0
前缀(例如 015
)。
- 小数不使用前缀(例如
13
)。
- 十六进制数使用
$
前缀(例如 [=18=]D
)。
#
符号用于指定立即寻址:
LDA 0 ; Load the byte from address 0 in memory into register A
LDA #0 ; Load the value 0 into register A
当然可以将立即寻址与不同的基数结合起来,例如:
LDA #$FF ; Load the value $FF into register A
平台
- 6502 模拟器
- DASM 汇编程序
- Windows 10
我的号码从
开始#2
$2F
%0000111
不明白为什么6502的汇编代码里要用#$%?
有时 ldx #$FF
用#$FF
加载x寄存器这里为什么用两个符号?
这些符号是许多平台上的许多汇编程序使用的常见语法糖,旨在使人们更容易以 2、10 和 16(二进制、十进制和十六进制)为基数向汇编程序提供数值):
%00001100 means 12 in binary
12 means 12 in decimal
[=10=]C means 12 in hexadecimal
#
符号在包括 DASM 在内的众多汇编语法中作为寻址指示符具有进一步的意义:
LDA #%00001100 loads 12 into the Accumulator
LDA #12 loads 12 into the Accumulator
LDA #[=11=]C loads 12 into the Accumulator
LDA [=11=]C loads the contents of memory location 12 into the Accumulator
DASM 允许用二进制、八进制、十进制和十六进制表示数字。
- 二进制数使用
%
前缀(例如%1101
)。 - 八进制数使用
0
前缀(例如015
)。 - 小数不使用前缀(例如
13
)。 - 十六进制数使用
$
前缀(例如[=18=]D
)。
#
符号用于指定立即寻址:
LDA 0 ; Load the byte from address 0 in memory into register A
LDA #0 ; Load the value 0 into register A
当然可以将立即寻址与不同的基数结合起来,例如:
LDA #$FF ; Load the value $FF into register A