a3 (1)
.pdf
keyboard_arrow_up
School
University of Regina *
*We aren’t endorsed by this school
Course
201
Subject
Computer Science
Date
Jan 9, 2024
Type
Pages
1
Uploaded by DrBook9814
CS 201-001 Assignment 3
Question 1.
Write the machine code corresponding to the following MIPS assembly code
in binary:
(a). add
$
t4,
$
s2,
$
t8
(b). addi
$
s4,
$
zero, 19
(c). jr
$
s2
Question 2.
Find the corresponding MIPS instruction to the following machine code. You
are given that any immediate value is represented using 2’s complement.
(a). 0011010101010111 1111111111111111
(b). 0001001000010001 0000000000000011, where:
PC = 0x0000 0078,
and there are three labels in the program that have address as follows:
label1 = 0x0000 0084,
label2 = 0x0000 0088, and
label3 = 0x0000 008C
Question 3.
Translate the following code to MIPS.
if
$
s0
>
0
then
$
s0 =
$
s0 - 1
else
$
s0 =
$
s0 + 1
Question 4.
There is a value stored in
$
s0. Write a sequence of MIPS instructions that
will place the absolute value of
$
s0 into
$
t0.
Question 5.
You are given a memory data segment labeled “cs201”. Write an assembly
language program to find the sum of the first 100 words data in the memory data segment
labeled cs201. Store the resulting sum in
$
s0.
Question 6.
Write a function fact(n) to compute and return the factorial of n.
The
function must use recursion. The value of n is passed in
$
a0 and the factorial is returned in
$
v0. Don’t forget to save and restore any register that you might need before using it.
1
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Please complete the binary encoding for the following BL
instruction at address Ox2000 using the given information.
Please write the answer in a group of four bits as follows: 0010
0010 0010 1100.
Address
Instructions
0x2000
bl sub
0x2004
add r3, r2, r1
0x2008
sub r6, r5, r3
sub: stmfd r13!, {r0-r12,
0X200C
r14]
0x2010
add r7, r2, r5
Ox2014
mov r3, r2
arrow_forward
Assemble the following code snippet into MIPSS binary, represented as hexadecimal numbers, one line for each instruction, assuming that the
label exit is at address 0x0040001C.
and $t0, $s3, $s2
ori $t0, $t0,
lw $t1, 24($s0)
sub $t3, $t1, $s1
slti $t9, $t3, 234
bne $t9, $zero, exit
j loop
lui
2
loop:
0x1234
4
6.
7
8.
9.
exit:
$t0, 0x543
You must show the HOW part, i.e. how do you come up with the opcode and other parts of the instruction for each instruction to get full credit.
You will get no credit if you just show the binary, as that can be done easily with MARS,
arrow_forward
The "Add immediate unsigned" MIPS instruction: addi Rt, Rs, Imm
requires the immediate field to be extended from 16 bits to 32 bits.
If the value of the immediate field is: 1111000011110000
what will be the sign extended value of this field from 16 bits to 32 bits?
Choose the best answer.
01111111111111111111000011110000
O 11111111111111111111000011110000
O This is a trick question. You cannot sign extend a negative number
O 00000000000000001111000011110000
10000000000000001111000011110000
This is a trick question. You cannot sign extend a positive number
arrow_forward
5. Trace the following RISC-V code and give the result of each instruction.
Assume: x10=80700cd34fe32222, x5=f2780cd300e32002, x6=00d0300355231133,
xl1=00222eell113feed
And part a doesn't affect part b
а. addi x30, x10, 8
addi x31, x10, 0
sd x31, 0(x30)
Id x30, 0(x30)
add x5, х30, х31
b. sli x30, x5, 3
add x30, x10, х30
slli x31, x6, 3
add x31, x11, х31
Id x5, 0(x30)
addi x12, x30, 8
Id x30, 0(x12)
add x30, х30, х5
sd x30, 0(x31)
arrow_forward
Discussion:
1. Two bytes - sized BCD integers are stored at the symbolic addresses
NUMI and NUM2 respectively. Write an instruction sequence to generate
their difference and store it at NUM3. The difference is to be formed by
subtracting the value at NUM2 from that at NUMI.
arrow_forward
Q2- Write a program in assembly language for the 8085 microprocessor to receive one byte of data via the SID and store it at the memory address (3000H to 3009H) using a baud rate of 1200.
Information: The 8085 processor operates at a frequency of 3.072 MHz . When receive the required bytes, you must adhere to the following: The bits of two high bits will be received at the beginning of the reception(start bits 1 1 ), after that the data bits will be received, after that the low bit of the stop bit will be received (stop bit 0 ).
The following flowchart will help you.
The solution must be integrated and include the calculation of the baudrate delay time
arrow_forward
Design a binary multiplier that multiplies two 8-bit binary number by following design rules that
shown in class. The Q and B are the two separate 8-bit binary inputs, C is the 3-bit sequence counter
and R is the 16-bit result. (Note: Explain the registers that you will use to establish given process.)(Hint:
Morris Mano, Computer System Architecture, Chapter 10.6.)
QxB
B
Clock
Start
-Busy/Ready
arrow_forward
please translate those mips codes to the machine codes
arrow_forward
Complete the following table:
MIPS
Instruction
op
code
rs
rt
rd
shamt
funct
imm.
/address
Hexadecimal
Representation
add $t4, $s2, $s1
addi $s0, $t0, 123
lw $s6, -88($t7)
Note: In MIPS register file, temporary registers $t0-$t7 have indices 8-15 (respec- tively). Also, the saved registers $s0-$s7 have indices 16-23 (respectively).
arrow_forward
8
arrow_forward
Q1- Write a program in assembly language for the 8085 microprocessor to receive 10 bytes of data via
the SID and store it at the memory address (3000H to 3009H) using a baud rate of 1200.
Information: The 8085 processor operates at a frequency of 3.072 MHz. When you receive each byte of
the required bytes, you must adhere to the following: The bits of two high bits will be received at the
beginning of the reception (start bits), after that the data bits will be received, after that the low bit of
the stop bit will be received (stop bit).
The following flowchart will help you, but you should notice that this flowchart deals with one byte, and
you are required to deal with 10 bytes
The solution must be integrated and include the calculation of the baudrate delay time
Of+CD!HID+[00
Yes
SIDATA
Read SID
Start
Bit?
Wait for
Half-Bit Time
Set up Bit
Counter
Wait Bit Time
Read SID
Save Bit
Decrement Bit
Counter
All Bits
Received?
Add Bit to
Previous Bits
Go Back to
Get Next Bit
Return
IMUNI
arrow_forward
I have been searching in my textbook and could not find anything to help me solve this problem. Could anyone help me please?
Registers in RISC-V are 64-bit. For the sake of simplicity, consider the following instructions operating on 32-bit registers. Assume that registers x5 and x6 hold the values 0xBBBBBBBB and 0x00000000, respectively.
What is the value in x6 for the followingslli x6, x5, 6
Using the result from the part above, what is the value in x6 for the following instruction.srli x6, x6, 6
arrow_forward
i need the answer quickly
arrow_forward
Write down the binary and the hexadecimal values of the following and MIPS instruction. Consider the correct values of opcode table and Register File from the tables. The registers size is 5-bit.
arrow_forward
For the following C statement, write the corresponding RISC-V assembly code. Assume that the base addresses of long long int arrays A and B are in registers x6 and x7 respectively. Each element of A or B is 8 bytes, and the variables i and j are assigned to registers x5 and x10 respectively. j = B[A[i*2]] - 16;
arrow_forward
Discussion:
1. Two bytes sized BCD integers are stored at the symbolic addresses
NUMI and NUM2 respectively. Write an instruction sequence to generate
their difference and store it at NUM3. The difference is to be formed by
subtracting the value at NUM2 from that at NUM1.
arrow_forward
2. Memory contents (in hexadecimal) are 0005, 0001, 0123 for addresses 000 to 002, then 2002,
1000, 7800, F400 for addresses 80A through 80D. AC starts with value 0F24, PC has the value
80A, and AR has the value 4F5. Starting with time-step T0, describe what happens until
the next TO. Make sure to indicate any updated register values as they happen. (Assume
R= 0.)
Refer to table 5.6 from Mano's textbook.
F24
1
AR
arrow_forward
You need to write in hexadecimal (E.g: OX00114A63) for the following RISC-V assembly
instruction:
sub ra,gp,t1
* WARNING: You MUST write the Ox followed by the 8 hexadecimal digits all in UPPER
case. If needed, add extra zeroes to have the 8 digits (this is auto graded, so no spaces,
underscores or lower case). In the previous hexadecimal example Ox00114a63 is incorrect,
OX114A63 is also incorrect, and 00114A63 is also incorrect. Only OX00114A63 is correct.
arrow_forward
Convert the given hex value to its R-format MIPS
instruction by completing the following table. The
instruction and letters for registers must be in lower
case. DO NOT TYPE DOLLAR SIGNS WITH REGISTERS.
Hex
Opcode
(decimal)
rs (decimal)
rt (decimal)
rd (decimal)
funct (decimal)
Instruction
02488822
O
18
16
17
34
sub
s4
$$1
"
$ to
"
LA
arrow_forward
3. For each instruction in the table, write 8 hexadecimal digits that represent the 32 bits in the
destination register after the instruction is executed. Assume s0 is 0x98AB3C6A, s1 is
0x20503666.
Instructions
to, 50, s1
t1, so, s1
t2, so, s1
t3, 50, 51
addi t4, 50, 0x210
wwwwwww
andi t5, 50, -16
add
and
or
xor
slli t6, 50, 12
srai s2, 50, 8
Dest. reg. in 8 hexadecimal digits
arrow_forward
Pls answer the following question from the picture
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Related Questions
- Please complete the binary encoding for the following BL instruction at address Ox2000 using the given information. Please write the answer in a group of four bits as follows: 0010 0010 0010 1100. Address Instructions 0x2000 bl sub 0x2004 add r3, r2, r1 0x2008 sub r6, r5, r3 sub: stmfd r13!, {r0-r12, 0X200C r14] 0x2010 add r7, r2, r5 Ox2014 mov r3, r2arrow_forwardAssemble the following code snippet into MIPSS binary, represented as hexadecimal numbers, one line for each instruction, assuming that the label exit is at address 0x0040001C. and $t0, $s3, $s2 ori $t0, $t0, lw $t1, 24($s0) sub $t3, $t1, $s1 slti $t9, $t3, 234 bne $t9, $zero, exit j loop lui 2 loop: 0x1234 4 6. 7 8. 9. exit: $t0, 0x543 You must show the HOW part, i.e. how do you come up with the opcode and other parts of the instruction for each instruction to get full credit. You will get no credit if you just show the binary, as that can be done easily with MARS,arrow_forwardThe "Add immediate unsigned" MIPS instruction: addi Rt, Rs, Imm requires the immediate field to be extended from 16 bits to 32 bits. If the value of the immediate field is: 1111000011110000 what will be the sign extended value of this field from 16 bits to 32 bits? Choose the best answer. 01111111111111111111000011110000 O 11111111111111111111000011110000 O This is a trick question. You cannot sign extend a negative number O 00000000000000001111000011110000 10000000000000001111000011110000 This is a trick question. You cannot sign extend a positive numberarrow_forward
- 5. Trace the following RISC-V code and give the result of each instruction. Assume: x10=80700cd34fe32222, x5=f2780cd300e32002, x6=00d0300355231133, xl1=00222eell113feed And part a doesn't affect part b а. addi x30, x10, 8 addi x31, x10, 0 sd x31, 0(x30) Id x30, 0(x30) add x5, х30, х31 b. sli x30, x5, 3 add x30, x10, х30 slli x31, x6, 3 add x31, x11, х31 Id x5, 0(x30) addi x12, x30, 8 Id x30, 0(x12) add x30, х30, х5 sd x30, 0(x31)arrow_forwardDiscussion: 1. Two bytes - sized BCD integers are stored at the symbolic addresses NUMI and NUM2 respectively. Write an instruction sequence to generate their difference and store it at NUM3. The difference is to be formed by subtracting the value at NUM2 from that at NUMI.arrow_forwardQ2- Write a program in assembly language for the 8085 microprocessor to receive one byte of data via the SID and store it at the memory address (3000H to 3009H) using a baud rate of 1200. Information: The 8085 processor operates at a frequency of 3.072 MHz . When receive the required bytes, you must adhere to the following: The bits of two high bits will be received at the beginning of the reception(start bits 1 1 ), after that the data bits will be received, after that the low bit of the stop bit will be received (stop bit 0 ). The following flowchart will help you. The solution must be integrated and include the calculation of the baudrate delay timearrow_forward
- Design a binary multiplier that multiplies two 8-bit binary number by following design rules that shown in class. The Q and B are the two separate 8-bit binary inputs, C is the 3-bit sequence counter and R is the 16-bit result. (Note: Explain the registers that you will use to establish given process.)(Hint: Morris Mano, Computer System Architecture, Chapter 10.6.) QxB B Clock Start -Busy/Readyarrow_forwardplease translate those mips codes to the machine codesarrow_forwardComplete the following table: MIPS Instruction op code rs rt rd shamt funct imm. /address Hexadecimal Representation add $t4, $s2, $s1 addi $s0, $t0, 123 lw $s6, -88($t7) Note: In MIPS register file, temporary registers $t0-$t7 have indices 8-15 (respec- tively). Also, the saved registers $s0-$s7 have indices 16-23 (respectively).arrow_forward
- 8arrow_forwardQ1- Write a program in assembly language for the 8085 microprocessor to receive 10 bytes of data via the SID and store it at the memory address (3000H to 3009H) using a baud rate of 1200. Information: The 8085 processor operates at a frequency of 3.072 MHz. When you receive each byte of the required bytes, you must adhere to the following: The bits of two high bits will be received at the beginning of the reception (start bits), after that the data bits will be received, after that the low bit of the stop bit will be received (stop bit). The following flowchart will help you, but you should notice that this flowchart deals with one byte, and you are required to deal with 10 bytes The solution must be integrated and include the calculation of the baudrate delay time Of+CD!HID+[00 Yes SIDATA Read SID Start Bit? Wait for Half-Bit Time Set up Bit Counter Wait Bit Time Read SID Save Bit Decrement Bit Counter All Bits Received? Add Bit to Previous Bits Go Back to Get Next Bit Return IMUNIarrow_forwardI have been searching in my textbook and could not find anything to help me solve this problem. Could anyone help me please? Registers in RISC-V are 64-bit. For the sake of simplicity, consider the following instructions operating on 32-bit registers. Assume that registers x5 and x6 hold the values 0xBBBBBBBB and 0x00000000, respectively. What is the value in x6 for the followingslli x6, x5, 6 Using the result from the part above, what is the value in x6 for the following instruction.srli x6, x6, 6arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning