A89: Re: Address Error: Original Question


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

A89: Re: Address Error: Original Question






>
>I am resubmitting my original Address Error question because the original
message has most likely not continued on in its entirety.  I think that all
the information that I am including is important, so here it is again.
>
>
>  I keep getting an address error (actually it is an Adress Error) when I
run this program I'm writing. I figured out where it is, sort of. It has to
do when I use a macro to display a variable.
>
>  print_d0 MACRO
>  bsr print_value
>  move.w \3,-(a7)
>  move.l a0,-(a7)
>  move.w \2,-(a7)
>  move.w \1,-(a7)
>  jsr doorsos::DrawStrXY
>  lea 10(a7),a7
>  ENDM
>
>  print_value:
>  move.l #str 8,a0
>  clr.b (a0)
>  clr.l d1
>
>  print_loop:
>  add.l #1,d1
>  divu #10,d0
>  swap d0
>  add.b #48,d0
>  move.b d0,-(a0)

This is where your problem lies.  a0 will decrement to an odd address and
thus cause a memory address error when you move d0 into the odd address of
the odd pointer.  One way you can get around this would be to do this when
you need to access an odd byte:

 move.w (a0),d2
 move.b d0,d2
 move.w d2,d0
 move.w d0,(a0)

thus preserving the even byte you do not want to access

>  clr.w d0
>  swap d0
>  tst.w d0
>  bne print_loop
>  rts
>
>  ch:
>  jsr graphlib::clr_scr
>  move.w #1,-(a7)
>  jsr doorsos::FontSetSys
>  add.l #2,a7
>  pea cash(pc) ;cash if the varible
>  move.w cash,d0
>  print_d0 #70,#0,#4
>  clr.w -(a7)
>  jsr userlib::idle_loop
>  bra mnscr
>
>  I also have this at the bottom:
>  str dc.b " ",0
>  cash dc.w 0
>
>  What do I need to do to fix this?
>
>
>____________________________________________________________________
>Get free e-mail and a permanent address at http://www.netaddress.com/?N=1


Follow-Ups: