7Eh near end of REM

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
stroebeljc
Posts: 67
Joined: Thu Apr 23, 2020 6:02 am

7Eh near end of REM

Post by stroebeljc »

Forgive me if this has already been addressed, but I encountered a strange issue while trying to list my combo MC and BASIC program. The line after the REM (line 5 in my code) was either buried at the end of the REM or displayed with no line number (see picture), although the program ran correctly. When I tried to edit the REM line (line 0) with the BASIC editor, the ZX81 crashed.
Screenshot 2024-03-12 001027.png
Screenshot 2024-03-12 001027.png (8.65 KiB) Viewed 567 times
I discovered that the problem was including an LD A,(HL) instruction (7Eh) within 5 bytes of the Newline. The listing interpreter expects that a numeric always follows a 7Eh, even in a REM. So, either don't place this instruction or data that could be equal to 7Eh at the end of your code, or add enough bytes to the end of the REM to allow the Newline to be properly handled by the BASIC lister.
Screenshot 2024-03-12 001146.png
Screenshot 2024-03-12 001146.png (8.83 KiB) Viewed 567 times
John
dr beep
Posts: 2080
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: 7Eh near end of REM

Post by dr beep »

Why would you edit machinecode?

You should always place new versions of your code over the line, but better
code outside the ZX81 and built a .P from that.

In this way you can use much more of the RAM, like printerbuffer, sysvar and no loss of bytes for line nimbers and lengt or start of machinecode.
stroebeljc
Posts: 67
Joined: Thu Apr 23, 2020 6:02 am

Re: 7Eh near end of REM

Post by stroebeljc »

The point is the behavior of the BASIC lister. For small MC routines mixed with BASIC there may be lots of editing of lines after the REM. I also observed the crash at times when editing the BASIC line after REM. The behavior is undefined and care must be taken when working with mixed code.

I actually found this because I generated the program entirely using TASM and didn't observe a problem until I saw how it was listed.
John
stroebeljc
Posts: 67
Joined: Thu Apr 23, 2020 6:02 am

Re: 7Eh near end of REM

Post by stroebeljc »

I did find something on this topic in this ancient post.
John
sboisvert
Posts: 40
Joined: Mon Nov 02, 2009 3:43 pm

Re: 7Eh near end of REM

Post by sboisvert »

As you noted I observed this in that post you referenced.

Probably the best way to avoid this is to have a double 76h at the start of that 0 REM line, making the system omit displaying all the contents. You would still be able to list subsequent lines, with:

Code: Select all

LIST 5
in this case.
Post Reply