我正在使用 Delphi pascal 进行简单的 PIC18 MCPU 助记符模拟。是的,我打算使用 Delphi IDE。我可以模拟任何 asm 指令,但它停在标签处。在某些情况下,我需要知道 Delphi 标签的地址。是否有可能将标签转换为指针变量?
就像我的例子一样?
procedure addlw(const n:byte); //emulation of mcpu addlw instruction
begin
Carry := (wreg + n) >= 256;
wreg := wreg + n;
Zero := wreg = 0;
inc(CpuCycles);
end;
procedure bnc(p: pointer ); //emulation of mcpu bnc instruction
asm
inc CpuCycles
cmp byte ptr Carry, 0
jnz @exit
pop eax //restore return addres from stack
jmp p
@exit:
end;
//模拟MCPU ASM代码
procedure Test;
label
Top;
var
p: pointer;
begin
//
Top:
addlw(5); //emulated mcpu addlw instruction
bnc(Top); //emulated mcpu bnc branch if not carry instruction
//
end;