Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request boriel-basic#288 from boriel/feature/refact_or32
Browse files Browse the repository at this point in the history
Refactorize OR32
  • Loading branch information
boriel committed May 10, 2020
2 parents 1ab7517 + 6ad1138 commit ddc0ff8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 30 deletions.
35 changes: 19 additions & 16 deletions library-asm/or32.asm
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
__OR32: ; Performs logical operation A AND B
; between DEHL and TOP of the stack.
; Returns A = 0 (False) or A = FF (True)
; between DEHL and TOP of the stack.
; Returns A = 0 (False) or A = FF (True)

ld a, h
or l
or d
or e
ld a, h
or l
or d
or e

pop hl ; Return address
pop hl ; Return address
pop de
ex (sp), hl

pop de
or d
or e

pop de
or d
or e ; A = 0 only if DEHL and TOP of the stack = 0

jp (hl) ; Faster "Ret"
or d
or e
or h
or l

#ifdef NORMALIZE_BOOLEAN
; Ensure it returns 0 or 1
ret z
ld a, 1
#endif
ret

29 changes: 15 additions & 14 deletions tests/functional/or32.asm
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,21 @@ __CALL_BACK__:
DEFW 0
#line 1 "or32.asm"
__OR32: ; Performs logical operation A AND B
; between DEHL and TOP of the stack.
; Returns A = 0 (False) or A = FF (True)
ld a, h
or l
or d
or e
pop hl ; Return address
pop de
or d
or e
pop de
or d
or e ; A = 0 only if DEHL and TOP of the stack = 0
jp (hl) ; Faster "Ret"
; between DEHL and TOP of the stack.
; Returns A = 0 (False) or A = FF (True)
ld a, h
or l
or d
or e
pop hl ; Return address
pop de
ex (sp), hl
or d
or e
or h
or l
#line 24 "/zxbasic/library-asm/or32.asm"
ret
#line 58 "or32.bas"
ZXBASIC_USER_DATA:
_a:
Expand Down

0 comments on commit ddc0ff8

Please sign in to comment.