MIPS Assembly Program Help - Press 0 on keyboard to show options?

Discussion in 'Assembly Language Programming (ALP) Forum' started by BearPaw, Mar 26, 2011.

  1. BearPaw

    BearPaw Guest

    Hello,

    I need help and don't understand how to press 0 on the keyboard to show a list of options. If the number is not 0 then it should say "Error: Please press 0."

    Then once I have the options listed, I still cannot figure out how to select each one by its' number.

    I am trying to have a customer select from the options and then give a total (like a receipt), thank you!

    Here is what I have (I tried using jump tables):

    .data
    buffer: .space 60
    welcome: .asciiz "\nWelcome to the Candy Store"
    name: .asciiz "\nWhat is your name? "
    namerespond: .asciiz "\nTake a look at our candy selection..... "
    catalog: .asciiz "\nPress 0 to view the candy catalog."
    options: .asciiz "\nThe candy catalog :

    To purchase select 1 Cookie $200
    To purchase select 2 Gum $100
    To purchase select 3 Lollipop $500
    To purchase select 4 Gummie Bears $300
    To purchase select 5 Chocolate $100

    selection: .asciiz "\nYou selected to purchase: "
    total: .asciiz "\nYour total is: "
    .text

    main:
    li $v0, 4
    la $a0, welcome
    syscall

    li $v0, 4
    la $a0, name
    syscall

    li $v0, 8
    la $a0, buffer
    li $a1, 60
    syscall

    li $v0, 4
    la $a0, namerespond
    syscall

    li $v0, 4
    la $a0, buffer
    syscall

    red:

    li $v0, 4
    la $a0, catalog
    syscall

    li $v0, 5
    syscall
    add $s0, $s0, 1

    bltz $s0, orange

    li $v0, 4
    la $a0, options
    syscall

    j red

    orange:

    li $v0, 1
    move $a0, $s0
    syscall
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice