无法在 nasm x86 中两次输出到标准输出
Can't output to stdout twice in nasm x86
我正在学习基本的 NASM x86 程序集,但在同一个二进制文件中两次打印到 stdout
时遇到问题。我的代码是:
section .data
pokelst: dw 'Bulbasaur',0xa,'Charmander',0xa,'Squirtle',0
pokelstLen: equ $-pokelst
endl: db '\n'
smiley: db '\u23a',0xa
smileyLen: equ $-smiley
section .text
global _start
_start:
mov ebx,1
mov ecx,smiley
mov eax,4
mov edx,smileyLen
int 80h
int 80h
mov eax,1 ;syscall code 1 is exit
mov ebx,0 ;ebx contains exit code (canonically, 0 means no errors)
int 80h ;int 80h=syscall
输出是:
\u23a
ocket8888@ParanoidLinux ~
忽略它没有解析 uni-code 的事实,在我看来,如果我使用 int 80h
两次,它应该打印两次。但是,很明显不是。
我做错了什么?
正在阅读 RETURN
部分或 write(2)
...
On success, the number of bytes written is returned (zero
indicates nothing was written). On error, -1 is returned, and
errno is set appropriately.
此调用完成后,返回一个值给EAX
。这意味着,当您再次尝试 运行 中断时,您将 运行 设置一个不同的中断。
我正在学习基本的 NASM x86 程序集,但在同一个二进制文件中两次打印到 stdout
时遇到问题。我的代码是:
section .data
pokelst: dw 'Bulbasaur',0xa,'Charmander',0xa,'Squirtle',0
pokelstLen: equ $-pokelst
endl: db '\n'
smiley: db '\u23a',0xa
smileyLen: equ $-smiley
section .text
global _start
_start:
mov ebx,1
mov ecx,smiley
mov eax,4
mov edx,smileyLen
int 80h
int 80h
mov eax,1 ;syscall code 1 is exit
mov ebx,0 ;ebx contains exit code (canonically, 0 means no errors)
int 80h ;int 80h=syscall
输出是:
\u23a
ocket8888@ParanoidLinux ~
忽略它没有解析 uni-code 的事实,在我看来,如果我使用 int 80h
两次,它应该打印两次。但是,很明显不是。
我做错了什么?
正在阅读 RETURN
部分或 write(2)
...
On success, the number of bytes written is returned (zero indicates nothing was written). On error, -1 is returned, and errno is set appropriately.
此调用完成后,返回一个值给EAX
。这意味着,当您再次尝试 运行 中断时,您将 运行 设置一个不同的中断。