This provides and, ior, xor, com, zer, set, cms when defined($1) and ior, set when !defined($1). I don't provide the other operations !defined($1) because our Modula-2 compiler hasn't used them. I wrote a Modula-2 example in https://gist.github.com/kernigh/add79662bb3c63ffb7c46d01dc8ae788 Put a dummy comment in mach/powerpc/libem/build.lua so git checkout will touch that file. Without the touch, the build system doesn't see the new *.s files.
		
			
				
	
	
		
			29 lines
		
	
	
	
		
			598 B
		
	
	
	
		
			ArmAsm
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
	
		
			598 B
		
	
	
	
		
			ArmAsm
		
	
	
	
	
	
| #include "powerpc.h"
 | |
| 
 | |
| .sect .text
 | |
| 
 | |
| ! Create singleton set.
 | |
| !  Stack: ( -- set )
 | |
| !  With r3 = size of set, r4 = bit number
 | |
| 
 | |
| .define .set
 | |
| .set:
 | |
| 	rlwinm	r7, r3, 30, 2, 31
 | |
| 	neg	r5, r3
 | |
| 	add	sp, sp, r5		! allocate set
 | |
| 	mr	r6, sp			! r6 = ptr to set
 | |
| 	mtspr	ctr, r7			! ctr = r3 / 4
 | |
| 1:
 | |
| 	rlwinm.	r7, r4, 0, 0, 26	! r7 = r4 & ~31
 | |
| 	bc	IFTRUE, EQ, 2f		! branch if r4 in 0..31
 | |
| 	addi	r5, r0, 0		! no bit, word is zero
 | |
| 	b	3f
 | |
| 2:
 | |
| 	addi	r5, r0, 1
 | |
| 	slw	r5, r5, r4		! yes bit, set bit in word
 | |
| 3:
 | |
| 	stw	r5, 0(r6)		! store word in set
 | |
| 	addi	r4, r4, -32
 | |
| 	addi	r6, r6, 4
 | |
| 	bc	DNZ, 0, 1b		! loop ctr times
 | |
| 	bclr	ALWAYS, 0, 0
 |