Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 为什么我的猜谜汇编游戏在sms32v50中不起作用?_Assembly_X86_Mips - Fatal编程技术网

Assembly 为什么我的猜谜汇编游戏在sms32v50中不起作用?

Assembly 为什么我的猜谜汇编游戏在sms32v50中不起作用?,assembly,x86,mips,Assembly,X86,Mips,我修改了一个用汇编编写的开源猜谜游戏 .data #storing data startmsg: .asciiz "Pick a number between 1 and 100.\n\n" guessmsg: .asciiz "Enter your guess\n" tooHigh: .asciiz "Your guess is too high.\n\n" tooLow: .asciiz "Your guess is too low.\n\n" win

我修改了一个用汇编编写的开源猜谜游戏

.data #storing data
    startmsg: .asciiz "Pick a number between 1 and 100.\n\n"
    guessmsg: .asciiz "Enter your guess\n"
    tooHigh: .asciiz "Your guess is too high.\n\n"
    tooLow: .asciiz "Your guess is too low.\n\n"
    wingame: .asciiz "You have guessed the number. Well done!\n\n"
.text #start of program

start:
    jal random
    add $t0, $zero, $a0 # store random number $a0 in $t0
    li $v0, 4         # print string
    la $a0, startmsg
    syscall

#######################################
# Main game loop for guessing
guessing:
    la $a0, guessmsg
    li $v0, 4 # print string guessmsg
    syscall




    li $v0, 5 #read int from user
    syscall
        move $t1, $v0 # store input in t1
        #addi $t2, $zero, 1 #t2 = 1 (guess min)
    beq $t0, $t1, win # if stored int = user input, user won
    addi $s0, $s0, -1 # guess used, subtract
    blt $t0, $t1, goLower # if stored int < user input, guess is too high

    # otherwise, guess is too low
    la $a0, tooLow
    li $v0, 4 # print string tooLow
        syscall

    # loop guessing
    j guessing

#######################################
# goLower: Procedure if the user guess too high
goLower:
    la $a0, tooHigh
    li $v0, 4 # print tooHigh
    syscall
    # loop back to get another guess
    j guessing

#######################################
# User won, print win and restart
win:
    la $a0, wingame
    li $v0, 4 #print string wingame
    syscall
    j start


#############################################
# LEAF PROCEDURE
# random: generate a rand number between 0 - 100
random: 
    li $v0, 42        # SERVICE 41 for a rand int
    #addi $a0, $zero, 0 # random number >= 0
    addi $a1, $zero, 100 #random number < 100
    #xor $a0, $a0, $a0  # Select random generator 0
    syscall            # Generate random int (returns in $a0)
    jr $ra

谢谢你的帮助

sms32v50不会说MIPS。来自:“这个模拟器模拟一个8位CPU,类似于80x86系列芯片的低8位。”@RuudHelderman谢谢你的帮助,你能告诉我如何转换代码使其工作吗?
; ---------------------------------------------------------------
; A program to demonstrate MOV commands. Mov is short for move.
; ---------------------------------------------------------------
    CLO     ; Close unwanted windows.
; ===== IMMEDIATE MOVES =====
    MOV AL,15   ; Copy 15 HEX into the AL register
    MOV BL,40   ; Copy 40 HEX into the BL register
    MOV CL,50   ; Copy 50 HEX into the CL register
    MOV DL,60   ; Copy 60 HEX into the DL register
Foo:
    INC AL      ; Increment AL for no particular reason.

; ===== INDIRECT MOVES =====
    MOV [A0],AL ; Copy value in AL to RAM location [40]
    MOV BL,[40] ; Copy value in RAM location [A0] into BL

; ===== REGISTER INDIRECT MOVES =====
    MOV [CL],AL ; Copy the value in AL to the RAM
            ; location that CL points to.
    MOV BL,[CL] ; Copy the RAM location that CL points
            ; to into the BL register.

    JMP Foo     ; PRESS ESCAPE TO STOP THE PROGRAM

    END
; ---------------------------------------------------------------
    TASK
    ====
    Look up the ASCII codes of the letters in H,E,L,L,O and move 
    these ASCII codes to RAM addresses [C0], [C1], [C2], [C3] 
    and [C4]. Run the program and watch how the text appears on 
    the simulated VDU display. This is very much the same as what 
    happens in the IBM PC running MS DOS. The program you write 
    should work but if you continue to study low level programming, 
    you will find much more efficient and flexible ways of solving 
    this problem.