AM and ADM destinations

classic Classic list List threaded Threaded
3 messages Options
...
Reply | Threaded
Open this post in threaded view
|

AM and ADM destinations

...
So, as far as I reached, the AM and ADM instructions store data in the A register and in the memory, and in case of ADM also in the D register. But when trying to recode this, should I change the A register before or after commiting changes to the RAM?
Reply | Threaded
Open this post in threaded view
|

Re: AM and ADM destinations

WBahn
Administrator
... wrote
So, as far as I reached, the AM and ADM instructions store data in the A register and in the memory, and in case of ADM also in the D register. But when trying to recode this, should I change the A register before or after commiting changes to the RAM?
After. All register/memory writes reflect the values that were present at the end of the prior instruction.

Be aware that one of the author's emulators violates this behavior. I think it is the A register. I don't recall the details or if the current version of that tool has been fixed. It's a bug that only rears it's head in very unusual circumstances, none of which are relevant to any of the N2T projects, which is why it went undiscovered for so long.
Reply | Threaded
Open this post in threaded view
|

Re: AM and ADM destinations

dolomiti7
The register updates should happen after all other changes. The original emulator was correct for instructions like AM=M+1, with the semantics that M refers to [A_before]. E.g. AM=M+1 => A_after=RAM[A_before]+1; RAM[A_before]=RAM[A_before]+1

What the Java based emulator didn't implement correctly are corner cases like:

A=0;JMP, where PC should be A_before, but the emulator would jump to address 0 instead. This has been fixed in the web-based emulator though.