News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_ervin

running interrupt code below #4000

Started by ervin, 05:14, 19 May 25

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ervin

Hi everyone.

I'm working on a little project using the ccz80 compiler, as that has many commands which align well with BASIC, and has excellent firmware support, but of course also runs magnitudes faster than BASIC.

Anyway, if I set up an interrupt with ccz80's EVERY command (equivalent to BASIC's EVERY command), it runs fine when the routine called by the interrupt is above #4000.

However, if the routine exists below #4000, and does something like a PRINT command, the PRINT command doesn't work.
(It works fine above #4000).

Now, the odd thing is that the PRINT command (when not run via interrupt) runs fine when it exists below #4000.

Is there some sort of interrupt/firmware clash with certain commands like PRINT?

Here is the ccz80 code.

include "cpc6128.ccz80";

array byte delayTimer_0[13];

every(5,PRINT_SOMETHING,delayTimer_0);

LOOP:
goto LOOP;

PRINT_SOMETHING:
prints("something");
return;

And here is the equivalent BASIC code.

10 every 5,0 gosub 100
20 goto 20
100 print "something";
110 return

ervin

Hmmm... I seem to have found the answer.
I remembered something about this being mentioned in cpctelera's documentation, and I found the specific case.

The cpct_drawString and cpct_drawChar commands mention this on their pages:

Do not put this function's code below 0x4000 in memory.  In order to read characters from ROM, this function enables Lower ROM (which is located 0x0000-0x3FFF), so CPU would read code from ROM instead of RAM in first bank, effectively shadowing this piece of code.  This would lead to undefined results (typically program would hang or crash).

Powered by SMFPacks Menu Editor Mod