Hi folks.
In my cpctelera/SDCC line drawing program, I'm now at the stage of optimisations in asm.
I'm starting to use the alternate (EXX) instructions a lot.
Now, as I've got the firmware disabled (as recommended when using cpctelera), I'm wondering if I need to use DI/EI around EXX blocks.
I don't have DI/EI around any of my EXX blocks (even when using BC) and so far I'm not having any problems.
Is it safe to ignore DI/EI when the firmware is disabled?
Quote from: ervin on 01:37, 17 August 16
Hi folks.
In my cpctelera/SDCC line drawing program, I'm now at the stage of optimisations in asm.
I'm starting to use the alternate (EXX) instructions a lot.
Now, as I've got the firmware disabled (as recommended when using cpctelera), I'm wondering if I need to use DI/EI around EXX blocks.
I think so, though I could be wrong, the Alternative Register set are used in the inner workings (OS I think) of the computer. I read somewhere in another post that if it was in CP/M, you wouldn't need to Enable Disable Interrupts for the Alternative Register Set (CP/M doesn't use them being the reason).
QuoteI don't have DI/EI around any of my EXX blocks (even when using BC) and so far I'm not having any problems.
Is it safe to ignore DI/EI when the firmware is disabled?
I know you can't use DI/EI when using the Firmware, I only really ever used DI when moving chunks of code from the Screen Memory to where AMSDOS/the Firmware Resided.
Quote from: AMSDOS on 01:57, 17 August 16
I think so, though I could be wrong, the Alternative Register set are used in the inner workings (OS I think) of the computer. I read somewhere in another post that if it was in CP/M, you wouldn't need to Enable Disable Interrupts for the Alternative Register Set (CP/M doesn't use them being the reason).
I know you can't use DI/EI when using the Firmware, I only really ever used DI when moving chunks of code from the Screen Memory to where AMSDOS/the Firmware Resided.
Hmmm, interesting.
Thanks man.
It certainly seems to be ok with the firmware disabled.
I know that I *had* to use DI/EI when I was writing Chunky Pixel Curator in ccz80.
I had the firmware enabled in that program, and if I didn't use DI/EI, the program would crash instantly (that program had a lot of EXX register usage).
I found this PDF document (https://www.google.com.au/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwiph9PApMfOAhUDn5QKHZLdBGwQFggdMAA&url=http%3A%2F%2Fcpctech.cpc-live.com%2Fdocs%2Fmanual%2Fs968ap11.pdf&usg=AFQjCNE0WlfdNtXpwOJ-4TBwgmHmichVcw) on the CPCTech site, which might help explain where you can use the Alternative Register Set and what Alternative Registers are used, the Firmware does get a lot of mentions in it, so perhaps with the Firmware out of play, you're in the clear to use them?
Quote from: AMSDOS on 02:25, 17 August 16
I found this PDF document (https://www.google.com.au/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwiph9PApMfOAhUDn5QKHZLdBGwQFggdMAA&url=http%3A%2F%2Fcpctech.cpc-live.com%2Fdocs%2Fmanual%2Fs968ap11.pdf&usg=AFQjCNE0WlfdNtXpwOJ-4TBwgmHmichVcw) on the CPCTech site, which might help explain where you can use the Alternative Register Set and what Alternative Registers are used, the Firmware does get a lot of mentions in it, so perhaps with the Firmware out of play, you're in the clear to use them?
That's fantastic!
Thanks!
If you're not using the firmware, where does the interrupt vector go in CPCtelera? If CPCtelera has an interrupt routine that uses the alternate registers you might be in trouble. That said, if you disable interrupts at the start of your routine and enable them at the end you won't need to do it separately when using the registers, but if the routine takes some time you'll upset interrupts if anyone is using them for anything.
Quote from: Executioner on 03:41, 17 August 16
If you're not using the firmware, where does the interrupt vector go in CPCtelera? If CPCtelera has an interrupt routine that uses the alternate registers you might be in trouble. That said, if you disable interrupts at the start of your routine and enable them at the end you won't need to do it separately when using the registers, but if the routine takes some time you'll upset interrupts if anyone is using them for anything.
Thanks Richard.
I actually don't know where the interrupt vector goes.
@ronaldo (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1227) can you help?
@ervin (http://www.cpcwiki.eu/forum/index.php?action=profile;u=82) CPCtelera (http://lronaldo.github.io/cpctelera) does nothing by itself: it's just a building system + a low-level library. Anything is done when you call functions of the low-level library, and anything a function does is detailed in the documentation.
With respect to interruptions, when you call cpct_disableFirmware(), the function writes a EI:RET in the interrupt vector (0038h). From then on, every time an interrupt happens, it only returns leaving interrupts enabled. Then, no other code than your code is executed. This is the reason why you can safely change any register. If you do not disable firmware, firmware code is called on every interrupt. Firmware code modifies the alternate register set, which surely will destroy your working values.
If you create your own interrupt handler, you have to take into account all this things: cpct_setInterruptHandler() creates a wrapper that automatically saves and restores standard registers, but not the alternate set. If you use them in your interrupt handling code, you have to take care by yourself.
I've looked into the cpctelera source:
When you disable firmware by using the cpctelera-function cpct_disableFirmware, cpctelera installs only a RET-instruction there.
So every interrupt, only a RET will be processed and no register in any of the two sets is altered.
Edit: Oh, ronaldo was faster :D .
Thanks @ronaldo (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1227) and @Shining (http://www.cpcwiki.eu/forum/index.php?action=profile;u=922) , that's really useful information.
Ronaldo probably means &0038, not 39. However one thing is needed to mention. If you switch on the lower ROM (f.e. to access character set), then the interrupt handler of the ROM will be used... and Crash!
Quote from: TFM on 17:47, 17 August 16
Ronaldo probably means &0038, not 39. However one thing is needed to mention. If you switch on the lower ROM (f.e. to access character set), then the interrupt handler of the ROM will be used... and Crash!
Yes, but either you shouldn't switch the lower ROM on, or if you do, you need to patch the vector also at #B9xx or alternatively switch to interrupt mode 2 and use a table in RAM. The way I normally do it (which may be better for CPCtelera disable firmware) is:
ld hl,(#39)
ld (hl),#fb ;; EI
inc hl
ld (hl),#c9 ;; RET
This may not be a good idea if the compiler actually generates code at #B9xx and you're not using firmware at all, so maybe also patch #38 with EI:RET.
The original method is fine so long as whenever you use the lower ROM (not to call firmware routines) you disable interrupts first, then enable the ROM, then do whatever, disable the ROM and re-enable interrupts once the ROM is disabled again.
Thanks guys.
I'm not using the firmware at all, so it should be ok.
Quote from: TFM on 17:47, 17 August 16
Ronaldo probably means &0038, not 39.
Yes, @TFM (http://www.cpcwiki.eu/forum/index.php?action=profile;u=179), completely right :). I wrote the post too fast and didn't notice it. Thanks for pointing it out. I'll fix it right now in the post :)
@ronaldo (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1227) : IMHO it's a great thing that CPCTelera can disable the firmware, so it serves a broader spectrum of development ideas. :)
@Executioner (http://www.cpcwiki.eu/forum/index.php?action=profile;u=17) : Yes, IM 2 is the way to go. Also makes things more easy when using PlayCity f.e. :)