Write a MIPS assembly code program that asks the user to enter an unsigned number and read it. Then swap the bits at odd positions with those at even positions and display the resulting number. For example, if the user enters the number 9, which has binary representation of 1001, then bit 0 is swapped with bit 1, and bit 2 is swapped with bit 3, resulting in the binary number 0110. Thus, the program should display 6.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Write a MIPS assembly code program that asks the user to enter an unsigned number and read it. Then swap the bits at odd positions with those at even positions and display the resulting number. For example, if the user enters the number 9, which has binary representation of 1001, then bit 0 is swapped with bit 1, and bit 2 is swapped with bit 3, resulting in the binary number 0110. Thus, the program should display 6
Example of the MIPS assembly code I went the answer on  MIPS Code only!!!!

Steps for program:
Step 1:
Open the MIPS code
Step 2:
Locate the code containing lowercase and vice versa. The numbers
are used to represent letters.For example, letters "a" to "i" are
represented by numbers from 61 to 69. The letters "j" through "o"
are represented by 6A to 6F. The letters "p" through "y" are
represented by 70 to 79. The letter z is represented by 7A.
Program :
.data
lower: .ascii "aaaa"
upper: .ascii "xxxx"
.text
loop:
Ib $t1, lower($t0)
beq $t1, 0, exit
sub $t1, $t1, 32
sb $t1, lower($to)
add $t0, $t0, 1
j loop
Ib $t1, upper($t0)
beq $t2, 0, exit
sub $12, $t2, 32
sb $t2, upper($to)|
add $t0, $t0, 2
j loop
exit :
Iw $t1, lower
sw $t2, upper
li $v0, 10
syscal
Programming in assembly language is easy for memory swapping and
memory related purposes.
Transcribed Image Text:Steps for program: Step 1: Open the MIPS code Step 2: Locate the code containing lowercase and vice versa. The numbers are used to represent letters.For example, letters "a" to "i" are represented by numbers from 61 to 69. The letters "j" through "o" are represented by 6A to 6F. The letters "p" through "y" are represented by 70 to 79. The letter z is represented by 7A. Program : .data lower: .ascii "aaaa" upper: .ascii "xxxx" .text loop: Ib $t1, lower($t0) beq $t1, 0, exit sub $t1, $t1, 32 sb $t1, lower($to) add $t0, $t0, 1 j loop Ib $t1, upper($t0) beq $t2, 0, exit sub $12, $t2, 32 sb $t2, upper($to)| add $t0, $t0, 2 j loop exit : Iw $t1, lower sw $t2, upper li $v0, 10 syscal Programming in assembly language is easy for memory swapping and memory related purposes.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY