TFR and EXR: 8bit <-> 16bit and undefined registers?!?

Hardware Hacking, Programming and Game Solutions/Cheats
Post Reply
jedie
Posts: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

TFR and EXR: 8bit <-> 16bit and undefined registers?!?

Post by jedie »

What happen on real hardware if transfer/exchange a...:
*... 16Bit Register into a 8Bit register?
*... 8Bit Register into a 16Bit register?
*... Undefined Register into existing register?
*... existing register into Undefined Register?

I read the XRoar code, e.g.: https://github.com/jedie/XRoar/blob/b1b ... #L542-L560
There is the commend TODO: verify this behaviour

The XRoar behaviour is this, e.g.:
8bit $cd TFR into 16bit, results in $cd00
16bit $1234 TFR into 8bit, results in: $34
undefined TFR to 8bit register -> $ff and into 16bit reg. -> $ffff
EXG 8Bit reg $56 with 16Bit reg. $1234 results in: 8bit reg: $34 and 16bit reg: $ff56
EXT 16Bit $1234 and 8bit $fe results in: 16bit $fe00 and 8bit $34

Does anybody verify on real hardware?
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
sixxie
Posts: 1346
Joined: Fri Jul 18, 2008 8:36 am
Location: Hertfordshire
Contact:

Re: TFR and EXR: 8bit <-> 16bit and undefined registers?!?

Post by sixxie »

jedie wrote: I read the XRoar code, e.g.: https://github.com/jedie/XRoar/blob/b1b ... #L542-L560
There is the commend TODO: verify this behaviour
That refers to the two following lines concerning CC & DP - the behaviour as described by Darren A. I just haven't actually run that as test code yet...
The XRoar behaviour is this, e.g.:
8bit $cd TFR into 16bit, results in $cd00
16bit $1234 TFR into 8bit, results in: $34
undefined TFR to 8bit register -> $ff and into 16bit reg. -> $ffff
EXG 8Bit reg $56 with 16Bit reg. $1234 results in: 8bit reg: $34 and 16bit reg: $ff56
EXT 16Bit $1234 and 8bit $fe results in: 16bit $fe00 and 8bit $34
It really shouldn't be, and it's not something I can replicate:

Code: Select all

4000| 8e0000      LDX     #$0000              cc=a4 a=00 b=ff dp=00 x=0000 y=0197 u=c562 s=7f2c
4003| 86cd        LDA     #$cd                cc=a8 a=cd b=ff dp=00 x=0000 y=0197 u=c562 s=7f2c
4005| 1f81        TFR     A,X                 cc=a8 a=cd b=ff dp=00 x=ffcd y=0197 u=c562 s=7f2c
4007| 8e1234      LDX     #$1234              cc=a0 a=cd b=ff dp=00 x=1234 y=0197 u=c562 s=7f2c
400a| 8600        LDA     #$00                cc=a4 a=00 b=ff dp=00 x=1234 y=0197 u=c562 s=7f2c
400c| 1f18        TFR     X,A                 cc=a4 a=34 b=ff dp=00 x=1234 y=0197 u=c562 s=7f2c
400e| 8e1234      LDX     #$1234              cc=a0 a=34 b=ff dp=00 x=1234 y=0197 u=c562 s=7f2c
4011| 8656        LDA     #$56                cc=a0 a=56 b=ff dp=00 x=1234 y=0197 u=c562 s=7f2c
4013| 1e81        EXG     A,X                 cc=a0 a=34 b=ff dp=00 x=ff56 y=0197 u=c562 s=7f2c
4015| 8e1234      LDX     #$1234              cc=a0 a=34 b=ff dp=00 x=1234 y=0197 u=c562 s=7f2c
4018| 86fe        LDA     #$fe                cc=a8 a=fe b=ff dp=00 x=1234 y=0197 u=c562 s=7f2c
401a| 1e18        EXG     X,A                 cc=a8 a=34 b=ff dp=00 x=fffe y=0197 u=c562 s=7f2c
That behaviour is something I researched really quite a long time ago now!

If you'll excuse the writing style of a teenager that had read one too many Jason Orbaum reviews, but lacked the ability to emulate him: http://www.6809.org.uk/dragon/illegal-opcodes.shtml
jedie
Posts: 655
Joined: Wed Aug 14, 2013 12:23 pm
Location: germany
Contact:

Re: TFR and EXR: 8bit <-> 16bit and undefined registers?!?

Post by jedie »

sixxie wrote: It really shouldn't be, and it's not something I can replicate:

Code: Select all

4000| 8e0000      LDX     #$0000              cc=a4 a=00 b=ff dp=00 x=0000 y=0197 u=c562 s=7f2c
4003| 86cd        LDA     #$cd                cc=a8 a=cd b=ff dp=00 x=0000 y=0197 u=c562 s=7f2c
4005| 1f81        TFR     A,X                 cc=a8 a=cd b=ff dp=00 x=ffcd y=0197 u=c562 s=7f2c
4007| 8e1234      LDX     #$1234              cc=a0 a=cd b=ff dp=00 x=1234 y=0197 u=c562 s=7f2c
400a| 8600        LDA     #$00                cc=a4 a=00 b=ff dp=00 x=1234 y=0197 u=c562 s=7f2c
400c| 1f18        TFR     X,A                 cc=a4 a=34 b=ff dp=00 x=1234 y=0197 u=c562 s=7f2c
400e| 8e1234      LDX     #$1234              cc=a0 a=34 b=ff dp=00 x=1234 y=0197 u=c562 s=7f2c
4011| 8656        LDA     #$56                cc=a0 a=56 b=ff dp=00 x=1234 y=0197 u=c562 s=7f2c
4013| 1e81        EXG     A,X                 cc=a0 a=34 b=ff dp=00 x=ff56 y=0197 u=c562 s=7f2c
4015| 8e1234      LDX     #$1234              cc=a0 a=34 b=ff dp=00 x=1234 y=0197 u=c562 s=7f2c
4018| 86fe        LDA     #$fe                cc=a8 a=fe b=ff dp=00 x=1234 y=0197 u=c562 s=7f2c
401a| 1e18        EXG     X,A                 cc=a8 a=34 b=ff dp=00 x=fffe y=0197 u=c562 s=7f2c
btw. can you explain how do to make this dump?
I know the -trace option. But how to feed xroar? Create a "test" rom ?
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
sixxie
Posts: 1346
Joined: Fri Jul 18, 2008 8:36 am
Location: Hertfordshire
Contact:

Re: TFR and EXR: 8bit <-> 16bit and undefined registers?!?

Post by sixxie »

I just create a .bin file (DragonDOS or CoCo RSDOS) and run it in XRoar... you can run "xroar -trace filename.bin | less" and then search, say: /^4000

You could certainly do it with a rom image instead and search for c000...

Oh, even better: xroar -trace filename.bin | awk '/^4000/,0' | less
Post Reply