# Change Slot/RAM direct for BASIC

Hi, I tried to change slots:
however the ram is always the same in slot 3-0.
the new ram is in slot 2-0 as if it were a RAM cartridge.
Here below displays the status of the current slot under BASIC

```10 rem slot 3-0 in RAM : 2Mb
20 rem slot 2-0 in RAM : 256kb
30 a=inp(&Ha8):b=256-peek(&HFFF)
40 A\$=right\$("00000000"+bin\$(a),8)
50 B\$=right\$("00000000"+bin\$(b),8)
60 print A\$:print B\$
70 for j=3 to 0 step-1
80 print val("&B"+mid\$(A\$,1+j*2,2));"-";
90 print val("&B"+mid\$(B\$,1+j*2,2))
100 next
110 print (257-inp(&hfe))*16;"Kb"
120 end
```

And finally edit the A and B values for the new slot:

```130 q=2:w=0
140 mid\$(A\$,1+1+1*2,2)=right\$("00"+bin\$(q),2)
150 mid\$(B\$,1+1+1*2,2)=right\$("00"+bin\$(w),2)
160 print A\$:print B\$
170 out &Ha8,val("&B"+A\$)
180 poke &HFFFF,val("&B"+B\$)
190 end
```

Result:
goto 10
before: 3-0
goto 130
after: 3-0
It does not change anything...

In this case, I tried restarting by pressing SHIFT and rewriting the program.
But the result is always the same.

Therefore in BASIC it remains in slot 3-0 (or 3-2) but the programs work when they are running in ROM or COM.
In basic it is possible to use DEFUSR.
I do not think that in BASIC it remains only in the current slot. Can someone explain?
Thank you.
Danysoft

By the way, remove line 120.
This will examine the BASIC listing.

the poke to FFFF only works in primary slot of sysarea. cannot do subslot anywhere else. no chance in BASIC.
make a little USR calling bios ENASLT.
your only chance is change page 2, &h8000 to another slot
so BASIC must be moved up to &hc000. with a poke to &hf677.

hi hit9918,
but in my opinion, after setting OUT and POKE with the new slot.
I tried to write poke & H8000.2 and then restore slots
Finally I wrote: PEEK (& H8000) but it's still the number 2!

I have already put two CALLs with my project written in ASM.
CALL SLOT (primary, secondary) and CALL READSLOT.

unfortunately it always gives me the same number and I suspect the ram slot for the BASIC
it remained there by default.

Only USR, ROM or RAM as program can change slots and run the program with JP .

DanySoft

As far as I recall there is no way to use the RAM in other slots using basic. You could try using a RAMDISK then calling one basic program from another? Did you want to use it for data or program storage? For data you could use RDSLT and WRSLT routines? Which MSX version do you have? do you have a disk drive? IDE device?

hi djh1697,
See this example on running MSX-BASIC:
Slot 3-2: 64Kb
Slot 2-0: 512Kb (cartridge expansion RAM)

page 3:C000-FFFF slot 3-2 \
page 2:8000-BFFF slot 3-2 \__ Only 64kb
page 1:4000-7FFF slot 3-2 /
page 0:0000-3FFF slot 3-2 /

change with this:
page 3:C000-FFFF slot 3-2
page 2:8000-BFFF slot 2-0 <--- extra ram: 256kb
page 1:4000-7FFF slot 3-2
page 0:0000-3FFF slot 3-2

True or false this example ?
Bye bye.
DanySoft

hi,
I examined the problem of slot with WBASS2 (debug/monitor) on emulator msx:
slot 3-0 (64k)
slot 2-0 (512k)
page 3,3,0,3 (slot 3-0 64Kb)
page 2,3,0,2 (slot 3-0 64Kb)
page 1,3,0,1 (slot 3-0 64Kb)
page 0,3,0,0 (slot 3-0 64Kb)

Write the page 2 with slot 2-0:
page 3,3,0,3 (slot 3-0 64Kb)
page 2,2,0,2 (slot 2-0 512Kb)
page 1,3,0,1 (slot 3-0 64Kb)
page 0,3,0,0 (slot 3-0 64Kb)

Ok, this is valid for code in asm without MSX-BASIC.
But ....
MSX-BASIC it not change other slot !
DanySoft

No one answers? Well ... The fact is that you can not write one quietly
16K page from the 2-0 slot instead of the 3-2 RAM slot.
However I will use the BIOS subroutine 0014h to write to the RAM of the selected slot.
Alternatively, I will use vram as RAM, it is used for free space for the text editor, therefore BASIC type with codes not in line numbers but with label.
Look under:
0-16384: reserved for screen 1/2 (MSX1)
16384-131072 Free space for the new Basic.

I have already written on our forum the post "function to asm":
Function to Asm

I will use vram to write the new basic code. Then it converts to ASM.
After the program is saved to file and compiled with GEN80 from MSX-DOS.
DanySoft :)

My MSX profile