section .data dw welcome_msg, "Simple 'Guess the number' game. Powered by Haxor VM.", 10, 0 dw generate_msg, "I will pick a number between %d and %d, your job is to guess it in smallest number of tries.", 10, 0 dw question_msg, 10, "What is the number? ", 0 dw bigger_msg, "Sorry, but my number is bigger.", 10, 0 dw smaller_msg, "Sorry, but my number is smaller.", 10, 0 dw win_msg, "Yeah! You guessed my number after %d tries!", 10, 0 dw invalid_msg, "Man, do you need definition of a number?! Try wikipedia then ;)", 10, 0 dw answer_fmt, "%d", 0 dw min, 1 dw max, 1000 section .bss dw number dw answer dw tries section .text bigger: addi $sc, $0, 01h pushi bigger_msg pushi 1 syscall j question smaller: addi $sc, $0, 01h pushi smaller_msg pushi 1 syscall j question win: addi $sc, $0, 01h pushm tries pushi win_msg push 1 syscall exiti 0 invalid_number: addi $sc, $0, 01h pushi invalid_msg push 1 syscall j question main: addi $sc, $0, 01h pushi welcome_msg push 1 syscall generate: addi $sc, $0, 01h pushm max pushm min pushi generate_msg pushi 1 syscall addi $sc, $0, 03h pushm max pushm min syscall popm number question: addi $sc, $0, 01h pushi question_msg pushi 1 syscall addi $sc, $0, 02h pushi answer pushi answer_fmt pushi 0 syscall addi $5, $0, -1 beq $sc, $5, invalid_number lw $6, $0, tries addi $6, $6, 1 sw $0, tries, $6 lw $7, $0, number lw $8, $0, answer beq $7, $8, win bgt $7, $8, bigger blt $7, $8, smaller