Write a MIPS assembly language program that prompts a user for a positive decima
ID: 3573446 • Letter: W
Question
Write a MIPS assembly language program that prompts a user for a positive decimal integer, reads the integer typed by the user and outputs the following values. The total number of 1's in the left half of the binary representation of the integer The total number of 0's in the right half of the binary representation of the integer The highest power of 2 that evenly divides the integer The value of the smallest digit in the decimal representation of the integer. Recall that each integer is represented using 32 bits in MIPS. Suppose the user types the integer 1536. The 32-bit binary representation of 1536 is 0000 0000 0000 0000 0000 0110 0000 0000 The output answer is as follows: The number of 1's in the left half of the binary representation of the given integer = 0 The number of 0's in the right half of the binary representation of the given integer = 14 The largest power of 2 that evenly divides the given integer = 9 (the largest power of 2 that evenly divides 1536 is 9) Program outline: a) Prompt the user for a positive integer. b) Read the integer c) Computer the four quantities mentioned above (1, 2, 3, 4) and print the answers d) Stop. You are to include that when the program is executed only one integer is allowed to be handled.Explanation / Answer
Hii there this may help you out,
8086 ASSEMBLY PROGRAM TO COUNT NUMBER OF 0’S AND 1’S FROM A NUMBER
DATA SEGMENT
NO DW 5648H
Z DW ?
O DW ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
MOV AX, NO
MOV BX, 00H
MOV CX, 10H
MOV DX, 00H
UP:
ROL AX,1
JC ONE
INC BX
JMP NXT
ONE:
INC DX
NXT:
DEC CX
JNZ UP
MOV Z, BX
MOV O, DX
INT 3
CODE ENDS
END START
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.