JenniferDigital wrote:
I think I found and fixed a bug, but before declaring it done, I'd just like for all you beautiful people to just look it over and see if I've missed any subtleties.
Code:
; perform SWAP
LAB_SWAP
JSR LAB_GVAR ; get var1 address
STA Lvarpl ; save var1 address low byte
STY Lvarph ; save var1 address high byte
LDA Dtypef ; get data type flag, $FF=string, $00=numeric
PHA ; save data type flag
JSR LAB_1C01 ; scan for "," , else do syntax error then warm start
JSR LAB_GVAR ; get var2 address (pointer in Cvaral/h)
PLA ; pull var1 data type flag
EOR Dtypef ; compare with var2 data type
; BUGFIX: SWAP would only swap a string with a number otherwise it would generate an error!
;
; BPL SwapErr ; exit if not both the same type
BNE SwapErr ; exit if not both the same type
;
; End of bugfix.
Hm... Not a great fan of diving into ehBasic, but I've had a quick look..
The test is for a string type vs. numeric type. String type is $FF, numeric is $00.
So number EOR number: $00 eor $00 -> 0 (positive)
String EOR string: $FF eor $FF -> 0 (positive)
Number EOR String: $00 EOR $FF -> $FF (negative)
I actually think the branch ought to be (or was intended to be) BMI rather than BPL, but BNE here works too. (So a logic swap waaaaaaay back)
It also makes me think that
no-one has ever used the SWAP command...
Attachment:
Screenshot_2023-06-01_21-23-52.png [ 17.57 KiB | Viewed 14383 times ]
Swapping a number & string is ... interesting:
Attachment:
Screenshot_2023-06-01_21-25-35.png [ 17.93 KiB | Viewed 14383 times ]
I patched my version (the Floobydust 2.22p5C version) with BMI and it works as it ought to.
Cheers,
-Gordon
_________________
--
Gordon Henderson.
See my
Ruby 6502 and 65816 SBC projects here:
https://projects.drogon.net/ruby/