閱讀168 返回首頁    go 阿裏雲 go 技術社區[雲棲]


linux簡單之美(三)

在linux簡單之美(二)中我們嚐試使用了C庫的函數完成功能,那麼能不能用syscall方式

來搞呢?顯然可以!

section .data
	ft db "now is X",10

section .text
global _start

_start:
	mov edi,10
again:
	dec edi
	mov eax,edi
	add eax,0x30
	mov byte [ft+7],al

	mov eax,4
	mov ebx,1
	mov ecx,ft
	mov edx,9
	int 0x80

	mov eax,162
	push 0
	push 1
	mov ebx,esp
	mov ecx,0
	int 0x80
	
	cmp edi,0
	jnz again
	
	mov eax,4
	mov ebx,1
	mov ecx,msg
	mov edx,15
	int 0x80
	
	mov eax,1
	mov ebx,0
	int 0x80
	
msg:
 db "happy xxx day!",10

    nasm -f elf main.asm

    ld -m elf_i386 -o main main.o

    在代碼中延時使用的是nanosleep,其他和第一篇一致,隻不過做了一個bin->ascii的小轉換.

最後更新:2017-04-04 07:03:18

  上一篇:go 淺析微軟Win 8係統激活的各種問題
  下一篇:go 最炫民族風!體驗國人新寵Linux Deepin