【发布时间】:2016-09-09 12:22:36
【问题描述】:
我正在学习汇编程序(Nasm、Linux、Ubuntu 16.4、x86_64) 并在使用 sys_time 调用 (mov eax, 13) 时遇到问题。
section .bss
time: resb 30;
section .data
msg: db "The Time is:";
msgLen: equ $-msg;
blank: db 0x0a;
blankLen: equ $-blank;
section .text
global _start:
_start:
mov eax, 13;
mov ebx, time;
int 80h;
mov eax, 4;
mov ebx, 1;
mov ecx, msg;
mov edx, msgLen;
int 80h;
mov eax, 4;
mov ebx, 1;
mov edx, time;
mov ecx, 30;
int 80;
mov eax, 4;
mov ebx, 1;
mov ecx, blank;
mov edx, blankLen;
int 80h;
mov eax, 1;
mov ebx, 0;
int 80h;
错误信息是
(用谷歌翻译)(Written dump ) segfaulting如果有人在这里知道德语,德语错误消息Speicherzugriffsfehler (Speicherabzug geschrieben)
我的想法:也许 resb 为字符串保留空间,但是如何将 Integer 转换为字符串?还是我必须声明一个整数? 还是我的内核坏了?
【问题讨论】:
-
使用
export LANG=C或export LANG=en_US.UTF-8获取英文错误消息以在SO 上发布。 -
如果我必须在终端中运行它,我已经完成了 :)
标签: linux ubuntu assembly nasm system-calls