有人可以告訴我如何讀取10字節長1字節的緩衝區?有人可以告訴我如何用1字節長的緩衝區讀取10個字節?
我的編程環境是Ubuntu Linux操作系統,emacs的,大會在& T語法
我可以讀取文件並保存讀取數據緩衝(1字節)
,但我怎麼能讀取文件的下一字節並保存到緩衝區?
我編輯的內容粘貼我的努力
.section .data
.section .bss
.lcomm buffer,1
.section .text
.global _start
_start:
movl %esp,%ebp
subl $8,%esp
#8(%ebp) is 2nd arg == input
#12(%ebp) is 3rd arg == output
#open,read,open,write,close
movl $5,%eax
movl 8(%ebp),%ebx
movl $0,%ecx
movl $0666,%edx
int $0x80
#%eax contains input's fd
#movl to first local var
movl %eax,-4(%ebp)
movl $5,%eax
movl 12(%ebp),%ebx
movl $03101,%ecx
movl $0666,%edx
int $0x80
#eax contains output's fd
#movl to second local var
movl %eax,-12(%ebp)
#read 1 byte from file 1st byte of data
movl $3,%eax
movl -4(%ebp),%ebx
movl $buffer,%ecx
movl $1,%edx
int $0x80
#read 1 byte from file I expect 2nd byte of data
movl $3,%eax
movl -4(%ebp),%ebx
movl $buffer,%ecx
movl $1,%edx
int $0x80
#buffer contains 1 byte of file
subb $48, buffer
movl buffer,%ebx
movl $1,%eax
int $0x80
使用C會不會更容易?或者失敗了,從彙編代碼中調用'read()'? – 2011-03-27 06:54:16
感謝您的回覆。 但我想在彙編中實現。 ,因爲它很好理解它是如何工作的 – 2011-03-27 06:56:30
爲什麼你不先努力? – 2011-03-27 07:00:29