|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Print to screen using Assembly
I am writing a program in assembly that takes in some information and prints out the answer. I have everything the way I need it except for one part. It prompst the user for a number (1,2,3) and then the number of tickets (1-10) and then the users name. It calculates the price and prints out a line with the total. However, before it prints out the total it should print out the name that was entered and then a sentence. It should look like: Jen, your total cost is $100" (if you entered 10 tickets at $10 each). I know how to print an integer and a string but not a string that was the result of user input. I will put the segments of code below that I believe is important. Any help that you could be, I would really appreciate it. Thank you! And let me know if you need more of the code to understand what I did.
move $t1, $v0 # saves number of seats to $t1 mul $t1, $t1, 10 # gets price of tickets li $v0, 4 # users name goes in register $v0 la $a0, prompt2 # address of string to be printed # goes in register $a0 syscall li $v0, 8 # code for read_string goes in register $v0 la $a0, statestr # address of the input goes in register $a0 li $a1, 20 # size of buffer goes in register $a1 syscall li $v0, 4 #prints out name la $a0, string3 syscall li $v0, 4 la $a0, statestr la $a0, string #prints out string syscall move $a0, $t1 li $v0, 1 syscall |
|
#2
|
|||
|
|||
|
Never mind everyone! I figured it out! I was missing a syscall in order to print it out. Now I just have to get the formatting of the output correct!
Thanks anyway! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Other Programming Languages > Print to screen using Assembly |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|