[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ROL Instruction



> Here is a weird way to use the stack for looping (the same idea can be
> used to loop 2^n times). It's really slow, though, and cannot be inlined,
> so it's mostly a curiosity (10 bytes but you need to JSR to it, so +3):
> 
>    jsr .1
> .1 jsr .2
> .2 cmp #$80
>    rol
>    rts

I've seen a variation of this in NES games where space is so important. They
used it as a way of calling a subroutine with two different args without
wasting space. i.e.

   lda #arg1
   jsr .1
   lda #arg2
.1 other code
   rts

-Lucas