ASM "Data" Function on ZX81 : André's Basic codes are Faster

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
Post Reply
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

ASM "Data" Function on ZX81 : André's Basic codes are Faster

Post by XavSnap »

Hi,

I planed to Code an machine code Routine to Boost André's Basic codes.

Last might i coded this:

Code: Select all

;************************
;*      DATA READER     *
;*      BY ><AVSNAP     *
;************************
; ARTIC ASM II ON XUR
; IN ASM WINDOW.

@DFILE=+16396
@DFCC=+16398
@FAST=2D6
@FRAMES=+16436
@SEED=+16434
@SLOW=2BF
@CLS=A2A
@KEYLOW=+16421
@KEYHI=+16422

@VARS=+16400
@DEST=+16402

@NXTL= 4029

ORG +16514


;************************
; GO TO THIS ITEM
@IJMP   ; 16514
01 00 
@FILL   ; 16516
" "
; ITEM LENGHT
@ILNG   ; 16517
01 00

;SOURCE LENGHT
@ND
00 00   ; 16519

; THE STRING START AT
@STROFF
00 00   ; 16521

; THE STRING END AT
@STREND
00 00   ; 16523

; THE STRING END AT
@TMPVAL
00 00   ; 16525
;************************

@START

;CALL FAST

@RECHE 
LD HL,(VARS)

@RET1
LD A,(HL)
CP 80
JP Z END1

LD A,(HL)
CP "D"
INC HL
JR NZ RET1

LD A,(HL)
CP "A"
INC HL
JR NZ RET1

LD A,(HL)
CP "T"
INC HL
JR NZ RET1

LD A,(HL)
CP "A"
INC HL
JR NZ RET1

LD A,(HL)
CP "="
INC HL
JR NZ RET1
DEC HL
LD (TMPVAL),HL

LD BC,6
SBC HL,BC

;
CALL LHL

;STORE STRING LENGHT.
LD (ND),DE
LD BC,(ND)
ADD HL,BC
INC HL
INC HL
LD (STREND),HL

;HL AT STR START OFFSET
LD HL,(TMPVAL)

; ITEM COUNTER
LD BC,0
@NXTIT
INC BC
INC HL
LD (TMPVAL),HL
LD HL,(IJMP)
SBC HL,BC
JR Z EXIT1
LD HL,(TMPVAL)

; "," LOCATION
@L1
CALL CMPBIT
JR NZ L1
JR NXTIT

@EXIT1
; STORE THE FIRST SOURCE
; STRING OFFSET
LD HL,(TMPVAL)


LD (STROFF),HL
LD BC,0

; ITEM RICHED.
; READ IT NOW
@L2
@L3
INC BC
CALL CMPBIT
JR NZ L3

@EXIT2
LD (ILNG),BC

;CLEAN VARIABLE
;WITH FILLER
LD HL,(NXTL)
INC HL
INC HL
INC HL

@RET2
INC HL
LD A,(HL)
CP 76
LD A,(HL)
JR Z END1
CP 0B
JR Z RET4
JR RET2

@RET4
INC HL
@RET3
LD A,(FILL)
LD (HL),A
INC HL
LD A,(HL)
CP 0B
JR NZ RET3


LD BC,+9
LD HL,(NXTL)
ADD HL,BC
EX DE,HL

LD HL,(STROFF)

LD BC,(ILNG)
LDIR

LD BC,(IJMP)
INC BC
LD (IJMP),BC

@END1

;CALL SLOW
LD BC,(ILNG)
RET

@CMPBIT
INC HL
LD (TMPVAL),HL
LD DE,(STREND)
SBC HL,DE
JR NZ CMPBIT2
LD DE,00
LD (IJMP),DE
LD A,","
JR CMPBIT3
@CMPBIT2
LD HL,(TMPVAL)
LD A,(HL)
@CMPBIT3
CP ","
RET


;(HL) TO DE
@LHL
LD A,(HL)
LD E,A
INC HL
LD A,(HL)
LD D,A
DEC HL
RET

And Compiled for VB Xur (directory explorer window)/or/ZxToken...

Code: Select all

1  REM [HEX:\
01,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,\
2A,10,40,7E,FE,80,CA,3A,\
41,7E,FE,29,23,20,F4,7E,\
FE,26,23,20,EE,7E,FE,39,\
23,20,E8,7E,FE,26,23,20,\
E2,7E,FE,14,23,20,DC,2B,\
22,8D,40,01,06,00,ED,42,\
CD,60,41,ED,53,87,40,ED,\
4B,87,40,09,23,23,22,8B,\
40,2A,8D,40,01,00,00,03,\
23,22,8D,40,2A,82,40,ED,\
42,28,0A,2A,8D,40,CD,42,\
41,20,FB,18,EA,2A,8D,40,\
22,89,40,01,00,00,03,CD,\
42,41,20,FA,ED,43,85,40,\
2A,29,40,23,23,23,23,7E,\
FE,76,7E,28,2B,FE,0B,28,\
02,18,F3,23,3A,84,40,77,\
23,7E,FE,0B,20,F6,01,09,\
00,2A,29,40,09,EB,2A,89,\
40,ED,4B,85,40,ED,B0,ED,\
4B,82,40,03,ED,43,82,40,\
00,00,00,ED,4B,85,40,C9,\
23,22,8D,40,ED,5B,8B,40,\
ED,52,20,0B,11,00,00,ED,\
53,82,40,3E,1A,18,04,2A,\
8D,40,7E,FE,1A,C9,7E,5F,\
23,7E,57,2B,C9 ]

    5 LET A$="DATA=HELLO1,HELLO...2,HeLlO3,hELLO4,H E L L O 5,hello"
   10 LET L=USR 16526
   20 LET R$="                              "
   30 LIST 

Juste type "Run" and "Run" and "Run"
Poke 16514,1 & 16515,0 to set the ID.
Poke 16516,128 to set the backbround.

BUT,
Basic routine don't like call ASM codes...
This code is too big...
The A$ must be loaded in memory... (repeated 3 times : vars: A$, program and array.).
And the code had to find his child evrey time.

A Bad example ...
It's a prety code, but is't the bigger "unuseable" code ever seen !
I thow this code be cause of variables coding :
1/ the Next_line example.
2/ the Vars example.
3/ the L= reg DE exemple.

I'm coding a new release base on a program scan to retrive a 'LET A$="Data:e,e,e,e"' without a$ loading.
And it will able to store the next variable offset.

The André's DiPic basic code seem faster !!!
and the simple way to speed it up and save memory it to save the Vars after the init sequence!
(using a LET A$="" and a SAVE"a" line...)
But, We can't do that whith Dipic..

Have Fun.

:oops: :oops: :oops: :oops:

Xavier.
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Post Reply