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

My Pitt Home sponsorship contact \" Mail ATM5a@pitte × / D Lab3.pdf ewnte A Prog

ID: 3869699 • Letter: M

Question

My Pitt Home sponsorship contact " Mail ATM5a@pitte × / D Lab3.pdf ewnte A Program w D MIPS Assembly Lan,x × × (--> d Secure | https://coursewebpitt.edu/bbcswebdav/pid-240501 70-dt-content-rid-21925618 2/courses/2181 UPITT CS 0447 SEC1070/Lab3.pdf Lab3.pdf Question 6: Is Mars simulator a small-Endian or a big-Endian? Save your answers to a .en file nd submtt it as "First name-Last name-A-text" on courseWeb B. Bit Manipulation Read an integer A from a user, and place it in register Sa. Recall that the 32 bits in a word are counted trom bit D, which is the right-nost or least significant bit (LSB), to bit 31, which is the left- most or most significant bit (MSB) Now, set register Stl to contain only bits 8, 9, 10, and I of A. That is, the LSB of Stl should contain bit 8 from A, the second least significant bit of Stl should contain bit 9 from A, etc. Then return the resulting number as output to the user For example, say your input integer is 985980. This corresponds to 0x000f0b7c in hex, which 0000 0000 00001111 0000 1011 011 1100 in binary. If you isolate bit 4,5,6 and 7 (which are underlined above) and move them to the least significant bits of St1, you will get 0x00000007 Here are some sample executions for your program Please enter your integer: 985980 Here is the output:7 Please make sure your output lines contain the string "Here is the output:" as shown in the sample output Tips: You should be able to accomplish the bit manipulation using at most one shift instruction (eg, sil srl, sra) and one logical instruction (e.g., andi, ori, xori, etc.) There are other ways of accomplishing the same manipulation that may use more instructions, or others altogether, but you should make your program as minimal as you can. Save your answer as "First name_Last mame B.asm" C. Multiplication Calculator 5:21 PM lype here to search e@[ % 26%

Explanation / Answer

Given below is the program to extract bits 4, 5 , 6 ,7 and display after shiftng them to LSB.

Hope the answer helps. If it did, please don't forget to rate the answer. Thank you.


.data
prompt: .asciiz "Please enter your integer: "
msg: .asciiz "Here is the output: "
  
.text
#prompt the user
li $v0, 4
la $a0, prompt
syscall
#get the int input and store it in $t0
li $v0, 5
syscall
move $t0, $v0
  
#To extract bits 4, 5 ,6 and 7 (count from LSB i.e right end), the corresponding bits should be 1 and rest 0
#i.e 0000 0000 0000 0000 0000 0000 1111 0000
#this value in hex is 0x000000F0
#after performing AND of input value with this hex value we have the bits extracted
#after extracting these bits we need to shift it 4 bits to right using srl 4 so that these bits start from LSB
  
and $t1, $t0, 0x000000F0 #extract bits 4 5 6 and 7 using hexa value and store the extracted bits in t1
srl $t1, $t1, 4 #shift 4 bits to right
  
#dispaly the results
li $v0, 4
la $a0, msg
syscall
  
li $v0, 1
move $a0, $t1
syscall
#exit
li $v0, 10
syscall

output

Please enter your integer: 985980
Here is the output: 7

Note: The question once mentions about extracting bits 8, 9 , 10, and 11 . But it shows example of extracting bits 4 , 5 , 6, 7 and the sample output shown in question is that of bits ,4, 5, 6 and 7. In case you wanted to extract bits 8 , 9 , 10 and 11 instead of 4, 5, , 6, and 7,

the binary representation is 0000 0000 0000 0000 0000 1111 0000 0000

Its equivalent hex value is 0x00000F00

So if you were to extract bits 8, 9 , 10 and 11 , then the only change in the program is to the change the hex value used to do AND operation . Change it from 0x000000F0 to 0x00000F00

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote