-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab22.s
64 lines (48 loc) · 2.06 KB
/
lab22.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Name and general description of the program
# This is a sample program to read from keyboard and print on the screen
# ----------------------------------------------------
# Data declaration go in this section
.data
prompt: .asciiz "Please input a number: "
answer: .asciiz "The sum is "
end: .asciiz "\n"
# Program-specific date declaration
# ----------------------------------------------------
# Program code goes in this section
.text
.globl main
.ent main
main:
jal readtwo
jal readtwo
#jal findminmax
li $v0, 10 # Code 10 = Exit
syscall
###########################################################################################################################################
readtwo:
li $v0, 4 # Code 4 = Print string
la $a0, prompt # load address of the string
syscall # Ask Operating System to perform the service (4 == Print string)
li $v0, 5 # Code 5 = read integer and store it in $v0
syscall # Ask Operating System to perform the service (5 == Read from keyboard)
sub $sp, $sp, 8
sw $v0, 4($sp) #PUSH VALUE TO THE STACK
li $v0, 4 # Code 4 = Print string
la $a0, prompt # load address of the string
syscall # Ask Operating System to perform the service (4 == Print string)
li $v0, 5 # Code 5 = read integer and store it in $v0
syscall
sw $v0, 0($sp) #PUSH VALUE TO THE STACK
jr $ra #RETURN TO MAIN
#li $v0, 4
# Code 4 = Print string
#lw $s0, 4($sp)
#$a0, $s0 # load address of the string
#syscall
#la $s0, 0($sp)
#move $a0, $s0
#syscall
# Ask Operating System to perform the service (5 == Read from keyboard)
###########################################################################################################################################
#findminmax:
###########################################################################################################################################