Skip to content

Commit ddc0ff8

Browse files
authored
Merge pull request #288 from boriel/feature/refact_or32
Refactorize OR32
2 parents 1ab7517 + 6ad1138 commit ddc0ff8

2 files changed

Lines changed: 34 additions & 30 deletions

File tree

library-asm/or32.asm

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
__OR32: ; Performs logical operation A AND B
2-
; between DEHL and TOP of the stack.
3-
; Returns A = 0 (False) or A = FF (True)
2+
; between DEHL and TOP of the stack.
3+
; Returns A = 0 (False) or A = FF (True)
44

5-
ld a, h
6-
or l
7-
or d
8-
or e
5+
ld a, h
6+
or l
7+
or d
8+
or e
99

10-
pop hl ; Return address
10+
pop hl ; Return address
11+
pop de
12+
ex (sp), hl
1113

12-
pop de
13-
or d
14-
or e
15-
16-
pop de
17-
or d
18-
or e ; A = 0 only if DEHL and TOP of the stack = 0
19-
20-
jp (hl) ; Faster "Ret"
14+
or d
15+
or e
16+
or h
17+
or l
2118

19+
#ifdef NORMALIZE_BOOLEAN
20+
; Ensure it returns 0 or 1
21+
ret z
22+
ld a, 1
23+
#endif
24+
ret
2225

tests/functional/or32.asm

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,21 @@ __CALL_BACK__:
6868
DEFW 0
6969
#line 1 "or32.asm"
7070
__OR32: ; Performs logical operation A AND B
71-
; between DEHL and TOP of the stack.
72-
; Returns A = 0 (False) or A = FF (True)
73-
ld a, h
74-
or l
75-
or d
76-
or e
77-
pop hl ; Return address
78-
pop de
79-
or d
80-
or e
81-
pop de
82-
or d
83-
or e ; A = 0 only if DEHL and TOP of the stack = 0
84-
jp (hl) ; Faster "Ret"
71+
; between DEHL and TOP of the stack.
72+
; Returns A = 0 (False) or A = FF (True)
73+
ld a, h
74+
or l
75+
or d
76+
or e
77+
pop hl ; Return address
78+
pop de
79+
ex (sp), hl
80+
or d
81+
or e
82+
or h
83+
or l
84+
#line 24 "/zxbasic/library-asm/or32.asm"
85+
ret
8586
#line 58 "or32.bas"
8687
ZXBASIC_USER_DATA:
8788
_a:

0 commit comments

Comments
 (0)