[ASM] How to Print 32 characters...

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

[ASM] How to Print 32 characters...

Post by XavSnap »

Hi,

A little routine to repeat a character code and preserve some memory room.

Example:

Code: Select all

10 PRINT "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
20 PRINT 
30 PRINT "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
Take more memory room than…

Code: Select all

10 PRINT USR X;"X"
20 PRINT 
30 PRINT USR X;"X"
My code:

Code: Select all

.org 16514

	LD HL,($4016)
	INC HL
	INC HL
	LD B,$20
	LD C,$00
	LD A,(HL)
Loop:
	RST 10H
	DJNZ Loop
	INC HL
	INC HL
	LD ($4016),HL
	JP $005B
.end

Code: Select all

     1  REM [HEX:\
2A,16,40,23,23,06,20,0E,\
00,7E,D7,10,FD,23,23,22,\
16,40,C3,5B,00 ]
2 LET X=VAL "16514"
3 PRINT AT 10,0;
4 PRINT USR X;"\,,"
5 PRINT TAB 14;"HELLO",
6 PRINT USR X;"\''"
LINE.P
(1.01 KiB) Downloaded 127 times

Note:
-Affect the cursor location.

-Can't be use with RAND USR, it will be compiled with any TexttoP, but the line can't be edited with the basic editor.

-All values and characters after this ASM call are ignored !

- if the "C3,5B,00 " (JP $005B) is replaced by "C9" (Ret) can't be use… the PRINT command will display the BC value !
In this case, just use the TAB function, if the line start at the first row…

Example: (The RET value in always BC=0)

Code: Select all

     1  REM [HEX:\
2A,16,40,23,23,06,20,0E,\
00,7E,D7,10,FD,23,23,22,\
16,40,C9 ]
2 LET X=VAL "16514"
3 PRINT AT 10,0;
4 PRINT TAB USR X;"\,,";TAB 14;"HELLO",TAB USR X;"\''"
LINE2.P
(1021 Bytes) Downloaded 126 times

Have fun...
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: [ASM] How to Print 32 characters...

Post by XavSnap »

Another way to preserve memory, is to set a variable …

Code: Select all

10 LET P$="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
20 PRINT P$,,P$
But, this code keep a value in the Vars buffer, and is needed if it's use more than 3 times !
And use more memory if the repeat character code if different…

Code: Select all

10 LET P$="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" (also mirrored in the Var memory room, take 64 bytes!)
10 LET Q$="ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" (also mirrored in the Var memory room, take 64 bytes!)
20 PRINT P$,,Z$,,P$,,Z$
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Post Reply