我有以下程序寫在NASM大會:NASM打印到下一行
section .text
global _start:
_start:
; Input variables
mov edx, inLen
mov ecx, inMsg
mov ebx, 1
mov eax, 4
int 0x80
mov edx, 2
mov ecx, num1
mov ebx, 0
mov eax, 3
int 0x80
mov edx, inLen
mov ecx, inMsg
mov ebx, 1
mov eax, 4
int 0x80
mov edx, 2
mov ecx, num2
mov ebx, 0
mov eax, 3
int 0x80
; Put input values in correct registers
mov eax, [num1]
sub eax, '0' ; convert char to num
mov ebx, [num2]
sub ebx, '0' ; convert char to num
; Perform addition
add eax, ebx
add eax, '0' ; convert num to char
; Set sum in res
mov [res], eax
; Output result
mov edx, resLen
mov ecx, resMsg
mov ebx, 1
mov eax, 4
int 0x80
mov edx, 1
mov ecx, res
mov ebx, 1
mov eax, 4
int 0x80
; Exit program
mov eax, 1
int 0x80
section .bss
num1 resb 2
num2 resb 2
res resb 2
section .data
inMsg db "Input number: ", 0xA, 0xD
inLen equ $-inMsg
resMsg db "Result: ", 0xA, 0xD
resLen equ $-resMsg
當我運行控制檯看起來是這樣的:
[email protected]:~/ASM/Addition$ ./Add
Input number:
3
Input number:
2
Result:
[email protected]:~/ASM/Addition$
我怎樣才能得到它,因此5將打印在自己的行,並沒有打印後直接cmd? I.E.它應該是這樣的:
[email protected]:~/ASM/Addition$ ./Add
Input number:
3
Input number:
2
Result:
5
[email protected]:~/ASM/Addition$
打印結果後,將字符序列'0xA,0xD'寫入標準輸出。 – Michael
它是linux,只寫'0xA'。 – Jester