ZX81 BASIC, _hide
Posted: Sun Feb 03, 2013 10:07 pm
So the last directive for now is _hide.
With hide you can hide a line or a full program or numeric parameters. The classic variant is the use with a REM line:
If you check the listing, there is simply a NEWLINE $FF used as the first REM parameters.
So the disadvantage is the additional offset of 2 bytes if you use RAND USR with a line number (RAND USR #10#). This could be avoided with definition of explicit labels. Maybe in a future release this will be handled more efficient. If you enter LIST, the listing will be stopped after the first line (10 REM ...). Anyway the unreadable REM assembler content will be stopped to display and with _noedit it can not be touched any more. This can be bypassed with another line number and LIST, for example LIST 11 for list of the rest of the program.
Optical nicer is to use the code for REM in the last BASIC line because the code start address will be determined anyway automatically. Here the concept of no explicit use of line numbers is an advantage to move BASIC lines simply in the editor.
With _hide you can hide more elements, for example any numeric value. So the display of the starting address of any assembly code can be manipulated. Background is the double use of a numeric value and a string to display with a numeric value.
If you dismantle the second statement you will find:
2 byte line number big endian ($14=20)
2 byte line length little endian ($0A=10)
1 byte BASIC command RAND ($F9)
1 byte BASIC function USR ($D4)
1 byte string ($1C='0')
1 integer identifier ($7E)
5 byte integer ($8F,$01,$70,$00,$00 = 16572)
1 byte end character (NEWLINE) ($76)
This will look live like this:
So this was part 1 of ZX BASIC.
With hide you can hide a line or a full program or numeric parameters. The classic variant is the use with a REM line:
Code: Select all
REM _hide _asm
printch:
LD A,,'Z'
RST $10
LD A,,'X'
RST $10
LD A,,'8'
RST $10
LD A,,'1'
RST $10
RET
error:
RST 8
db $0A
END _asm
RAND USR #error
AUTORUN:
RAND USR #printch
Code: Select all
0074: [407D] 00 0A 13 00 EA 76 FF REM _hide _asm
printch:
007B: [4084] 3E 3F LD A,,'Z'
007D: [4086] D7 RST $10
007E: [4087] 3E 3D LD A,,'X'
0080: [4089] D7 RST $10
0081: [408A] 3E 24 LD A,,'8'
0083: [408C] D7 RST $10
0084: [408D] 3E 1D LD A,,'1'
0086: [408F] D7 RST $10
0087: [4090] C9 RET
error:
0088: [4091] CF RST 8
0089: [4092] 0A db $0A
008A: [4093] 76 END _asm
008B: [4094] 00 14 0E 00 F9 D4 1D 22 RAND USR #error
21 1E 25 7E 8F 01 22 00
00 76
AUTORUN:
009D: [40A6] 00 1E 0E 00 F9 D4 1D 22 RAND USR #printch
21 1D 22 7E 8F 01 08 00
00 76
Optical nicer is to use the code for REM in the last BASIC line because the code start address will be determined anyway automatically. Here the concept of no explicit use of line numbers is an advantage to move BASIC lines simply in the editor.
Code: Select all
RAND USR #error
AUTORUN:
RAND USR #printch
REM '(C) by PokeMon'
REM _hide _asm
printch:
LD A,,'Z'
RST $10
LD A,,'X'
RST $10
LD A,,'8'
RST $10
LD A,,'1'
RST $10
RET
error:
RST 8
db $0A
END _asm
Code: Select all
RAND USR #error
AUTORUN:
RAND USR _hide #printch
Code: Select all
0074: [407D] 00 0A 0E 00 F9 D4 1D 22 RAND USR #error
21 24 1D 7E 8F 01 8A 00
00 76
AUTORUN:
0086: [408F] 00 14 0A 00 F9 D4 1C 7E RAND USR _hide #printch
8F 01 70 00 00 76
2 byte line number big endian ($14=20)
2 byte line length little endian ($0A=10)
1 byte BASIC command RAND ($F9)
1 byte BASIC function USR ($D4)
1 byte string ($1C='0')
1 integer identifier ($7E)
5 byte integer ($8F,$01,$70,$00,$00 = 16572)
1 byte end character (NEWLINE) ($76)
This will look live like this:
So this was part 1 of ZX BASIC.