pgubook-readers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pgubook-readers] [chapter 5] about buffer


From: 김태윤
Subject: [Pgubook-readers] [chapter 5] about buffer
Date: Sun, 27 Mar 2011 18:53:52 +0900

I am trying to read 2nd data of file
but the following code read always 1st byte of data
what's wrong with me?

.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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]