我正在使用nasm構建一個簡單的計算器以顯示迄今爲止學到的什麼... 我正在使用linux。 當我打電話打斷80h時,它會打印出我所有的字符串,而不是指定長度的字符串。我該如何解決這個問題?`
SECTION .data
AskForCalculationPrompt: db "Choose which operation you want", 0xA, "1. Addition", 0xA, "2.Subtraction", 0xA, "3. Multiplication", 0xA, "4. Division", 0x3
FirstOperandPrompt: db "Enter the first operand:", 0xA
SecondOperandPrompt: db "Enter the second operand:", 0xA
AnswerPrompt: db "The answer is: "
AskForCalculationPromptln: equ $-AskForCalculationPrompt
FirstOperandPromptln: equ $-FirstOperandPrompt
SecondOperandPromptln: equ $-SecondOperandPrompt
AnswerPromptln: equ $-AnswerPrompt
SECTION .bss
Choice: resb 1
FirstOperand: resd 1
SecondOperand: resd 1
Answer: resd 1
SECTION .text
;Make interrupt to ask for a prompt ask for calculation prompt
global _start
_start:
mov eax, 4 ;Specify sys_write call
mov ebx, 1 ;Standard output
mov ecx, AskForCalculationPrompt
mov edx, AskForCalculationPromptln
int 80h
;error happens here.
;Make interrupt to read textfrom keyboard
mov eax, 3 ;Sys_read call
mov ebx, 0 ;Standard input file descriptor 0
mov ecx, Choice
mov edx, 1
int 80h
;Determine what we inserted
mov al, byte [Choice]
cmp al, 0x35
je _start`
這可以幫助你一下:http://www.dreamincode.net/forums/topic/286248-nasm-linux-terminal-inputoutput-wint-80h/ – wazy