2016-12-10 17:23:07 +00:00
|
|
|
#include "powerpc.h"
|
|
|
|
|
|
|
|
.sect .text
|
|
|
|
|
|
|
|
! Set intersection.
|
2017-01-17 21:31:38 +00:00
|
|
|
! Stack: ( b a size -- a*b )
|
2016-12-10 17:23:07 +00:00
|
|
|
|
|
|
|
.define .and
|
|
|
|
.and:
|
2017-01-17 21:31:38 +00:00
|
|
|
lwz r3, 0 (sp) ! r3 = size
|
|
|
|
addi sp, sp, 4
|
|
|
|
|
2016-12-10 17:23:07 +00:00
|
|
|
mr r4, sp ! r4 = ptr to set a
|
|
|
|
add r5, sp, r3 ! r5 = ptr to set b
|
|
|
|
rlwinm r6, r3, 30, 2, 31
|
|
|
|
mtspr ctr, r6 ! ctr = r3 / 4
|
|
|
|
1:
|
|
|
|
lwz r7, 0(r4)
|
|
|
|
lwz r8, 0(r5)
|
|
|
|
and r8, r7, r8 ! intersection of words
|
|
|
|
stw r8, 0(r5)
|
|
|
|
addi r4, r4, 4
|
|
|
|
addi r5, r5, 4
|
|
|
|
bc DNZ, 0, 1b ! loop ctr times
|
|
|
|
add sp, sp, r3
|
|
|
|
bclr ALWAYS, 0, 0
|