Drop the PRINT instruction on ZX80

Discussion about ZX80 / ZX81 Software
Post Reply
zx-heinz
Posts: 23
Joined: Thu Apr 27, 2017 8:56 pm

Drop the PRINT instruction on ZX80

Post 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?
dr beep
Posts: 1422
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Drop the PRINT instruction on ZX80

Post by dr beep »

LET A=USR 30000

or

PRINT “” AND USR 30000;
User avatar
1024MAK
Posts: 3469
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Drop the PRINT instruction on ZX80

Post 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
zx-heinz
Posts: 23
Joined: Thu Apr 27, 2017 8:56 pm

Re: Drop the PRINT instruction on ZX80

Post 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.
dr beep
Posts: 1422
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Drop the PRINT instruction on ZX80

Post 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.
User avatar
1024MAK
Posts: 3469
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Drop the PRINT instruction on ZX80

Post 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
sboisvert
Posts: 20
Joined: Mon Nov 02, 2009 3:43 pm

Re: Drop the PRINT instruction on ZX80

Post 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.
sboisvert
Posts: 20
Joined: Mon Nov 02, 2009 3:43 pm

Re: Drop the PRINT instruction on ZX80

Post 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.
zx-heinz
Posts: 23
Joined: Thu Apr 27, 2017 8:56 pm

Re: Drop the PRINT instruction on ZX80

Post 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
Post Reply