Page 1 of 1

[ASM] How to Print 32 characters...

Posted: Tue May 04, 2021 4:07 am
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 133 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 131 times

Have fun...

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

Posted: Tue May 04, 2021 4:47 am
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$