用于在MIPS中修改图像中的像素的功能

时间:2018-07-30 10:25:38

标签: mips

我在C语言中获得了以下功能。它必须从图像中修改像素。它以图像的地址,2个坐标和必须存储在该位置的字节为参数。

void image_set_pixel(Image *img, int x, int y, Pixel colour) {
  Pixel *pixel = image_pixel_addr(img, x, y);
  *pixel = colour;
}

我尝试了这个,但是似乎有些不起作用:

image_set_pixel:            # ($a0, $a1, $a2, $a3) = (img, x, y, pixel color)
    addiu   $sp, $sp, -8
    sw  $ra, 0($sp)
    sw  $s0, 4($sp)

    jal     image_pixel_addr # this func returns the adress of a pixel inside an image
    move    $s0, $v0
    sb  $a3, 0($s0)

    lw  $ra, 0($sp)
    lw  $s0, 4($sp)
    addiu   $sp, $sp, 8
    jr  $ra

0 个答案:

没有答案
相关问题