MIPS - Assembler - store address not aligned on word boundary

-1

I'm trying to create BMP file from scratch in Mips (Mars 4.5 emulator). In order to do so, I'm trying to write its headers to some buffers. But saddly I get error of beeing "not aligned on word boundary" in first "save word" instruction. Buffer size does not affects this error :/ (BMP header has 14 bytes, I tried extending buffer to 16 bytes but no result).

Code:

la $s0, BMP_header
li $t0, 0x424D4600
li $t1, 0x00000000
li $t2, 0x00003600
li $t3, 0x00000000

sw $t0, ($s0)
addi $s0, $s0, 4 #BM, size
sw $t1, ($s0)
addi $s0, $s0, 4 #size, 00
sw $t2, ($s0)
addi $s0, $s0, 4 #00 offset
sw $t4, ($s0)
addi $s0, $s0, 4 #offset 00

It looks like I'm missing something that makes buffer alignment to correct address, but I have no clue what that is.

assembly
mips
asked on Stack Overflow Mar 20, 2020 by Rafalini

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0