CPCWiki forum

General Category => Programming => Topic started by: Shining on 14:32, 19 July 13

Title: Stuck with RUN Basic- program from ASM
Post by: Shining on 14:32, 19 July 13
Hello all, my introduction in "off-topic" will follow later cause I first want to fix this damn problem  ;) :

I'm fixing some old code of mine but I'm a little bit stuck:

I need to load and run a Basic- Program out of ASM.

When I load the program using cas_in_open, cas_in_direct and cas_in_close and then return to BASIC I can "run" the program.

Is there a way to jump to the basic-program after cas_in_close ? I tried to jump to &EA78 ( RUN on 6128 ) with no success.

Or is there perhaps another, better solution ?


Title: Re: Stuck with RUN Basic- program from ASM
Post by: HAL6128 on 16:43, 19 July 13
I think it's complex situation running running BASIC programs out of ASM. It depends how the BASIC program is initialized because of different variables  and enviroment settings (e.g. symbol after xx will change RAM limits after initializing and those settings will be stored / located in different places in RAM depending on it's boundaries). It's not trivial. Just poke the RAM from &170 to the end with tokens won't help the program run. But I don't know what is needed more to get a BASIC program run. Maybe poke some more right RAM settings after &A6FC?
Title: Re: Stuck with RUN Basic- program from ASM
Post by: arnoldemu on 17:25, 19 July 13
I have some code that will do this. I will find it for you.

A easier idea would be to have the basic program from the start. Call your binary code. And let this return back to basic. Then basic takes over again and calls your program again when it's done?

Your code could return a code to tell basic what to do.

Could you do this instead?

It would be more compatible this way.
Title: Re: Stuck with RUN Basic- program from ASM
Post by: Urusergi on 17:22, 20 July 13
Quote from: Shining on 14:32, 19 July 13
Is there a way to jump to the basic-program after cas_in_close ? I tried to jump to &EA78 ( RUN on 6128 ) with no success.

Hello! 8)

I think this code should do the job (only CPC6128, of course):

CALL &B900
LD HL,KB_ASC
JP &C0B4
KB_ASC DB &52,&55,&4E,&0D


Saludos!
Title: Re: Stuck with RUN Basic- program from ASM
Post by: arnoldemu on 13:05, 22 July 13
;; length is the length of your program in bytes


ld hl,(length)
ld bc,&170
add hl,bc
ld c,0
call kl_rom_select
ld a,(&c002)
cp 0
jp z,cpc464
ld (&ae66),hl
ld (&ae68),hl
ld (&ae6a),hl
ld (&ae6c),hl
cp 1
jp z,cpc664
jp &ea78        ;; run BASIC CPC6128
.cpc664
jp &ea7d        ;; run BASIC CPC664
.cpc464
ld (&ae83),hl
ld (&ae85),hl
ld (&ae87),hl
ld (&ae89),hl
jp &e9bd        ;; run BASIC CPC464
.length
defw 0

Title: Re: Stuck with RUN Basic- program from ASM
Post by: HAL6128 on 13:21, 22 July 13
...hey, it works!!
Very interesting.
(Thanks also from my side although I hadn't post the topic. ;D )
Title: Re: Stuck with RUN Basic- program from ASM
Post by: arnoldemu on 13:24, 22 July 13
Where the code says "CPC6128" this *should* also work for Plus.
But I didn't test this.
Powered by SMFPacks Menu Editor Mod