Page 1 of 1

Drop the PRINT instruction on ZX80

Posted: Sat Oct 31, 2020 6:28 pm
by zx-heinz
I have a question concerning MC on ZX80. Suppose, I have poked a RET ($C9) at address 30000. The command PRINT USR(30000) will come back with 30000. But I want to surpress the printing. How can I drop the PRINT instruction from the stack?
Is there good textbook for MC programming on ZX80?

Re: Drop the PRINT instruction on ZX80

Posted: Sat Oct 31, 2020 8:47 pm
by dr beep
LET A=USR 30000

or

PRINT “” AND USR 30000;

Re: Drop the PRINT instruction on ZX80

Posted: Sat Oct 31, 2020 9:15 pm
by 1024MAK
Mastering Machine Code on Your ZX81 by Toni Baker which also covers the ZX80 (where it’s often referred to as the ‘old ROM’, in the context of the book, ‘new ROM’ means the ZX81 ROM).

Mark

Re: Drop the PRINT instruction on ZX80

Posted: Sun Nov 01, 2020 11:58 am
by zx-heinz
dr beep wrote: Sat Oct 31, 2020 8:47 pm LET A=USR 30000
or
PRINT “” AND USR 30000;
This doesn't solve my problem really. First point is that ( "" AND USR 30000) is not an admissible expression. The first term is a string, the second a number, and AND is expecting numbers. But I want to go more in the details:
The command under discussion should be used to call a USB driver for the ZX80. The structure of the command is as follows:
PRINT USR(MC-address), "X" <CR>
where X is some letter which is read by the MC program first and is used for branching inside of the MC program. The problem is a right jump at the end of the MC back to BASIC without additional printings or error messages. Including cleaning the stack. This is not as hard for the ZX81, but I was not successfully for the ZX80. Are there available any samples for similiar situations?

Or an example solving my problem accurate? Let me formulate the task:
I would like to have an MC-program for the ZX80 doing the following: The command PRINT USR(MC-address),"X" <CR> should print out just the given letter X, nothing else.

Re: Drop the PRINT instruction on ZX80

Posted: Sun Nov 01, 2020 2:55 pm
by dr beep
The command makes sense, the result of the printing is only displayed when the boolean result from the USR call is true, which it is when BC >0.

However the PRINT itself wil print nothing even when BC >0, the ; will keep the cursor on the same line and not to the next line.

Your problem is different than what you asked. You need to drop the RET to the printing on the stack.
On the ZX Spectrum you get that by increasing the SP with 14, don’t know by heart how much you need on a ZX80.

After that you need scanning or GET CHAR RST routine to read your data.

Re: Drop the PRINT instruction on ZX80

Posted: Sun Nov 01, 2020 4:07 pm
by 1024MAK
zx-heinz wrote: Sun Nov 01, 2020 11:58 am
dr beep wrote: Sat Oct 31, 2020 8:47 pm PRINT “” AND USR 30000;
This doesn't solve my problem really. First point is that ( "" AND USR 30000) is not an admissible expression. The first term is a string, the second a number, and AND is expecting numbers.
dr beep wrote: Sat Oct 31, 2020 8:47 pm PRINT “” AND USR 30000;
To be fair, this is valid on a ZX81. But as you have found out, the syntax checker does not allow it on a ZX80.

Mark

Re: Drop the PRINT instruction on ZX80

Posted: Tue Nov 03, 2020 12:44 am
by sboisvert
zx-heinz wrote: Sat Oct 31, 2020 6:28 pm The command PRINT USR(30000) will come back with 30000. But I want to surpress the printing. How can I drop the PRINT instruction from the stack?
Is there good textbook for MC programming on ZX80?
Do you absolutely need to use PRINT? Couldn't you do RAND USR 30000?

I see now from your other post what you're trying to do; I know it's possible (for example SHREB does this, but using REM and LPRINT instead I believe), but don't know the technique. It would basically be a parser that then 'skips' to the end of the line for what to execute next/return to the initiating instruction.

Re: Drop the PRINT instruction on ZX80

Posted: Tue Nov 03, 2020 12:55 am
by sboisvert
From what I remember seeing SHREB doing, it's usually formulated like:

Code: Select all

IF USR MC-ADDR THEN REM <stuff to parse or execute by MC routine>
My guess is that the MC function then returns 0, meaning the THEN part never gets executed (which in this case it wouldn't, being a REM, but other tokens could be used to mean other things, like LPRINT). This would be the simplest way to 'suppress' any action from the MC call returning anything to BASIC.

Re: Drop the PRINT instruction on ZX80

Posted: Tue Nov 03, 2020 11:46 am
by zx-heinz
dr beep wrote: Sun Nov 01, 2020 2:55 pm The command makes sense, the result of the printing is only displayed when the boolean result from the USR call is true, which it is when BC >0.

However the PRINT itself wil print nothing even when BC >0, the ; will keep the cursor on the same line and not to the next line.

Your problem is different than what you asked. You need to drop the RET to the printing on the stack.
On the ZX Spectrum you get that by increasing the SP with 14, don’t know by heart how much you need on a ZX80.

After that you need scanning or GET CHAR RST routine to read your data.
It seems so that the problem is solved now. The "magic" number for the ZX80 could be 8. For details see the assembler instruction at:https://forum.tlienhard.com/phpBB3/view ... 512#p46512