Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Assembly Language Programming (ALP) Forum (http://www.go4expert.com/forums/assembly-language-programming-forum/)
-   -   Help with simple assembly Program (http://www.go4expert.com/forums/help-simple-assembly-program-t20734/)

namasteall2000 22Jan2010 12:10

Help with simple assembly Program
 
Hello - I am new to assembly language and just started to learn- I have a question - I have to get input(string, integer and double) from the user and store and print it on screen - but for some reason my code is showing weird o/p - double/string doesn't work.

Could somone guide me please?

################################################## ###################
# Test Program:
################################################## ##################
.data
prompt: .asciiz "\n Please Input an Integer value = "
prompt1: .asciiz "\n Please Input a Double value = "
prompt2: .asciiz "\n Please Input a Float value = "
prompt3: .asciiz "\n Please Input a String value = "
result: .asciiz " The sum of the integers NEW from 1 to N is "
result1: .asciiz " You have enter : "
bye: .asciiz "\n **** Have a good day ****"
.globl main
.text

main:

#Printing a String

li $v0, 4 # system call code for Print String
la $a0, prompt3 # load address of prompt into $a0
syscall # print the prompt message

li $v0, 5 # system call code for Read Integer
syscall # reads the value into $v0

li $v0, 4 # system call code for Print String
la $a0, result1 # load address of message into $a0
syscall # print the string

#lw $a0, $v0
li $v0, 1 # system call code for Print Integer
syscall # print sum of integers

#print a newline
la $a0, newline
li $v0, 4
syscall




#Printing an Integer
li $v0, 4 # system call code for Print String
la $a0, prompt # load address of prompt into $a0
syscall # print the prompt message

li $v0, 5 # system call code for Read Integer
syscall # reads the value into $v0

li $v0, 4 # system call code for Print String
la $a0, result1 # load address of message into $a0
syscall # print the string

#lw $a0, $v0
li $v0, 1 # system call code for Print Integer
syscall # print sum of integers


#print a newline
la $a0, newline
li $v0, 4
syscall




#Printing a double Value

li $v0, 4 # system call code for Print String
la $a0, prompt1 # load address of prompt into $a0
syscall # print the prompt message

li $v0, 5 # system call code for Read Integer
syscall # reads the value into $v0

li $v0, 4 # system call code for Print String
la $a0, result1 # load address of message into $a0
syscall # print the string

#lw $a0, $v0
li $v0, 3 # system call code for Print Double
syscall # print sum of integers

#print a newline
la $a0, newline
li $v0, 4
syscall


end:
li $v0, 4 # system call code for Print String
la $a0, bye # load address of msg. into $a0
syscall # print the string

li $v0, 10 # terminate program run and
syscall # return control to system

virxen 15Feb2010 05:45

Re: Help with simple assembly Program
 
read and store a string

Code:

.data
S: .space 20 #20 characters
...........
    la $a0, S        #store input string into S
    li $a1,20     
    li $v0,8
    syscall
.............



All times are GMT +5.5. The time now is 07:02.