comparing 16 bit numbers
- barrym95838
- Posts: 2056
- Joined: 30 Jun 2013
- Location: Sacramento, CA, USA
Re: comparing 16 bit numbers
It looks correct at first glance, but only for unsigned numbers.
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!
Mike B. (about me) (learning how to github)
Mike B. (about me) (learning how to github)
- speculatrix
- Posts: 151
- Joined: 03 Apr 2018
- Contact:
Re: comparing 16 bit numbers
barrym95838 wrote:
It looks correct at first glance, but only for unsigned numbers.
I should have said that this is for unsigned numbers.
It either works or catches fire. Either way is fun.
Zolatron 64 project (on Medium)
Zolatron 64 project (on Medium)
-
pebmeister
- Posts: 32
- Joined: 19 Feb 2013
- Location: Marlborough, Ma
Re: comparing 16 bit numbers
Just as an FYI I have made these macros that work with my assembler, but they should be compatible to others
Code: Select all
;********************************************
;* *
;* BEQ16 *
;* *
;* 16bit beq *
;* *
;* \1 a 16-bit *
;* \2 b 16 bit *
;* \3 Destination a = b *
;* *
;* destroys a *
;* *
;********************************************
.macro BEQ16
lda \1 + 1
cmp \2 + 1
bne @exit
lda \1
cmp \2
beq \3
@exit
.endm
;********************************************
;* *
;* BNE16 *
;* *
;* 16bit beq *
;* *
;* \1 a 16-bit *
;* \2 b 16 bit *
;* \3 Destination a != b *
;* *
;* destroys a *
;* *
;********************************************
.macro BNE16
lda \1 + 1
cmp \2 + 1
bne \3
lda \1
cmp \2
bne \3
.endm
;********************************************
;* *
;* BLT16 *
;* *
;* 16bit bcc *
;* *
;* \1 a 16-bit *
;* \2 b 16 bit *
;* \3 Destination a < b *
;* *
;* destroys a *
;* *
;********************************************
.macro BLT16
lda \1 + 1
cmp \2 + 1
bcc \3
bne @exit
lda \1
cmp \2
bcc \3
@exit
.endm
;********************************************
;* *
;* BLE16 *
;* *
;* 16bit branch less than or equal *
;* *
;* \1 a 16-bit *
;* \2 b 16 bit *
;* \3 Destination a <= b *
;* *
;* destroys a *
;* *
;********************************************
.macro BLE16
lda \1 + 1
cmp \2 + 1
bcc \3
bne @exit
lda \1
cmp \2
bcc \3
beq \3
@exit
.endm