Reversing the bytes in a word: (i.e. changing endianness)

On comp.sys.acorn nbannon@tartarus.uwa.edu.au (Nick Bannon) gave a small code fragment to print decimal numbers from ARM code - useful for debugging, and olly@mantis.co.uk (Olly Betts) made a small bug fix. The final version is included below:
 .printbin			; R0=num
 STMFD R13!,{R0-R2,R14}
 SUB R13,R13,#36
 MOV R1,R13
 MOV R2,#36
 SWI XOS_ConvertBinary4	; Convert to 32 char string
 ;._loop			; Strip leading 0's
 ;LDRB R1,[R0],#1		; Uncomment to execute
 ;CMP R1,#"0"
 ;BEQ _loop
 ;SBC R0,R0,#1		; subtracts 1 if R1>='0', 2 if R1<'0' SWI XOS_Write0 ADD R13,R13,#36 SWI XOS_NewLine LDMFD R13!,{R0-R2,PC}^ 

Robin.Watts@prg.ox.ac.uk

AltStyle によって変換されたページ (->オリジナル) /