1

I'm using an assebler project in ATMEL Studio 7 (ATtiny84A) and I ran into a strange problem. In a code segment, if a .DB has two bytes it's fine, but two .DB on separate lines gives a misalignment warning.

.CSEG

; one row
.DB 0x01, 0x02

; same data on two rows
.DB 0x01
.DB 0x02

I understand what misalignment is, but I can't see why the compiler is complaining since putting the data on one row vs two rows yeld the exact same amount of data, in the exact same order.

Do I need some "pack" directive to make it understand that this should be treated as the same chunk of data?

The reason to divide it up in one .DB per line is because it defines character glyphs, like this

.db 0b00000000 ; 0 - 0
.db 0b00111000
.db 0b01000100
.db 0b01000100
.db 0b01000100
.db 0b01000100
.db 0b01000100
.db 0b00111000

It's a lot easier to design/change the glyphs in this way.

EDIT:
Ok, I figured it out. You can simply split one line with \

; 0 - 0
.db 0b00000000, \
    0b00111000
.db 0b01000100, \
    0b01000100
.db 0b01000100, \
    0b01000100
.db 0b01000100, \
    0b00111000

I guess it got confused bacause .CSEG is word oriented. But the compiler should be smart enough to figure out this on its own.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Max Kielland
  • 5,627
  • 9
  • 60
  • 95
  • Have you seen the binary when you put each .db on its own line (without the \)? Does it pad it out to a word or pack them together in a word? – Erik Eidt May 31 '20 at 15:08
  • Yes, it did put a 0 byte pad in front of each .DB byte. – Max Kielland May 31 '20 at 15:57
  • Can you quote the exact error message so future readers will be able to find this when searching? Also, post your answer as an answer, not an edit to the question. – Peter Cordes Jun 01 '20 at 00:37

0 Answers0