I am trying to remove a circular dependencies from the 6502 assembly in my interpreter but I am not having very much success.
I have reduced my code down to the essential components to demonstrate the issue.
There is a jump from commandLoop.s to a jump table in logicCommands.s, and the another jmp back again. There is an exports.s file so that certain assembly labels are exported for visibility to C code (not shown).
When I attempt to compile this code I receive a: ld65: Error: Duplicate external identifier: 'returnFromOpCodeFalse'
Shifting exports around can make the error go away, but can cause a 'same variable name two different addresses' issue.
I hope my understanding that the global keyword serves as both an export and import command is correct.
I expect there is a dynamic that I don't quite understand.
So in summary I need to know what is the best way to share labels in both directions between two assembly files, and export some of those labels so as to be visible by C.
Here is the code.
commandLoop.s:
Code: Select all
.ifndef COMMAND_LOOP_INC
COMMAND_LOOP_INC = 1
.include "logicCommands.s"
.global returnFromOpCodeFalse
_commandLoop:
ldx #$0
jmp (jmpTable,x)
returnFromOpCodeFalse:
.endif
Code: Select all
.ifndef LOGICCOMMANDS_INC
LOGICCOMMANDS_INC = 1
.global returnFromOpCodeFalse
jmpTable:
.addr b1GreaterThan
b1GreaterThan:
jmp returnFromOpCodeFalse
.endif
Code: Select all
.include "commandLoop.s"
.export _commandLoop