How do i create or edit basic, bmp image using risc-v assembler?

32 views Asked by At

I am using rars, and i need to create empty bmp file, and edit it, but idk how. I have code(attached below) that create file, but when i try to open exit file, it says that file is corrupted)

code:

.data
bmp_header: .byte 0x42, 0x4D, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00
pixel_data: .byte 0x00

.text
main:
    
    la a0, filename
    li a1, 1
    li a7, 1024
    ecall

   
    mv s0, a0

    
    la a1, bmp_header
    li a2, 62
    mv a0, s0
    li a7, 64
    ecall

    
    la a1, pixel_data
    li a2, 1
    mv a0, s0
    li a7, 64
    ecall

   
    mv a0, s0
    li a7, 57
    ecall

Can you help me fix mine code, or give other one, and explain how it works, cause i am new in this, thanks

0

There are 0 answers