View Single Post
Old 10 February 2017, 09:24   #3
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
This RiVA code is more than a little bit suspect.

Code:
CreatePalette	lea	Palette,a0
		move.w	#256,(a0)+			;Number of colours to load
		move.w	#0,(a0)+			;Register number to start from
		move.l	#256-1,d7
.colsloop	move.b	d7,d6
		lsl.l	#8,d6
		move.b	d7,d6
		lsl.l	#8,d6
		move.b	d7,d6
		lsl.l	#8,d6
		move.b	d7,d6
		lsl.l	#8,d6
		not.l	d6
		move.l	d6,(a0)+
		move.l	d6,(a0)+
		move.l	d6,(a0)+
		dbf	d7,.colsloop
		move.l	#0,(a0)				;Close Structure
		rts
Did somebody get carried away with the shifting?

Code:
CreatePalette	lea	Palette,a0
		move.l  #256,d7
		move.w	d7,(a0)+			;Number of colours to load
		subq.l  #1,d7				;256-1
		clr.w	(a0)+				;Register number to start from
.colsloop	move.b	d7,d6
		lsl.l	#8,d6
		move.b	d7,d6
		lsl.l	#8,d6
		move.b	d7,d6
		lsl.l	#8,d6
		not.l	d6
		move.l	d6,(a0)+
		move.l	d6,(a0)+
		move.l	d6,(a0)+
		dbf	d7,.colsloop
		clr.l	(a0)				;Close Structure
		rts
Shaved a few cycles and 12 bytes. Even vasm would have saved 6 bytes here if optimizations were on. At least compilers are smart enough to turn on optimizations .

Last edited by matthey; 10 February 2017 at 09:59.
matthey is offline  
 
Page generated in 0.05662 seconds with 10 queries