Re: A89: Need some help with an error
[Prev][Next][Index][Thread]
Re: A89: Need some help with an error
> delay:
> move.w #0,d0
> =20
> delay_repeat:
> add.w #1,d0
> cmp delay_len,d0
> bne delay_repeat
I'd recommend using the full cmp.w, regardless of what the assembler
defaults to - it might fail when you want cmp.b or cmp.l and don't specify
it.
You could also save yourself a byte or two by increasing delay_len and using
the following code:
move.w delay_len,d0
\delay_repeat:
dbra d0,\delay_repeat
> rts
> =20
> _main:
> jsr graphlib::clr_scr ; clear the screen
> loop:
> =20
> move.w numx,d0 =20
> move.w #20,d1 =20
> move.l #ball_sprite,a0
if you're loading the address of a label into a register, you _should_ use:
lea ball_sprite(PC),a0
> jsr graphlib::put_sprite
> cmp #0,dir
> beq right
Once again, specify the size in cmp. . . and for a neat little optimization,
these two lines can be written as:
tst.w dir ;triggers beq if dir = 0, bne otherwise
beq right
> cmp #1,dir
> beq left
> bsr loop
Here's where the error is - should be "bra loop". You're overflowing the
stack and running into protected mem
> moveleft:
> move #1,dir
> bsr loop
> moveright:
> move #0,dir
> bsr loop
Those should _all_ be "bra loop" and not bsr
> right:
> add.w #1,numx
> cmp #100,numx
> beq moveleft
> bsr loop
> left:
> sub.w #1,numx
> cmp #1,numx
> beq moveright
> bsr loop=20
I think that you want these
> end:
Don't use end as a label, a68k wants to use it as a directive. And in a
kernel using prog like this one, you should use _exit (and xdef if like you
do _main and _comment) as the label to finish uo, so that the kernel can run
that code on a crash.
> clr.l d0
> clr.l d1
> clr.w numx
> clr.w temp
> rts ; end of program
-Scott
References: