【发布时间】:2015-04-15 23:12:16
【问题描述】:
我是一名新手 Assembly x86 Learner,我想添加两个数字 (5+5) 并将结果打印在屏幕上。
这是我的代码:
global _start
section .text
_start:
mov eax, 5
mov ebx, 5
add eax, ebx
push eax
mov eax, 4 ; call the write syscall
mov ebx, 1 ; STDOUT
pop ecx ; Result
mov edx, 0x1
int 0x80
; Exit
mov eax, 0x1
xor ebx, ebx
int 0x80
请指正
【问题讨论】:
-
写系统调用的参数应该是一个字符串。
-
你的意思是我们不能使用 write 系统调用来打印一个整数?
-
可以,但不能直接。
-
你能帮我做吗?
-
您必须将整数转换为字符串。参见例如stackoverflow.com/questions/25064565/…