#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Posts
    2
    Rep Power
    0

    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. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Posts
    2
    Rep Power
    0
    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!

IMN logo majestic logo threadwatch logo seochat tools logo