ZX81, Alternate Register Pair HL' Used By System?
ZX81, Alternate Register Pair HL' Used By System?
Hopefully a simple question for the experts here-
It seems changing the value in the hl' (alternate) register pair causes the ZX81 to crash. I thought the prime registers were safe to use, except af' which is used by the screen display routines. Is hl' used, what for, and is there a particular value it should contain on return to BASIC? Any of the others (bc' de')?
It seems changing the value in the hl' (alternate) register pair causes the ZX81 to crash. I thought the prime registers were safe to use, except af' which is used by the screen display routines. Is hl' used, what for, and is there a particular value it should contain on return to BASIC? Any of the others (bc' de')?
Re: ZX81, Alternate Register Pair HL' Used By System?
Wild guess:
Call to MC uses FP-calc which need the value of HL' on return.
So
EXX
PUSH HL
before running code
And on end
POP HL
EXX
Before RET to BASIC
http://www.wearmouth.demon.co.uk/zx81.htm#L0028
Call to MC uses FP-calc which need the value of HL' on return.
So
EXX
PUSH HL
before running code
And on end
POP HL
EXX
Before RET to BASIC
http://www.wearmouth.demon.co.uk/zx81.htm#L0028
Re: ZX81, Alternate Register Pair HL' Used By System?
Ah okay, that makes sense. It's just a normal RAND USR 16514 type thing, but I guess that decoding the address from the program line uses the FP calculator.
I won't be using BASIC in the finished program, but it's quite handy to have it working for testing
I won't be using BASIC in the finished program, but it's quite handy to have it working for testing
Re: ZX81, Alternate Register Pair HL' Used By System?
Normally you can use all registers with EXX freely in your programs as well as long as you do not use specific ROM code.
If you want to program a driver cooperating with the rest you should avoid these double registers.
But when the control goes back from your routine to BASIC (asm code is finished) it is no problem to use the EXX registers.
But you can not assume that your registers are saved when calling your code in a kind of BASIC loop.
If you want to program a driver cooperating with the rest you should avoid these double registers.
But when the control goes back from your routine to BASIC (asm code is finished) it is no problem to use the EXX registers.
But you can not assume that your registers are saved when calling your code in a kind of BASIC loop.
Re: ZX81, Alternate Register Pair HL' Used By System?
Strange, I'm not doing any calls to ROM. Still, it crashes if HL' is changed. It appears to be okay to use BC' though. So far
Re: ZX81, Alternate Register Pair HL' Used By System?
You can use all the registers except iy, ix, af'
Are you sure your not corrupting the stack?
Regards andy
Are you sure your not corrupting the stack?
Regards andy
what's that Smell.... smells like fresh flux and solder fumes...
-
- Posts: 74
- Joined: Thu Apr 23, 2020 6:02 am
Re: ZX81, Alternate Register Pair HL' Used By System?
HL' is used by the FP calculator when machine code is launched using USR in BASIC. So you need to do what dr beep says and save-and-restore it.
John
Re: ZX81, Alternate Register Pair HL' Used By System?
Wow.... a 2015 thread revived!stroebeljc wrote: ↑Thu Mar 07, 2024 6:04 pm HL' is used by the FP calculator when machine code is launched using USR in BASIC. So you need to do what dr beep says and save-and-restore it.
Well if it helps anyone, why not!
-
- Posts: 74
- Joined: Thu Apr 23, 2020 6:02 am
Re: ZX81, Alternate Register Pair HL' Used By System?
I think it interesting that this detail is conspicuously missing from the ZX81 User Manual, especially when it addresses which registers not to mess with. It doesn't seem like such a minor detail to me.
John
Re: ZX81, Alternate Register Pair HL' Used By System?
The manual also doesn't mention the use of IX or A' which you can only use in a special way.stroebeljc wrote: ↑Thu Mar 07, 2024 8:28 pm I think it interesting that this detail is conspicuously missing from the ZX81 User Manual, especially when it addresses which registers not to mess with. It doesn't seem like such a minor detail to me.
IX to activate your own hires or intruptroutine and A' only to delay screenupdates when you initialize data and you need a very small stack ( use it in my code).