www.retrosoftware.co.uk
http://www.retrosoftware.co.uk/forum/

Calling basic from Asssembler
http://www.retrosoftware.co.uk/forum/viewtopic.php?f=73&t=648
Page 1 of 1

Author:  PitfallJ [ Thu Jul 14, 2011 4:27 pm ]
Post subject:  Calling basic from Asssembler

I have a program that a mixture of assembler and basic.
I load it in and relocate it in assembler (from a *RUN command from disc)
but then I want to run the basic part of it

To do that I think I want to perform these commands:

PAGE=&2E00:OLD:RUN

How do I do that from assembler?

OSCLI only works for * Commands I think.

- PJ

Author:  RichTW [ Thu Jul 14, 2011 6:37 pm ]
Post subject:  Re: Calling basic from Asssembler

You can do it by inserting the characters into the keyboard buffer, and then returning back to BASIC. (You can also do it by programming a soft key with *KEY, and then inserting just that into the keyboard buffer, but this won't work if you have something valuable between &B00 and &BFF).

Here's an example:
Code:
\ insert command into keyboard buffer, character by character
LDX #0
.insertloop
TXA
PHA
LDA #138
LDY command,X
LDX #0
JSR &FFF4
PLA
TAX
INX
CPX #commandend-command
BNE insertloop

\ turn off VDU output (otherwise you'll see the commands being 'typed' into the keyboard buffer)
LDA #21
JSR &FFEE

\ enter BASIC
\ note: if the machine code was definitely called from BASIC, you can just put an RTS instead
LDX #basic MOD 256
LDY #basic DIV 256
JMP &FFF7

.command
\ abbreviated as much as possible, to avoid filling up the keyboard buffer
EQUS "PA.=&2E00"
EQUB 13
EQUS "O."
EQUB 13
EQUS "RUN"
EQUB 6    \ reenable VDU output just before 'pressing' RETURN
EQUB 13
.commandend

.basic
EQUS "BASIC"
EQUB 13

Untested, but should do the trick!

Author:  PitfallJ [ Thu Jul 14, 2011 8:37 pm ]
Post subject:  Re: Calling basic from Asssembler

Thanks!
Worked first time!!

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/