View Single Post
Old 16 July 2012, 22:54   #96
frank_b
Registered User
 
Join Date: Jun 2008
Location: Boston USA
Posts: 466
Quote:
Originally Posted by StingRay View Post
Sure does. Might be that I needed this behaviour once and my mind was playing tricks on me.

I tested using this code albeit on the Hatari emulator.

d1 winds up being $ff00
Code:
oddsandends
        move.l sp,d0
        move.w #$3344,-(sp)
        move.b #$ff,d1
        move.b d1,-(sp)
        move.w (sp)+,d1   ; shift by 8
        move.l d0,sp
        rts
Seems my memory and test code was fuzzy. Here's a better test case.

Code:
oddsandends
        move.l sp,d0
        move.w #$3344,-(sp)  ; set four bytes up with garbage
        move.w #$1122,-(sp)  ; " " 
        
        addq   #2,sp         ; point the stack at $1122

        move.l sp,a1         ; stuff it in a1
        move.b -1(a1),d2     ; we load $22 
        
        move.b #$ff,d1       ; then move shift value
        move.b d1,-(sp)      ; boom high byte is $22 
        move.w (sp)+,d1      ; shift by 8 and d1 is now $ff22 
        move.l d0,sp
        rts
Indeed there's garbage in the lower byte. Care must be taken when using the stack with this trick

Last edited by frank_b; 29 July 2012 at 13:04. Reason: Added code block around code.
frank_b is offline  
 
Page generated in 0.04243 seconds with 11 queries