2016-08-01 1 views
-1

내가 MIPS에 확인 대화 상자에 대한 코드에 문제가 오전 : 분명히확인 대화

 
.data 
Welcome1:.asciiz "\n Hello! you are about to play the mastermind guessing and logic game,Bulls & Cows!\n The Computer will generate a secret numbermade of 4 unique integer number.You have to guess the number!\n Using the number of Bulls and Cows you get to find out what the secret number is!\n" 
Welcome2: .asciiz "\nEvery digit you enter that is both correct and in the right location is a BULL. When you get 4 BULLS, YOU WIN!\n\nEvery digit you enter that is correct, but not in the right location is a COW!\n" 
confirm: .asciiz "\n Select \nYES - if you are ready to guess \n NO - to see the rules again \n Cancel - to exit the Game\n" 
.text 
main:jal welcome 
welcome: 
la $a0,Welcome1 
li $a1,1 
li $v0, 55 
syscall 

la,$a0,Welcome2 
li $v0,55 
syscall 

la $a0,confirm 
li $v0,50 

syscall 


Exit: 
li $v0,10 
syscall 
+1

안녕하세요 @ user3341473 안녕하세요, stackoverflow. 코드로 인해 발생하는 문제에 대해 자세히 설명해 주시겠습니까? 당신은 그것이 무엇을 기대하며, 대신 무엇이 일어나고 있습니까? – Blckknght

+0

프로그램 확인을 위해 "예"또는 "아니요"옵션이있는 확인 대화 상자를 찾고 있습니다. – user3341473

답변

0

을, 당신은 게임의 작업을 얻기 위해 할 수있는 좀 더 일을 가지고,하지만 난했습니다 스켈레톤 프레임 워크가 생겼습니다. [무상의 스타일 클린업을 용서해주십시오] :

.data 

Welcome1: 
    .ascii "\n Hello! you are about to play the mastermind" 
    .ascii " guessing and logic game,Bulls & Cows!\n" 
    .ascii "The Computer will generate a secret number made of 4 unique" 
    .ascii " integer numbers. You have to guess the number!\n" 
    .ascii "Using the number of Bulls and Cows you get to find out what" 
    .asciiz " the secret number is!\n" 

Welcome2: 
    .ascii "\nEvery digit you enter that is both correct and in the right" 
    .ascii " location is a BULL. When you get 4 BULLS, YOU WIN!\n\n" 
    .ascii "Every digit you enter that is correct, but not in the right" 
    .asciiz " location is a COW!\n" 

confirm: 
    .ascii "\n Select \n" 
    .ascii "YES - if you are ready to guess\n" 
    .ascii "NO - to see the rules again\n" 
    .asciiz "Cancel - to exit the Game\n" 

msg_asknum: 
    .asciiz "\nEnter your game choice\n" 

    .text 

main: 

    # show intro and rules 
main_welcome: 
    la  $a0,Welcome1 
    li  $a1,1 
    li  $v0,55 
    syscall 

    la  $a0,Welcome2 
    li  $v0,55 
    syscall 

    # ask user to select an action (i.e. enter data, reread rules, exit program) 
main_confirm: 
    la  $a0,confirm 
    li  $v0,50 
    syscall 

    # the return is in a0: 0=yes, 1=no, 2=cancel 
    beq  $a0,0,main_asknum 
    beq  $a0,2,main_exit 
    b  main_welcome 

    # ask user for the next game input 
    # NOTE: this is a prompt for an integer number 
main_asknum: 
    li  $v0,51 
    la  $a0,msg_asknum 
    syscall 

    beq  $a1,-1,main_asknum  # syntax error 
    beq  $a1,-2,main_confirm  # cancel 
    beq  $a1,-3,main_asknum  # ok, but no data 

    jal  do_something   # do something with the number in a0 ... 

    j  main_asknum 

main_exit: 
    li  $v0,10 
    syscall 

# do_something -- process user's input 
# 
# arguments: 
# a0 -- number the user entered 
do_something: 
    jr  $ra      # return