CPCWiki forum

General Category => Programming => Topic started by: ervin on 15:08, 09 September 10

Title: WinAPE and EXX in assembler
Post by: ervin on 15:08, 09 September 10
Hi all.

I'm having a rather odd problem.

This code causes strange behaviour when assembled and run from WinAPE's assembler:
org &4000

di
exx
ld bc,2
exx
ei

ret


As far as I understand it, this should be ok, as HL, DE & BC all have alternate registers which can be accessed via EXX.
The above code is fine if I use HL or DE instead of BC.

Am I doing something wrong?
Or does WinAPE have a problem with this sort of thing?

Thanks for any help.
Title: Re: WinAPE and EXX in assembler
Post by: arnoldemu on 15:10, 09 September 10
Quote from: ervin on 15:08, 09 September 10
Hi all.

I'm having a rather odd problem.

This code causes strange behaviour when assembled and run from WinAPE's assembler:
org &4000

di
exx
ld bc,2
exx
ei

ret


As far as I understand it, this should be ok, as HL, DE & BC all have alternate registers which can be accessed via EXX.
The above code is fine if I use HL or DE instead of BC.

Am I doing something wrong?
Or does WinAPE have a problem with this sort of thing?

Thanks for any help.
I see you're returning back to basic.
Basic/firmware uses BC' to store the I/O address of the gate-array and the current state of the roms and video mode.

So really you need to store firmware's version of BC' and restore it back before you return.
Title: Re: WinAPE and EXX in assembler
Post by: ervin on 15:14, 09 September 10
Quote from: arnoldemu on 15:10, 09 September 10
I see you're returning back to basic.
Basic/firmware uses BC' to store the I/O address of the gate-array and the current state of the roms and video mode.

So really you need to store firmware's version of BC' and restore it back before you return.

Holy cow that was a quick reply!

Okay, I've changed the code to this:
org &4000

di
exx
push bc
ld bc,2
pop bc
exx
ei

ret


and the problem has gone away!

Awesome stuff. Thanks for your help dude.
Title: Re: WinAPE and EXX in assembler
Post by: TFM on 22:16, 10 September 10
You also should save the content of AF' under BASIC. Using CP/M you can use all the registers of the Z80.
Title: Re: WinAPE and EXX in assembler
Post by: ervin on 23:31, 10 September 10
Cool, thanks for the tip.
8)
Powered by SMFPacks Menu Editor Mod