garrylancaster (stranger
)
2002/05/30 00:44
|
EXE program questions
|
| |
I'm about to start porting a version of ANS Forth to the Sprinter, and I have a few questions ;-)
1. What memory segments are available for use by EXE programs? I see that normally DSS/BIOS is at $0000-$3fff, and the EXE loads at $8000. What is at $4000-$7fff?
2. Can the DSS/BIOS be paged out and replaced with RAM at $000-$3fff? Do interrupts need to be disabled if doing this?
3. Is it recommended to use the text I/O functions in DSS or the BIOS?
4. When exiting the EXE with BC=$0041/RST $18, does execution continue after the RST $18 (in other words, is it necessary to have the following RET?)
Thanks,
Garry
--
Garry Lancaster
http://www.z88forever.org.uk/zxplus3e/
http://www.z88forever.org.uk/
|
Denis Parinov (Sprinter Team)
2002/05/31 05:33
|
|
> 1. What memory segments are available for use by EXE programs? I see that normally DSS/BIOS is at $0000-$3fff, and the EXE loads at $8000. What is at $4000-$7fff?
Yes, the first segment ($0000-$3FFF) used for DSS or BIOS, when you call it or interrupts coming.
The next segments ($4000-$7FFF, $8000-$BFFF, $C000-$FFFF) are available for use EXE program.
But it has some features:
The system will build EXE prefix at the address (start address - $100). Therefore you can't use the address of loading less than $4100.
The system will allocates and set memory only that need to load your program. I.e. if a program loads to $4100 and it has length 10K, system allocates one page (16K) and set it to $4000-$7FFF segment. In the next segments will set page number $FF. If a program has length 20K, system allocates two pages (32K) and set it to $4000-$7FFF $8000-$BFFF segments, the last segment set to $FF.
About 'loads at $8000'. We recommended to use $8100 as start address for the program and $BFFF as STACK address. If your programm are small than $4000(16K). It will help to avoid mistakes in the first programm. But it's not system requirement.
> 2. Can the DSS/BIOS be paged out and replaced with RAM at $0000-$3fff? Do interrupts need to be disabled if doing this?
Yes, it can.
Replace
DI ; disable interrupts
IN A,($82) ; get page which set $0000-$3FFFF
LD (DSSPAGE),A ; store dss page number
LD A,your_page ;
OUT ($82),A ; replace it with your page.
Restore
LD A,(DSSPAGE) ; restore dss page number
OUT ($82),A ; back dss page
EI ; enable interrupts
> 3. Is it recommended to use the text I/O functions in DSS or the BIOS?
We recommended to use DSS I/O functions for console messages with control codes like TB, CR, LF etc. And BIOS I/O functions for text windows output or for lowlevel screen operations.
> 4. When exiting the EXE with BC=$0041/RST $10, does execution continue after the RST $10 (in other words, is it necessary to have the following RET?)
It's not necessary today, but we recommend to have RET at the end of program. If the system can't terminate a program for any reasons, then RET will try terminate it with fault.
|
garrylancaster (stranger
)
2002/05/31 15:38
|
|
Thanks for your replies - very informative. I'm sure the memory allocation would have caught me out if you hadn't explained it!
Are there any issues with disabling interrupts for a long period of time (are they used to read the keyboard or something, for example)? I was considering paging out DSS/BIOS all the time (except when needing to call it) so I can use the whole 64K address space.
Thanks,
Garry
--
Garry Lancaster
http://www.z88forever.org.uk/zxplus3e/
http://www.z88forever.org.uk/
|
Denis Parinov (Sprinter Team)
2002/06/01 03:35
|
|
> Thanks for your replies - very informative. I'm sure the memory allocation would have caught me out if you hadn't explained it!
Thank you for your question. It help us for more and best description of Sprinter's features.
> Are there any issues with disabling interrupts for a long period of time (are they used to read the keyboard or something, for example)? I was considering paging out DSS/BIOS all the time (except when needing to call it) so I can use the whole 64K address space.
If you don't want to lose data from keyboard or mouse, you have to write interrupt handler at $0038 address.
Like this:
$0038
CALL DSS_INT ;that placed at $4000 or more
EI
RETI
...
...
$4000
...
DSS_INT
PUSH AF
LD A, (DSS_PAGE)
OUT ($82),A
CALL $0038
DI
LD A,(YOUR_PAGE)
OUT ($82),A
POP AF
RET
If you can't place DSS_INT at $4000, then you may add routine, that will save data from $4000 segment to $0000 segment and move DSS_INT there. Also it can be put in STACK frame.
|
|