Login
Back to forumReply to this topicGo to last reply

Posted By

Evx
on 2017-03-26
20:07:12
 "Ram under Rom"

Maybe I'm missing something, but I seem to have had no luck in finding information detailing the use of the ram at $8000 and up.

I was hoping I could load some ML routines there, while still being able to use basic.

Can anyone point me towards documentation or a summary of use? Thanks!

Posted By

JamesC
on 2017-03-26
22:11:43
 Re: "Ram under Rom"

Programmer's Reference Guide to the Commodore Plus/4, page 304:

SEI
STA $FF3F : turn on RAM over $8000
(do whatever is in RAM over $8000)
STA $FF3E : turn on ROM over $8000
CLI

Posted By

Csabo
on 2017-03-26
22:17:51
 Re: "Ram under Rom"

I think SYS above $8000 will always call the ROM. You can get around by using a small "wedge", which does what JamesC mentioned above. Here's a practical example:

0 DATA78,8D,3F,FF,20,00,80,8D,3E,FF,58,60
1 FORI=0TO11:READA$:POKE4072+I,DEC(A$):NEXTI
2 DATAA9,32,8D,19,FF,60
3 FORI=0TO5:READA$:POKEDEC("8000")+I,DEC(A$):NEXTI
4 SYS4072

It places a small routine to $8000 which simply turns the border red, then calls it from BASIC.

Posted By

SVS
on 2017-03-27
07:06:50
 Re: "Ram under Rom"

@Evx: of course you have to take care yourself of all the things normally managed by the IRQ routine (that is disabled by the SEI instruction). This means that you have to manage the keyboard and all I/O through your code.

Posted By

JamesD
on 2017-03-27
09:42:10
 Re: "Ram under Rom"

The previous replies have it covered, but if you need more hardware info in the future, here are a couple memory maps.

Here is a decent article on the Plus/4 memory map:
http://plus4world.powweb.com/plus4encyclopedia/500237

And a more recent one:
http://plus4world.powweb.com/tools/Ultimate_Map

Posted By

Mad
on 2017-04-23
18:44:48
 Re: "Ram under Rom"

What Csabo said.

Referring to the basic code above:

The datas place this code to $0fe8 (4072)
.C:0fe8 78 SEI
.C:0fe9 8D 3F FF STA $FF3F
.C:0fec 20 00 80 JSR $8000
.C:0fef 8D 3E FF STA $FF3E
.C:0ff2 58 CLI
.C:0ff3 60 RTS

and this code to $8000
.C:8000 A9 32 LDA #$32
.C:8002 8D 19 FF STA $FF19
.C:8005 60 RTS

The first code is used to disable the interrupts (SEI) and turn on RAM (sta $ff3f)
then the routine jumps to the routine at $8000 and changes the bordercolor.
The wedge then takes care of reenabling the ROM(sta $ff3e) and turns on the interrupts again(CLI).

Perhaps you should install this wedge ($0fe8) somewhere in a unused zeropage area or in a place which is not touched by the system and then exchange only the $8000 in the JSR instruction for your needs on the fly. You can call the same wedge routine (which is on a safe place), for all your basic SYS calls which should go into the ram under the rom.

edit: oh my, surely the place $0fe8 choosen by csabo is already sufficient for persistence. It will not be overwritten by anything systemwise. just for the record :).. Nice place for a very small routine :)..

Posted By

Evx
on 2017-03-27
17:58:20
 Re: "Ram under Rom"

Thanks for the clarification. This is an RS232 program I'm working with, am I playing with fire by disabling the interrupts ! ?

Posted By

JamesC
on 2017-03-27
18:55:53
 Re: "Ram under Rom"

Maybe. It depends how long your routines take to run, what other things the system should be doing at the time.

How much space under ROM do you need? Is it possible to put your routines in lower RAM ($1000 - $3FFF area) once the start of BASIC is moved up? This would save you a lot of worry about interrupts, as well as make your routines easier to call (no SYS worries or added bankswitching code).

Posted By

Evx
on 2017-03-27
19:15:42
 Re: "Ram under Rom"

SVS, I do see your comment about controlling the I/O. I will evaluate what the code does before placing it in the rom area. I'm excited to have learned about all this memory I can use! Though I am a bit sad that half the ram of this machine has this limitation, unless I am misunderstanding something...

Posted By

Evx
on 2017-03-27
19:24:52
 Re: "Ram under Rom"

James, I just need a space from $_000 to $_BEF. The lower area sounds like a better solution if my routines run too long for RX/TX (which I will assume they could). What are the details for using that lower area of memory? I have formed the assumption that programs that "RUN" from BASIC are within $4096-$7FFF, but I need to protect that area for normal BASIC program operation.

Posted By

JamesC
on 2017-03-27
20:21:27
 Re: "Ram under Rom"

@Evx - a quick boot program would change the start of BASIC, then load the main program using the Dynamic Keyboard technique. Something like this:

10 HI = DEC("1C") : REM New start of BASIC, $1C00/7168
20 print [Shift/Home] and LOAD"MAIN FILE",8,1 to the screen
30 print RUN to the screen
40 shove a couple CHR$(13)'s into the keyboard buffer
50 POKE44,HI : POKE HI*256,0 : NEW

For development purposes, POKE44,28:POKE7168,0:NEW before writing your main program (or reloading your partially written main program). This way your memory pointers line up when you LOAD,8,1 from the boot program.

EDIT TO ADD: BASIC programs can extend past $8000. The system knows how to handle them, allocate variable memory, etc. So don't worry about keeping your BASIC code below $7FFF. :)

Posted By

SVS
on 2017-03-28
08:21:57
 Re: "Ram under Rom"

Actually each byte read by the Basic interpreter from *any* memory address is managed as it was in the high RAM ($8000... area).
Maybe a direct reading from low RAM (...$7FFF) would had speeded a lot the Basic run. But this would have required an address test before each read operation.



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024