2018-09-10 21:37:28 +00:00
|
|
|
#
|
|
|
|
.sect .text; .sect .rom; .sect .data; .sect .bss
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create singleton set.
|
|
|
|
* Stack: ( bitnumber size -- set )
|
|
|
|
*/
|
|
|
|
|
|
|
|
.sect .text
|
|
|
|
.define .set
|
|
|
|
.set:
|
|
|
|
lw r4, 0(sp) ! r4 = size
|
|
|
|
lw r5, 4(sp) ! r5 = bit number
|
2018-09-17 10:56:15 +00:00
|
|
|
addiu sp, sp, 8
|
2018-09-10 21:37:28 +00:00
|
|
|
srl r4, r4, 2 ! r4 = word count
|
|
|
|
|
2018-09-17 10:56:15 +00:00
|
|
|
! Create an empty set by pushing zeros.
|
2018-09-10 21:37:28 +00:00
|
|
|
|
|
|
|
1:
|
|
|
|
addiu sp, sp, -4
|
|
|
|
sw zero, 0(sp)
|
|
|
|
addiu r4, r4, -1
|
|
|
|
bne r4, zero, 1b
|
2018-09-17 10:56:15 +00:00
|
|
|
nop
|
2018-09-10 21:37:28 +00:00
|
|
|
|
|
|
|
! sp now points at the set.
|
|
|
|
|
2018-09-17 10:56:15 +00:00
|
|
|
andi r6, r5, ~31 ! r6 = bit offset of base of word in set
|
|
|
|
srl r6,r6, 3 ! r6 = byte offset of word in set
|
|
|
|
addu r6, sp, r6 ! r6 = address of word in set
|
2018-09-10 21:37:28 +00:00
|
|
|
|
2018-09-17 10:56:15 +00:00
|
|
|
andi r7, r5, 31 ! r7 = bit number within word
|
2018-09-10 21:37:28 +00:00
|
|
|
li r8, 1
|
|
|
|
sllv r8, r8, r7 ! r8 = word with 1 set
|
|
|
|
sw r8, 0(r6) ! write to set
|
|
|
|
|
|
|
|
jr ra
|
|
|
|
nop
|
|
|
|
|