A89: Re: disp d0


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

A89: Re: disp d0




nevermind folks, Olle helped me out over icq :-)  it appears that a68k
doesn't handle things like =$-1 the same way z80 compilers do.
here's the corrected routine though, in case you want to use it.  if
you don't like using the rom call macro for whatever socialist reason,
you can change rom_call DrawStr to jsr tios::DrawStrXY.  I don't think
there's really any benift though, since the rom_call macro is only 6
bytes (jsr tios::DrawStrXY is also 6 bytes?).

;display d0 in unsigned decimal (must be 5 digits or less)
;input: d0.l (value to display); d1.l (upper word = x, lower word =
y); d2.w (color)
;destroyed: d0,d1,d2,a0

dispD0:
 move.w d2,-(a7)   ;push color here so d2 can be used for scratch
 lea strBuffer-1(pc),a0  ;last byte of string buffer (work right to
left)
dispD0Loop:
 divu #10,d0    ;get rightmost base 10 digit into remainder
 move.l d0,d2    ;preserve d0 in case more digits
 swap d2     ;get remainder into d2.w
 add.b #'0',d2    ;make d2 into an ascii char
 move.b d2,-(a0)   ;store it in the string buffer
 ext.l d0     ;clear upperword of d0 for next divide
 bne dispD0Loop    ;get next digit if more remain
 move.l a0,-(a7)   ;push pointer to string for DrawStr
 move.l d1,-(a7)   ;push x and y coordinates for DrawStr
 rom_call DrawStr   ;display the string
 lea 10(a7),a7    ;restore stack
 rts

 ds.b 5
strBuffer:
 dc.b 0     ;zero terminated



Follow-Ups: References: