-Pseudoinstructions Give an example of: 1) a pseudo-instruction, 2) which core i
ID: 3620892 • Letter: #
Question
-PseudoinstructionsGive an example of: 1) a pseudo-instruction, 2) which core instruction(s) MARS translate it into, and 3) why it works
Explanation / Answer
Dear, 1) The MIPS assembler supports several pseudoinstructions Programmers can use pseudo-instructions Assembler translates them into actual instructions or sequences of instructions Example move $7,$18 contents of $18 are copied to $7 is translated into add $7, $18, $0 Remember: $0 always contains 0 bgez $s0, else # if ($s0 is > or = zero) branch to else seq, sle, la, li, etc example program: bgez $s0, else # if ($s0 is > or = zero) branch to else sub $t1, $zero, $s2 # $t1 gets the negative of $s2 b next # branch around the else code else: bne $t1, $s2, next # if ($t1 s2) branch to next addi $t2, $t2, 1 # otherwise if it equals increment t2 by 1 next: 2)When assembly programs try to destroy each other in the memory of a simulated computer, then the programs are written in a special language called Redcode, and run by a program called MARS (Memory Array Redcode Simulator). The MARS executes one instruction at a time, and then proceeds to the next one in the memory, unless the instruction explicitly tells it to jump to another address MOV -- move (copies data from one address to another) ADD -- add (adds one number to another) SUB -- subtract (subtracts one number from another) MUL -- multiply (multiplies one number with another) DIV -- divide (divides one number with another) MOD -- modulus (divides one number with another and gives the remainder) JMP -- jump (continues execution from another address) JZ -- jump if zero (tests a number and jumps to an address if it's 0) JNZ -- jump if not zero (tests a number and jumps if it isn't 0) CMP--compare 3) MARS environment are much simplified and abstracted compared to ordinary computer systems. It is easy to understand for the users while designing of programmingRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.