Another issue with setting new command in BASIC

By Eugeny_Brychkov

Hero (589)

Eugeny_Brychkov's picture

13-12-2010, 14:06

I used H.GONE hook for that. It does RST30 to ROM. I check if command executing matches the one ROM needs to handle. I find the command, execute my code and...

problems start. I can not make BASIC to display "Ok". It always says "Syntax error".

I tried the following
- writing to the buffer where command is found (in HL) - it causes bad result
- skipping HL pointer to the end of my command (there're zeros in the buffer) - says "Syntax error" anyway.

It is not possible to alter stack (just do "pop" on the ret address, as it contains a lot of pushes and calls from CALLF and other subs.

Can anyone help with that? Any ideas? What should I return to basic not to get "Syntax error"?

Login or register to post comments

By Leo

Paragon (1236)

Leo's picture

13-12-2010, 14:51

Just in case :
Maybe some interesting information in :
http://msx.fi/nyyrikki/software.html

look for NSBASIC , and more specifically :
http://msx.fi/nyyrikki/files/nsbasic.lzh

I think i had read a complete tutorial on that topic somewhere else, i remember something like string must finish by chr(0) but maybe i dont remember very well

--edit---
also this link might help :http://www.konamiman.com/msx/lpe-z380/callpcm.lzh

In fact these lzh i cant open them since at my work my poor XPpro laptop does not handles them and i dont have admin rights ...

By Eugeny_Brychkov

Hero (589)

Eugeny_Brychkov's picture

13-12-2010, 14:55

Played with finishing with 0 etc with no success.
In this example, he does "inc sp; inc sp" but it seems not working for all the cases. For example, if you set those commands in program, or in long line with other commands following it (after ":" ) this may give Syntax error. It works if you issue this command standalone.

- edit -
it seems that when H.GONE is called and BASIC already expects that there's some command, you can not tell BASIC that there's nothing to do and it parses what in the buffer anyway. Zero (0) value in buffer is also being considered as Syntax error.
For example, if you just press ENTER (empty sting) H.GONE is not called at all.

By tcruise

Expert (124)

tcruise's picture

14-12-2010, 02:00

By Leo

Paragon (1236)

Leo's picture

14-12-2010, 06:25

it is more the chapter 3:
http://www.electricadventures.net/index.php/features/50-beyond-basic-part-3

ican see you do not put ":" after extended basic commands in the forewords , do you see it ?

By Eugeny_Brychkov

Hero (589)

Eugeny_Brychkov's picture

14-12-2010, 06:42

it is more the chapter 3:
http://www.electricadventures.net/index.php/features/50-beyond-basic-part-3

LD (HTIMI+1),A

;(
and does not call subs down the chain

it is more the chapter 3:
http://www.electricadventures.net/index.php/features/50-beyond-basic-part-3

CHECK CP “[“

:(

INC SP
INC SP

when you know what is in the stack!!

Well, both programs will not work if just copypasted :) Second will give compiler error, first will just hang or reboot

Anyway thanks for examples. It seems the only solution is identify what exactly in the stack and alter it removing unwanted return address.

By AuroraMSX

Paragon (1886)

AuroraMSX's picture

14-12-2010, 08:06

Just an idea:

Is H.GONE called before the interpreter starts parsing a new statement or when it's encountered some text that it cannot parse?
In the latter case, the interpreter probably already is in an error state and you need to switch it back to normal: check the system variables that hold the error line number and error code and set those back to 0. It may help

Oh, and if I recall correctly, at the end HL should point to the last byte of the text you parsed, so one byte before the text you want the normal interpreter to pick up again.

Santa

- EDIT - Ok, I had a few seconds to rtfm: H.GONE is called at the beginning, not when the parser encounters an error, so my first statement you can forget Running Naked in a Field of Flowers The second part though seems to be valid: HL must point to the last byte of the text you parsed, so the byte before the concluding '0' or ':'

My MSX profile