Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can you make this a MIPS assembly code : *display an image at a given location a

ID: 3667411 • Letter: C

Question

Can you make this a MIPS assembly code:

*display an image at a given location any necessary orientation, and possibly animation
*store any data necessary to achieve this orientation as well as a way to correctly display the image

} Sprite;

where 'data' points to the image data, x and y are the location of the sprite, and h and w are the height and width so that you can print the image correctly and other things (like collision detection).

his is my code so far but it loop is infinity

    syscall

main:
load the immediate value 0x0eeeeeee into register $s2
load the immediate value 0 into register $s3
loop:
rotate the contents of $s2 right four bits
save the value in InArr
branch back to loop: if the register $s2 is not equal to $s3

The infinite loop is caused by the fact that $s3 contains a value of 0 and you make no change to this.
What you should have (again written in English) is this

main:
load the immediate value 0x0eeeeeee into register $s2
load the immediate value 7 into register $s3
loop:
rotate the contents of $s2 right four bits
save the value in InArr
subtract 1 from $s3
branch back to loop: if the register $s2 is not equal to $s3

Dry running this gives you the following results

$s2 $s3
1 0x0eeeeeee 7
2 0xe0eeeeee 6
3 0xee0eeeee 5
4 0xeee0eeee 4
5 0xeeee0eee 3
6 0xeeeee0ee 2
7 0xeeeeee0e 1
8 0xeeeeeee0 0

1 typedef struct {

Explanation / Answer

typedef struct { void* data; short x,y,h,w; } Sprite; mov ebp,esp ;set base of stack to top of stack sub esp,12 ;allocate 12 bytes on the stack push .size ;pass some size to memcpy push .data ;pass some data to memcpy push [ebp-12] ;pass array to memcpy, this sets your data call [memcpy] ;call memcpy to get your pointer data mov word[ebp-8],0 ;set 'x' to 0 mov word[ebp-6],0 ;set 'y' to 0 mov word[ebp-4],32;set 'w' to 32 mov word[ebp-2],32;set 'h' to 32 .data InArr: .word 0x0eeeeeee .text .globl main main: # li $s2,0x0eeeeeee li $s3,0 # loop: ror $s2,$s2,4 # $s2 = $s2 >>4 sw $s2,InArr # InArr(0) = $s2 #addi $s2,$s2,4 bne $s2,$s3,loop # until i==0 # li $v0,10 # System(exit) syscall .data InArr: .word 0x0eeeeeee .text .globl main main: # li $s2,0x0eeeeeee li $s3,0 # loop: ror $s2,$s2,4 # $s2 = $s2 >>4 sw $s2,InArr # InArr(0) = $s2 #addi $s2,$s2,4 bne $s2,$s3,loop # until i==0 # li $v0,10 # System(exit) syscall #include void printInt(int printable){ std::cout