6502 中 $# 和 % 的意义是什么?

问题描述

平台

  • 6502 模拟器
  • DASM 汇编器
  • Windows 10

我的号码从

开始

#2

$2F

%0000111

我不明白为什么在6502的汇编代码中使用#$%?

有时 ldx #$FF

使用#$FF 加载 x 寄存器

为什么这里使用两个符号?

解决方法

DASM 允许以二进制、八进制、十进制和十六进制表示数字。

  • 二进制数字使用 % 前缀(例如 %1101)。
  • 八进制数字使用 0 前缀(例如 015)。
  • 十进制数字不使用前缀(例如 13)。
  • 十六进制数字使用 $ 前缀(例如 $0D)。

# 符号用于指定立即寻址:

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
,

这些符号是许多平台上的许多汇编器使用的常见语法糖,旨在使人们更容易向汇编器提供基数为 2、10 和 16(二进制、十进制和十六进制)的数值:

%00001100 means 12 in binary
12 means 12 in decimal
$0C means 12 in hexadecimal

# 符号在包括 DASM 在内的众多汇编语法中作为寻址指示符具有更重要的意义:

LDA #%00001100 loads 12 into the Accumulator
LDA #12 loads 12 into the Accumulator
LDA #$0C loads 12 into the Accumulator
LDA $0C loads the contents of memory location 12 into the Accumulator

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...