How to cleanly exit a BASIC program from assembly?

Por Louthrax

Prophet (2082)

Imagen del Louthrax

29-05-2016, 22:18

Let's say I have this BASIC program:

10 bload"foo.bin",r
20 other BASIC stuff...
30 ...

I'd like to cleanly exit the BASIC program from foo.bin if something bad happens inside. I can't do a PEEK() test after line 10 as RAM might be erased / corrupted after the bload"foo.bin",r.

Any idea ?

Login sesión o register para postear comentarios

Por flyguille

Prophet (3029)

Imagen del flyguille

29-05-2016, 22:36

when your assembly do RET, it will continue executing the BASIC listing.

Also is the peek technics, set from assembler a value to know everything go well, or wrong.

you can use cleanly the value $8000, <> 0 is error.

that address being non zero will prevent the basic listing to run again, but before ENDing the basic listing, you can poke that adress again to zero after the check.

Por Louthrax

Prophet (2082)

Imagen del Louthrax

29-05-2016, 22:46

Thanks flyguille, I'll try that. In case the bload ,r goes wrong, I'd like the BASIC program to be cleaned too, so that poke $8000,0 looks perfect!

Por flyguille

Prophet (3029)

Imagen del flyguille

29-05-2016, 23:26

well, it is poke &h8000,0 as BASIC rules.

Por NYYRIKKI

Enlighted (5384)

Imagen del NYYRIKKI

30-05-2016, 01:46

Louthrax wrote:

Let's say I have this BASIC program:

10 bload"foo.bin",r
20 other BASIC stuff...
30 ...

I'd like to cleanly exit the BASIC program from foo.bin if something bad happens inside. I can't do a PEEK() test after line 10 as RAM might be erased / corrupted after the bload"foo.bin",r.

Any idea ?

I would suggest that you see "ON ERROR GOTO"-command. In case you need to return different errors from FOO.BIN then you can use code like:

	LD	E,4 ; BASIC error number
	JP	#406F

By default in your case this would print "Out of DATA in 10". If you want to handle it correctly see also BASIC ERR and ERL variables.

... ok reading your question again... You may just want to jump to #409B (Exit BASIC program) or even to #7D17 (Erase program & restart BASIC)

Por Louthrax

Prophet (2082)

Imagen del Louthrax

30-05-2016, 03:07

Thanks Nyyrikki. #7D17 has the side-effect of erasing the screen (and I might have an error message displayed by my bloadable program). I used "ld e,19 & call #406F" which displays "Device I/O error", so I don't even have to print an error message Smile