【发布时间】:2016-05-25 15:32:22
【问题描述】:
我正在研究 Brandon W 为 ti-84 设计的“假”应用程序,以了解它是如何工作的。 (http://brandonw.net/calculators/fake/) 在查看代码时,我注意到许多我不理解的标签和跳转指令。我想了解他是如何使用这些美元符号和跳跃的。我的问题在以下代码 sn-p 中提出:(所有代码均来自 Brandon W 的开源假应用程序!)
resetKeys:
xor a
ld (de),a
$$: ld a,(MenuCurrent) ;How is this label two dollar signs? What does this mean?
cp 02h
jr nz,$F ;Are we jumping to the instruction at 0xF or to one of these dollar sign labels?
ld hl,sFakeAppVar
rst 20h
B_CALL ChkFindSym
jr c,$F ;If we are jumping to 0xF, what are the dollar signs used for?
ld a,b
or a
jr nz,$F
inc de
inc de
ld a,(de)
cp 25h
jr z,ignoreAppsKeys
cp 26h
jr z,ignoreAppsKeys
cp 27h
jr z,ignoreAppsKeys
$$: pop af ;Here's another
ld b,a
ld a,(cxCurApp)
cp 45h
jr nz,$F
ld a,b
cp kCapS
jr nz,$F
根据我的研究,美元符号用于表示十六进制或当前位置计数器。如果我错了,请纠正我。任何帮助将不胜感激!
【问题讨论】:
-
如果我冒险猜测
$F意味着找到下一个(Forward)$$标签并分支/jmp 到它。我认为$$充当临时标签。$B很有可能会转到Backward 到之前的$$标签。这只是基于其他一些汇编器语法的猜测。 -
@MichaelPetch 非常感谢!
-
jr c,$F如果进位标志为 1,则为相对跳转。所以如果carry flag == 1那么PC = PC + 0x0F。不要忘记 PC 已经指向下一条指令,所以要明确的是PC = address_of_next_instruction + 0x0F。