2016-12-10 17:23:07 +00:00
|
|
|
.sect .text
|
|
|
|
|
|
|
|
! Compare sets a, b.
|
2017-02-13 21:52:32 +00:00
|
|
|
! Stack: ( b a size -- result )
|
|
|
|
! Result is 0 if equal, nonzero if not equal.
|
2016-12-10 17:23:07 +00:00
|
|
|
|
|
|
|
.define .cms
|
|
|
|
.cms:
|
2017-02-13 21:52:32 +00:00
|
|
|
lwz r3, 0(sp) ! r3 = size of each set
|
2017-02-11 23:00:56 +00:00
|
|
|
srwi r7, r3, 2
|
|
|
|
mtspr ctr, r7 ! ctr = size / 4
|
2017-02-13 21:52:32 +00:00
|
|
|
addi r4, sp, 4 ! r4 = ptr to set a
|
|
|
|
add r5, r4, r3 ! r5 = ptr to set b
|
2017-02-11 23:00:56 +00:00
|
|
|
li r6, 0 ! r6 = index
|
2016-12-10 17:23:07 +00:00
|
|
|
1:
|
2017-02-11 23:00:56 +00:00
|
|
|
lwzx r7, r4, r6
|
|
|
|
lwzx r8, r5, r6
|
In PowerPC libem, use the new features of our assembler.
The new features are the hi16/lo16 and ha16/lo16 syntax for
relocations, and the extended mnemonics like "blr".
Use ha16/lo16 to load some double floats with 2 instructions (lis/lfd)
instead of 3 (lis/ori/lfd).
Use the extended names for branches, comparisons, and bit rotations,
so I can more easily read the code. The new names often encode the
same machine instructions as the old names, except in a few places
where I changed the instructions.
Stop using andi. when we don't need to set cr0. In inn.s, I change
andi. to extrwi to extract the same bits. In los.s and sts.s, I
change "andi. r3, r3, ~3" to "clrrwi r3, r3, 2". This avoids setting
cr0 and also stops clearing the high 16 bits of r3.
In csa.s, los.s, sts.s, I change some comparisons and right shifts
from signed to unsigned (cmplw, cmplwi, srwi), because the sizes are
unsigned. In inn.s, the right shift can be signed (sraw) or unsigned
(srw), but I use srw because we don't need the carry bit.
In fef8.s, I save an instruction by using rlwinm instead of addis/andc
to rlwinm to clear a field. The code no longer kills r7. In both
fef8.s and fif8.s, I remove the list of killed registers.
Also remove some whitespace from ends of lines.
2017-01-23 22:16:39 +00:00
|
|
|
cmpw cr0, r7, r8 ! compare words in sets
|
2017-02-11 23:00:56 +00:00
|
|
|
addi r6, r6, 4
|
In PowerPC libem, use the new features of our assembler.
The new features are the hi16/lo16 and ha16/lo16 syntax for
relocations, and the extended mnemonics like "blr".
Use ha16/lo16 to load some double floats with 2 instructions (lis/lfd)
instead of 3 (lis/ori/lfd).
Use the extended names for branches, comparisons, and bit rotations,
so I can more easily read the code. The new names often encode the
same machine instructions as the old names, except in a few places
where I changed the instructions.
Stop using andi. when we don't need to set cr0. In inn.s, I change
andi. to extrwi to extract the same bits. In los.s and sts.s, I
change "andi. r3, r3, ~3" to "clrrwi r3, r3, 2". This avoids setting
cr0 and also stops clearing the high 16 bits of r3.
In csa.s, los.s, sts.s, I change some comparisons and right shifts
from signed to unsigned (cmplw, cmplwi, srwi), because the sizes are
unsigned. In inn.s, the right shift can be signed (sraw) or unsigned
(srw), but I use srw because we don't need the carry bit.
In fef8.s, I save an instruction by using rlwinm instead of addis/andc
to rlwinm to clear a field. The code no longer kills r7. In both
fef8.s and fif8.s, I remove the list of killed registers.
Also remove some whitespace from ends of lines.
2017-01-23 22:16:39 +00:00
|
|
|
bne cr0, 2f ! branch if not equal
|
|
|
|
bdnz 1b ! loop ctr times
|
2017-02-13 21:52:32 +00:00
|
|
|
li r9, 0 ! equal: return 0
|
2016-12-10 17:23:07 +00:00
|
|
|
b 3f
|
|
|
|
2:
|
2017-02-13 21:52:32 +00:00
|
|
|
li r9, 1 ! not equal: return 1
|
2016-12-10 17:23:07 +00:00
|
|
|
3:
|
2017-02-13 21:52:32 +00:00
|
|
|
slwi r7, r3, 1
|
|
|
|
add sp, sp, r7 ! adjust stack pointer
|
|
|
|
stw r9, 0(sp) ! push result
|
In PowerPC libem, use the new features of our assembler.
The new features are the hi16/lo16 and ha16/lo16 syntax for
relocations, and the extended mnemonics like "blr".
Use ha16/lo16 to load some double floats with 2 instructions (lis/lfd)
instead of 3 (lis/ori/lfd).
Use the extended names for branches, comparisons, and bit rotations,
so I can more easily read the code. The new names often encode the
same machine instructions as the old names, except in a few places
where I changed the instructions.
Stop using andi. when we don't need to set cr0. In inn.s, I change
andi. to extrwi to extract the same bits. In los.s and sts.s, I
change "andi. r3, r3, ~3" to "clrrwi r3, r3, 2". This avoids setting
cr0 and also stops clearing the high 16 bits of r3.
In csa.s, los.s, sts.s, I change some comparisons and right shifts
from signed to unsigned (cmplw, cmplwi, srwi), because the sizes are
unsigned. In inn.s, the right shift can be signed (sraw) or unsigned
(srw), but I use srw because we don't need the carry bit.
In fef8.s, I save an instruction by using rlwinm instead of addis/andc
to rlwinm to clear a field. The code no longer kills r7. In both
fef8.s and fif8.s, I remove the list of killed registers.
Also remove some whitespace from ends of lines.
2017-01-23 22:16:39 +00:00
|
|
|
blr
|