a6-2004-37957-pseudo-instructions
pdf
keyboard_arrow_up
School
University of Regina *
*We aren’t endorsed by this school
Course
201
Subject
Electrical Engineering
Date
Jan 9, 2024
Type
Pages
8
Uploaded by DrBook9814
Studocu is not sponsored or endorsed by any college or university
A6 2004 37957 -
pseudo-instructions
Introduction to Digital Systems (University of Regina)
Studocu is not sponsored or endorsed by any college or university
A6 2004 37957 -
pseudo-instructions
Introduction to Digital Systems (University of Regina)
Downloaded by black pearl (bp6735254@gmail.com)
lOMoARcPSD|21438098
NAME: KHUSHIBEN PIYUSHBHAI PATEL
STUDENT ID: 200437957
ASSIGNMENT NO: A6
Task 1
The following are some additional pseudo-instructions that one could define in the assembly
system that we have discussed. For each of them, give one or more real assembly instructions
to perform the expected operation. Remember: pseudo-instructions cannot modify any
registers except the specified $rd and $pc for branch/jump (where applicable), but pseudo
instructions may rely on $at for intermediate results. Provide short description of the
potential use of each listed pseudo-instruction below.
Answer:
A). xchg $rt, o[$rs]
#swap the memory in M[$rs+o] with $rt
.xchg : use to changes data between to operands.
$rt : A second type register in R-type instruction
$rs : used first source register
MIPS assembly instruction:
Sub $at, $rt, $0
lw $rt, 0 [$rs]
sw $at, 0 [$rs]
B). slld $rs,$rt,shamt
#Shift the double word rs:rt left by shamt
Slld : used for shift left register
$rt: A second type register in R-type of instruction
$rs: is source register and used for first source register
Shamt : it is used to shift two operands.
MIPS assembly Instruction:
Slr $at,rt, 32-shamt
Sll $rs,rs, shamt
Downloaded by black pearl (bp6735254@gmail.com)
lOMoARcPSD|21438098
Sll $rs,$rs,$at
C). double $rd, $rs
#$rd = 2x($rs)
Double: store data in 8 memory location
$rt: A second type of register in R-type of instruction
$rs : is first source register and used for first source register
Li: li means load the
immediate value, immediate values are 16-bits.
Bgt: bgt means branching pseudo instruction
Blt: blt means branching pseudo instruction
Sll : sll means shift left register
MIPS assembly instruction:
li $at, 0x3FFF
bgt $rs, $at, ERRORHANDLER
li $at, 0xC000
blt $rs,$at, ERRORHANDLER
sll $rd,$rs,1
D). triple $rd, $rs
#$rd = 3x($rs)
triple: store data in 12 memory locations
$rt: A second type of register in R-type of instruction
Li: li means load the immediate value, immediate values are 16-bits
Bgt : bgt means branching pseudo instruction
Blt: blt means branching pseudo instruction
Sll : sll means shift left register
Add: add $rs and 1, and stored the result in $rd
MIPS assembly instruction:
Li $at, 03xFFF
Bgt $rs,$at, ERRORHANDLER
Downloaded by black pearl (bp6735254@gmail.com)
lOMoARcPSD|21438098
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Li $at, 0xC000
Blt $rs, $at, ERRORHANDLER
SLL $at,$rs,1
Add $rd,$rs,1
E). mulacc $rd, $rs, $rt
#$rd = ($rd)+($rs)x($rt)
$rs:is first source register and used for first source
register
$rt: A second type of instruction
$rd: destination register
MIPS assembly instruction:
mul $rs,$rt
mflo $at
add $rd,$rd,$at
Task 2
Write a MIPS program to demonstrate the operation of the following switch statement:
switch (S) { case 5: A = A + 1; break; case 25: A = A - 1; break; default: A = A * 2; break; }
Implement and simulate your solution. Allocate .data locations for the variables S and A, and
load these values into registers before performing the switch statement on the registers. Run
your program several times with different values for these variables, to ensure that your
program works as expected. Make sure that your program prompts the user for the values of
S and A and displays results of the computation to the user.
Answer:
1.
Source code in a readable, well-formatted (tabulated, commented) way
.text
.globl __start
__start:
# execution starts here
#print string
li $v0,4
la $a0,inputS
Downloaded by black pearl (bp6735254@gmail.com)
lOMoARcPSD|21438098
syscall
#read int and save to S
li $v0,5
syscall
sw $v0,S
#print string
li $v0,4
la $a0,inputA
syscall
#read int and save to A
li $v0,5
syscall
sw $v0,A
lw $t1,S
lw $t2,A
switch:
beq $t1,5,case5
beq $t1,25,case25
beq $t1,50,default
case5:
add $t2,$t2,1
b end_switch
case25:
sub $t2,$t2,1
b end_switch
default:
mul $t2,$t2,2
Downloaded by black pearl (bp6735254@gmail.com)
lOMoARcPSD|21438098
b end_switch
end_switch:
sw $t2,A
#display value of A
li $v0,4
la $a0,ans1
syscall
move $a0,$t2
li$v0,1
syscall
la $a0,endl
# syscall to print out
li $v0,4
# a new line
syscall
#exit
li $v0,10
syscall
.data
S: .word 0
A: .word 0
inputS: .asciiz "Enter values of S:"
inputA: .asciiz "Enter values of A:"
ans1:
.asciiz "Now the value of A="
endl: .asciiz "\n"
##
Screenshot of PC SPIM showing the emulator with your code successfully loaded
Downloaded by black pearl (bp6735254@gmail.com)
lOMoARcPSD|21438098
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Screenshots of PC SPIM console displaying the results of running your program with the
following test inputs:
1. S = 5 ; A = 1
2.
S = 25; A = 2
Downloaded by black pearl (bp6735254@gmail.com)
lOMoARcPSD|21438098
3. S = 50; A = 3
Downloaded by black pearl (bp6735254@gmail.com)
lOMoARcPSD|21438098
Related Documents
Related Questions
Digital Electronics
Are these complete answers? I want complete
arrow_forward
Question iii please help......
arrow_forward
The numbers from 0-9 and a no characters
is the Basic 1 digit seven segment display
* .can show
False
True
In a (CA) method of 7 segments, the
anodes of all the LED segments are
* "connected to the logic "O
False
True
Some times may run out of pins on your
Arduino board and need to not extend it
* .with shift registers
True
False
arrow_forward
An 8085 assembly language program is given below.
Line 1: MVI A, B5H
2: MVI B, OEH
3: XRI 69H
4: ADD B
5: ANI 9BH
6: CPI 9FH
7: STA 3010H
8: HLT
The contents of the accumulator just execution of the ADD instruction in line
4 will be
arrow_forward
2) Perform the following conversions:
dont use others answers
show yiur work step by step
arrow_forward
Answer the D, E and F part
arrow_forward
Please answer in typing format
arrow_forward
Identify what type of Finite State Machine would be required to implement the given
sequence:
=01011100100010010010
00000000010000001001
Mealy FSM
Moore FSM
OShannon FSM
arrow_forward
Without using the MUL instruction, give instructions that multiply register r4 by:
a)69
b)16385
arrow_forward
QUESTION i please help........
arrow_forward
Which of the following is true about quantization?
a. Actual quantization error is the same all throughout the process.b. The signal to noise ratio is the same all throughout the quantization process.c. The smaller the resolution the less quantization error is introducedd. All of the choices
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you

Related Questions
- Digital Electronics Are these complete answers? I want completearrow_forwardQuestion iii please help......arrow_forwardThe numbers from 0-9 and a no characters is the Basic 1 digit seven segment display * .can show False True In a (CA) method of 7 segments, the anodes of all the LED segments are * "connected to the logic "O False True Some times may run out of pins on your Arduino board and need to not extend it * .with shift registers True Falsearrow_forward
- An 8085 assembly language program is given below. Line 1: MVI A, B5H 2: MVI B, OEH 3: XRI 69H 4: ADD B 5: ANI 9BH 6: CPI 9FH 7: STA 3010H 8: HLT The contents of the accumulator just execution of the ADD instruction in line 4 will bearrow_forward2) Perform the following conversions: dont use others answers show yiur work step by steparrow_forwardAnswer the D, E and F partarrow_forward
- Please answer in typing formatarrow_forwardIdentify what type of Finite State Machine would be required to implement the given sequence: =01011100100010010010 00000000010000001001 Mealy FSM Moore FSM OShannon FSMarrow_forwardWithout using the MUL instruction, give instructions that multiply register r4 by: a)69 b)16385arrow_forward
- QUESTION i please help........arrow_forwardWhich of the following is true about quantization? a. Actual quantization error is the same all throughout the process.b. The signal to noise ratio is the same all throughout the quantization process.c. The smaller the resolution the less quantization error is introducedd. All of the choicesarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
