Bitmap Display on MARS Simulator

jomicobasi picture jomicobasi · Jan 21, 2015 · Viewed 10.2k times · Source

I am trying to draw some coloured squares into the memory of MARS Simulator. The problem is, I can't even staticaly draw anything.

http://tinypic.com/r/503czk/8

Basically, I have some memory filled with yellows (I guess that's the colour), but nothing is showing up. Just black.

    .macro Terminate
        li $v0, 10
        syscall
    .end_macro

    .data
what0: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what1: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what2: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what3: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what4: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what5: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what6: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what7: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what8: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what9: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what10: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what11: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what12: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what13: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what14: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what15: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what16: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what17: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what18: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00
what19: .word 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00

    .text   
main:

    Terminate

Thanks in advance.

Answer

gusbro picture gusbro · Jan 21, 2015

The Bitmap display tool in MARS simulator does not display the contents of the memory as a bitmap but rather plots the pixel written to the memory location where the display buffer is located.

That means you have to actually write the memory locations with the pixel you want to plot; it will not show you the "image" stored when compiling your code.

In your sample code, you can rewrite each pixel in its own memory location, e.g.:

    .text   
main:
    li $t1, 0
    li $t2, 4
    li $t3, 320
loop:
    lw $t4, what0($t1)
    sw $t4, what0($t1)
    addu $t1, $t1, $t2
    bne $t1, $t3, loop  

    Terminate