Skip to content

Commit 266275d

Browse files
authored
Merge pull request #201 from boriel/feature/optimize_array
Update array access
2 parents 4348055 + f340b6a commit 266275d

151 files changed

Lines changed: 516 additions & 1191 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

library-asm/array.asm

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ LOOP:
7373
exx
7474
pop de ; DE = Max bound Number (i-th dimension)
7575

76-
;call __MUL16_FAST ; HL *= DE
7776
call __FNMUL
7877
jp LOOP
7978
@@ -99,35 +98,13 @@ ARRAY_SIZE_LOOP:
9998
add hl, de
10099
djnz ARRAY_SIZE_LOOP
101100

102-
;; Even faster
103-
;pop bc
104-
105-
;ld d, h
106-
;ld e, l
107-
108-
;dec c
109-
;jp z, __ARRAY_FIN
110-
111-
;add hl, hl
112-
;dec c
113-
;jp z, __ARRAY_FIN
114-
115-
;add hl, hl
116-
;dec c
117-
;dec c
118-
;jp z, __ARRAY_FIN
119-
120-
;add hl, de
121-
;__ARRAY_FIN:
122101
#endif
123102

124103
pop de
125104
add hl, de ; Adds element start
126105

127106
RET_ADDRESS:
128-
ld de, 0
129-
push de
130-
ret ; HL = (Start of Elements + Offset)
107+
jp 0
131108

132109
;; Performs a faster multiply for little 16bit numbs
133110
LOCAL __FNMUL, __FNMUL2
@@ -137,10 +114,6 @@ __FNMUL:
137114
or d
138115
jp nz, __MUL16_FAST
139116

140-
or e
141-
ex de, hl
142-
ret z
143-
144117
cp 33
145118
jp nc, __MUL16_FAST
146119

tests/functional/27.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,9 @@ __MEM_START:
405405
__MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE
406406
ld a, h ; HL = NULL (No memory available?)
407407
or l
408-
#line 111 "/zbasic/library-asm/alloc.asm"
408+
#line 111 "/zxbasic/library-asm/alloc.asm"
409409
ret z ; NULL
410-
#line 113 "/zbasic/library-asm/alloc.asm"
410+
#line 113 "/zxbasic/library-asm/alloc.asm"
411411
; HL = Pointer to Free block
412412
ld e, (hl)
413413
inc hl

tests/functional/28.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,9 @@ __MEM_START:
408408
__MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE
409409
ld a, h ; HL = NULL (No memory available?)
410410
or l
411-
#line 111 "/zbasic/library-asm/alloc.asm"
411+
#line 111 "/zxbasic/library-asm/alloc.asm"
412412
ret z ; NULL
413-
#line 113 "/zbasic/library-asm/alloc.asm"
413+
#line 113 "/zxbasic/library-asm/alloc.asm"
414414
; HL = Pointer to Free block
415415
ld e, (hl)
416416
inc hl

tests/functional/29.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,9 @@ __MEM_START:
327327
__MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE
328328
ld a, h ; HL = NULL (No memory available?)
329329
or l
330-
#line 111 "/zbasic/library-asm/alloc.asm"
330+
#line 111 "/zxbasic/library-asm/alloc.asm"
331331
ret z ; NULL
332-
#line 113 "/zbasic/library-asm/alloc.asm"
332+
#line 113 "/zxbasic/library-asm/alloc.asm"
333333
; HL = Pointer to Free block
334334
ld e, (hl)
335335
inc hl

tests/functional/46.asm

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ __MUL16NOADD:
9797

9898
#line 20 "array.asm"
9999

100-
#line 24 "/zbasic/library-asm/array.asm"
100+
#line 24 "/zxbasic/library-asm/array.asm"
101101

102102
__ARRAY:
103103
PROC
@@ -120,10 +120,10 @@ __ARRAY:
120120
ld hl, 0 ; BC = Offset "accumulator"
121121

122122
LOOP:
123-
#line 49 "/zbasic/library-asm/array.asm"
123+
#line 49 "/zxbasic/library-asm/array.asm"
124124
pop bc ; Get next index (Ai) from the stack
125125

126-
#line 59 "/zbasic/library-asm/array.asm"
126+
#line 59 "/zxbasic/library-asm/array.asm"
127127

128128
add hl, bc ; Adds current index
129129

@@ -141,7 +141,6 @@ LOOP:
141141
exx
142142
pop de ; DE = Max bound Number (i-th dimension)
143143

144-
;call __MUL16_FAST ; HL *= DE
145144
call __FNMUL
146145
jp LOOP
147146

@@ -153,7 +152,7 @@ ARRAY_END:
153152
push de
154153
exx
155154

156-
#line 92 "/zbasic/library-asm/array.asm"
155+
#line 91 "/zxbasic/library-asm/array.asm"
157156
LOCAL ARRAY_SIZE_LOOP
158157

159158
ex de, hl
@@ -164,35 +163,13 @@ ARRAY_SIZE_LOOP:
164163
add hl, de
165164
djnz ARRAY_SIZE_LOOP
166165

167-
;; Even faster
168-
;pop bc
169-
170-
;ld d, h
171-
;ld e, l
172-
173-
;dec c
174-
;jp z, __ARRAY_FIN
175-
176-
;add hl, hl
177-
;dec c
178-
;jp z, __ARRAY_FIN
179-
180-
;add hl, hl
181-
;dec c
182-
;dec c
183-
;jp z, __ARRAY_FIN
184-
185-
;add hl, de
186-
;__ARRAY_FIN:
187-
#line 123 "/zbasic/library-asm/array.asm"
166+
#line 102 "/zxbasic/library-asm/array.asm"
188167

189168
pop de
190169
add hl, de ; Adds element start
191170

192171
RET_ADDRESS:
193-
ld de, 0
194-
push de
195-
ret ; HL = (Start of Elements + Offset)
172+
jp 0
196173

197174
;; Performs a faster multiply for little 16bit numbs
198175
LOCAL __FNMUL, __FNMUL2
@@ -202,10 +179,6 @@ __FNMUL:
202179
or d
203180
jp nz, __MUL16_FAST
204181

205-
or e
206-
ex de, hl
207-
ret z
208-
209182
cp 33
210183
jp nc, __MUL16_FAST
211184

tests/functional/47.asm

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ __MUL16NOADD:
124124

125125
#line 20 "array.asm"
126126

127-
#line 24 "/zbasic/library-asm/array.asm"
127+
#line 24 "/zxbasic/library-asm/array.asm"
128128

129129
__ARRAY:
130130
PROC
@@ -147,10 +147,10 @@ __ARRAY:
147147
ld hl, 0 ; BC = Offset "accumulator"
148148

149149
LOOP:
150-
#line 49 "/zbasic/library-asm/array.asm"
150+
#line 49 "/zxbasic/library-asm/array.asm"
151151
pop bc ; Get next index (Ai) from the stack
152152

153-
#line 59 "/zbasic/library-asm/array.asm"
153+
#line 59 "/zxbasic/library-asm/array.asm"
154154

155155
add hl, bc ; Adds current index
156156

@@ -168,7 +168,6 @@ LOOP:
168168
exx
169169
pop de ; DE = Max bound Number (i-th dimension)
170170

171-
;call __MUL16_FAST ; HL *= DE
172171
call __FNMUL
173172
jp LOOP
174173

@@ -180,7 +179,7 @@ ARRAY_END:
180179
push de
181180
exx
182181

183-
#line 92 "/zbasic/library-asm/array.asm"
182+
#line 91 "/zxbasic/library-asm/array.asm"
184183
LOCAL ARRAY_SIZE_LOOP
185184

186185
ex de, hl
@@ -191,35 +190,13 @@ ARRAY_SIZE_LOOP:
191190
add hl, de
192191
djnz ARRAY_SIZE_LOOP
193192

194-
;; Even faster
195-
;pop bc
196-
197-
;ld d, h
198-
;ld e, l
199-
200-
;dec c
201-
;jp z, __ARRAY_FIN
202-
203-
;add hl, hl
204-
;dec c
205-
;jp z, __ARRAY_FIN
206-
207-
;add hl, hl
208-
;dec c
209-
;dec c
210-
;jp z, __ARRAY_FIN
211-
212-
;add hl, de
213-
;__ARRAY_FIN:
214-
#line 123 "/zbasic/library-asm/array.asm"
193+
#line 102 "/zxbasic/library-asm/array.asm"
215194

216195
pop de
217196
add hl, de ; Adds element start
218197

219198
RET_ADDRESS:
220-
ld de, 0
221-
push de
222-
ret ; HL = (Start of Elements + Offset)
199+
jp 0
223200

224201
;; Performs a faster multiply for little 16bit numbs
225202
LOCAL __FNMUL, __FNMUL2
@@ -229,10 +206,6 @@ __FNMUL:
229206
or d
230207
jp nz, __MUL16_FAST
231208

232-
or e
233-
ex de, hl
234-
ret z
235-
236209
cp 33
237210
jp nc, __MUL16_FAST
238211

tests/functional/48.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,9 @@ __MEM_START:
416416
__MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE
417417
ld a, h ; HL = NULL (No memory available?)
418418
or l
419-
#line 111 "/zbasic/library-asm/alloc.asm"
419+
#line 111 "/zxbasic/library-asm/alloc.asm"
420420
ret z ; NULL
421-
#line 113 "/zbasic/library-asm/alloc.asm"
421+
#line 113 "/zxbasic/library-asm/alloc.asm"
422422
; HL = Pointer to Free block
423423
ld e, (hl)
424424
inc hl

tests/functional/49.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,9 @@ __MEM_START:
416416
__MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE
417417
ld a, h ; HL = NULL (No memory available?)
418418
or l
419-
#line 111 "/zbasic/library-asm/alloc.asm"
419+
#line 111 "/zxbasic/library-asm/alloc.asm"
420420
ret z ; NULL
421-
#line 113 "/zbasic/library-asm/alloc.asm"
421+
#line 113 "/zxbasic/library-asm/alloc.asm"
422422
; HL = Pointer to Free block
423423
ld e, (hl)
424424
inc hl

tests/functional/55.asm

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ __MUL16NOADD:
9292

9393
#line 20 "array.asm"
9494

95-
#line 24 "/zbasic/library-asm/array.asm"
95+
#line 24 "/zxbasic/library-asm/array.asm"
9696

9797
__ARRAY:
9898
PROC
@@ -115,10 +115,10 @@ __ARRAY:
115115
ld hl, 0 ; BC = Offset "accumulator"
116116

117117
LOOP:
118-
#line 49 "/zbasic/library-asm/array.asm"
118+
#line 49 "/zxbasic/library-asm/array.asm"
119119
pop bc ; Get next index (Ai) from the stack
120120

121-
#line 59 "/zbasic/library-asm/array.asm"
121+
#line 59 "/zxbasic/library-asm/array.asm"
122122

123123
add hl, bc ; Adds current index
124124

@@ -136,7 +136,6 @@ LOOP:
136136
exx
137137
pop de ; DE = Max bound Number (i-th dimension)
138138

139-
;call __MUL16_FAST ; HL *= DE
140139
call __FNMUL
141140
jp LOOP
142141

@@ -148,7 +147,7 @@ ARRAY_END:
148147
push de
149148
exx
150149

151-
#line 92 "/zbasic/library-asm/array.asm"
150+
#line 91 "/zxbasic/library-asm/array.asm"
152151
LOCAL ARRAY_SIZE_LOOP
153152

154153
ex de, hl
@@ -159,35 +158,13 @@ ARRAY_SIZE_LOOP:
159158
add hl, de
160159
djnz ARRAY_SIZE_LOOP
161160

162-
;; Even faster
163-
;pop bc
164-
165-
;ld d, h
166-
;ld e, l
167-
168-
;dec c
169-
;jp z, __ARRAY_FIN
170-
171-
;add hl, hl
172-
;dec c
173-
;jp z, __ARRAY_FIN
174-
175-
;add hl, hl
176-
;dec c
177-
;dec c
178-
;jp z, __ARRAY_FIN
179-
180-
;add hl, de
181-
;__ARRAY_FIN:
182-
#line 123 "/zbasic/library-asm/array.asm"
161+
#line 102 "/zxbasic/library-asm/array.asm"
183162

184163
pop de
185164
add hl, de ; Adds element start
186165

187166
RET_ADDRESS:
188-
ld de, 0
189-
push de
190-
ret ; HL = (Start of Elements + Offset)
167+
jp 0
191168

192169
;; Performs a faster multiply for little 16bit numbs
193170
LOCAL __FNMUL, __FNMUL2
@@ -197,10 +174,6 @@ __FNMUL:
197174
or d
198175
jp nz, __MUL16_FAST
199176

200-
or e
201-
ex de, hl
202-
ret z
203-
204177
cp 33
205178
jp nc, __MUL16_FAST
206179

tests/functional/addstr.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,9 +576,9 @@ __MEM_START:
576576
__MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE
577577
ld a, h ; HL = NULL (No memory available?)
578578
or l
579-
#line 111 "/zbasic/library-asm/alloc.asm"
579+
#line 111 "/zxbasic/library-asm/alloc.asm"
580580
ret z ; NULL
581-
#line 113 "/zbasic/library-asm/alloc.asm"
581+
#line 113 "/zxbasic/library-asm/alloc.asm"
582582
; HL = Pointer to Free block
583583
ld e, (hl)
584584
inc hl

0 commit comments

Comments
 (0)