Reputation: 75
I am having problem getting rid of the trailing trash in memory when logging my output.
I have a number n in my D1 and another one in D2.
Whenever I log them, the appear like this:
1-20012
but I just want the 1-2
I would just like to know how would I be able to select certain bytes of my Data Registers and put them in memory (in a ds.b declared storage with label result with size of 40 bytes).
Say, if I store the 1 in the starting address of my label "result" ($0000 2450), the '1' would only take up 1 byte, so will the '-' sign, as well as the '2'. So these contents would be stored in the range $0000 2450 - $0000 2452. The thing is that the following byte addresses contain garbage from previous operations and I am not allowed to clear them manually. I need to develop a method to clear them during runtime.
How would I ignore the following garbage bytes that are logged all together with my '1-2' print?
Thank you for your help!
Upvotes: 0
Views: 66
Reputation: 14325
Like @Jester suggested, maybe you should terminate the string with a NUL character.
move.l #result,a0
move.b d1,(a0)+ ;Or maybe call a subroutine to convert from decimal?
move.b #'-',(a0)+
move.b d2,(a0)+
clr.b (a0) ;Clear last byte.
Or if you want to use the number of bytes written:
move.b #result,a0
move.b d1,(a0)+
move.b #'-',(a0)+
move.b d2,(a0)+
sub.l #result,a0 ;A0 is now the number of bytes to log.
Upvotes: 1