This assignment is designed to introduce you to using memory,
input/output syscalls and if statements
a. Open the text editor and type in the following. Then save your
work as “assign3.asm”. Note that there are
3 words of memory indicated that start at the address 0x10010000.
Do not use labels in the data segment.
.data
.word 0
.word 0
.word 0
.globl main
.text
main:
b. Add the following zero terminated ascii strings (.asciiz) to the
data segment right above the .globl directive
(after the .word directives).
1. Your name
2. “Enter a number “
3. “\n”
c. Add the MIPS assembly language instructions (after main:) to
complete the following (in this order). Do
not skip steps. Use other registers as needed.
Actions:
1. Prompt the user to enter a number, read the number and then put
it into memory at address
0x10010000
2. Prompt the user to enter a number, read the number and then put
it into memory at address
0x10010004
3. Compare the two numbers and place the larger value into memory
at address 0x10010008
4. Print the following output each on its own line. You will need
to determine the location of each of the
strings from the beginning of the memory segment.
a. Your name
b. The value in address 0x10010000
c. The value in address 0x10010004
d. The value in address 0x10010008
Specifics:
• Use only the instructions covered to date plus the
syscalls.
• Stop the program by using a syscall with the command 10.
• Test, test, test!!!!! The results in the memory and the output
must be correct at the end of the
execution.
Documentation:
• Comment the beginning of your programs with your name, class ID,
and assignment number.
• Comment every instruction.
Assignment 3 submittal:
• Upload your assembly language program (.asm file) using the link
on the website.
• Be sure to click on the submit button.
Screenshot
-----------------------------------------------------------------------------------------------------------------------
Program
#Declaration
.data
.word 0
.word 0
.word 0
.asciiz "Your name"
.asciiz "Enter number "
.asciiz "\n"
.globl main
.text
main:
#Prompt for first number
addi $v0,$0,4
addi $a0,$0,0x00000016
syscall
#Read first number
addi $v0,$0,5
syscall
#Save into memory
addi $t0,$0,0x00000000
sw $v0,($t0)
#Prompt for second number
addi $v0,$0,4
addi $a0,$0,0x00000016
syscall
#Read number
addi $v0,$0,5
syscall
#Store into memory
addi $t0,$0,0x00000004
sw $v0,($t0)
#First value in to
addi $a0,$0,0x00000000
lw $t0,($a0)
#Compare
bgt $t0,$v0,saveFirst
addi $t2,$0,0x00000008
#Second value large in third word
sw $v0,($t2)
#Go to print section
j print
#Save first value in third word
saveFirst:
addi $t2,$0,0x00000008
sw $t0,($t2)
#Display values
print:
#Display "\n"
addi $v0,$0,4
addi $a0,$0,0x00000024
syscall
#Display name
addi $v0,$0,4
addi $a0,$0,0x0000000c
syscall
#Display "\n"
addi $v0,$0,4
addi $a0,$0,0x00000024
syscall
#Display first value
add $a0,$0,$t0
addi $v0,$0,1
syscall
#Display "\n"
addi $v0,$0,4
addi $a0,$0,0x00000024
syscall
#Display secon value
addi $t0,$0,0x00000004
lw $a0,($t0)
addi $v0,$0,1
syscall
#Display "\n"
addi $v0,$0,4
addi $a0,$0,0x00000024
syscall
#Display largest number
addi $t0,$0,0x00000008
lw $a0,($t0)
addi $v0,$0,1
syscall
#End of the program
addi $v0,$0,10
syscall
-------------------------------------------------
Output
Enter number 4
Enter number 5
Your name
4
5
5
This assignment is designed to introduce you to using memory, input/output syscalls and if statements a....
(USING THE PROGRAM MARS) Using the MemoryAccess program we wrote in class as a starting point, write a program called LoadStore # Title : Memory access.asm #Desc: Practice initially memory, #in val1 = 0x0a; #int val2 = 0x0b; #int result; #string resultstring = " final answer : "; #string returnchar = "\n"; #void main() { # result = val1 + val2; # cout<<< resultstring << returnchar; #} .data val1: .word 0x0a #store 0xa into variable val1 val2: .word 0x0b #store...
Introduction: In this lab, you will write a MIPS program to read in (up to) 50 integer values from the user, store them in an array, print out the amay, one number per line, reverse the elements in the array and finally print out the elements in the just-reversed) array. Feel free to do this lab and all assembly programming labs) in Windows. You must use MARS Getting started: l. In MARS, create a new assembly file with the name...
Hello, I'm having trouble completing this program in less than four lines using MIPS programming language, we are required to fill in the missing code as indicated (via comments). IMPORTANT: As indicated in the program's comments: ⇒ Write no more than certain number of lines of code as indicated. (One instruction per line, and there will be penalty if your code consumes more lines.) ⇒ Code MUST use only instructions that are allowed i.e., only bit manipulating instructions: (ANDing, ORing,...
# ECE 445 Computer Organization # Homework 3, problem 9 # Write a MIPS assembly language program to count the number of positive values in an array of integers. # The array of integers and the array length are provided in the .data section below. # After running your code, the variable count (in memory) should contain the number of positive values in the array Insert your name here > Insert the date here > # Author: # Date: .text...
X86 Assembly language lab: TITLE Lab 3: assembly language fundamentals ;;;;; Q1: Don't forget to document your program ; Name:Yuyan Wang ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;; Answer each question below by writing code at the APPROPRIATE places in the file. ;;;;; Hint: the appropriate place is not always right below the question. ;;;;; Q2: Write the directive to bring in the IO library ;;;;; Q3: Create a constant called MAX and initialize it to 150...
Write a complete MIPS assembly language program that implements the following pseudocode. program h2 define global integer variables w, x, y, z -- in the .data section function main() SysPrintStr("Enter an integer >= 0 for w? ") w ← SysReadInt() SysPrintStr("Enter an integer >= 0 for x? ") x ← SysReadInt() SysPrintStr("Enter an integer < 0 for y? ") y ← SysReadInt() z ← 16(w + x) - (3 × -y mod 7) SysPrintStr("z = ") SysPrintInt(z) SysExit() end function...
Computer Architecture Project Description: farh-to-cel.asm : # Revised and added code taken from Hennesey and Patterson 5th edition # to work with this simulator. # # Prompts a user to enter a Fahrenheit temperature as a floating point. # Displays the converted temperature in Celcius. # 10/28/2015 .data const5: .float 5.0 # store a floating point constant 5.0 const9: .float 9.0 const32: .float 32.0 .align 2 # align the next string on a word boundary .space 100 prompt: .asciiz "Please...
Specifics: Use only the instructions covered to date. No jal and jr. Do not use any pseudo-instructions. Do not store any values into memory. There are no lw or sw instructions in this program. Just read the integers and process them. Document the beginning of your program with your name, project description, and class ID. comment every instruction. Write a MIPS assembly language program to do the following: 1. Print your name 2. Prompt the user...
In this assignment you are going to handle some basic input operations including validation and manipulation, and then some output operations to take some data and format it in a way that's presentable (i.e. readable to human eyes). Functions that you will need to use: getline(istream&, string&) This function allows you to get input for strings, including spaces. It reads characters up to a newline character (for user input, this would be when the "enter" key is pressed). The first...