I spent about 20 minutes finding a bug this morning. For a complex bug, that’s not so terrible, but this wasn’t a complex one.
The emulator uses different storage for the Windows version (RAM arrays) and the Arduino version (Flash memory) because the 2650 just doesn’t have very much RAM memory, so the ROM images are permanent in Flash.
So I wrote some Macros in ‘C’ to create and access these.
When I added support for ROM at $9000-$9FFF into the emulator, this involved putting these macros in and amending the Read() inline function to cope with reading from this space.
Worked perfectly in the emulator version, didn’t work at all on the Arduino one.
Lots of headscratching.
Eventually it dawned on me that I’d written something like :
MB = extendedROMMemory[MA-0x9000]
on the Read inline function.
This is why it didn’t work ; I was always using the static RAM access in either version, whereas to access Arduino flash you have to use a function pgm_read_byte_far() or something like that.
This was despite writing a Macro to do this automatically (so you just put in ROM(extendedROMMemory,MA-0x9000) and it did the work for you) and having an example immediately above (reading from the Monitor ROM space) to copy.
I felt very dim when I realised it…..
Answer to the question in the last post:
VTL-2 allows punctuation to be used for variables, including ‘=’ so ===== becomes, if we replace the = that refers to the variable '=' with 'E' it becomes
E = E = E
E = E as an expression is 1 (VTL's "True") so it becomes
E = 1