- #1
heman
- 361
- 0
Can anyone explain how this simple assembly code is working:
This is specifically for pentium ones
I am actually lacking codes for assembly,,didn;t get any...if you have any please give..
----------------------------------------------------------------
#include<asm/unistd.h>
#include<syscall.h>
.data
buffer: .int 0
fileread:
.string "fileread.S"
filewrite:
.string "filewrite.S"
.text
.globl _start
_start:
movl $(SYS_open), %eax
movl $(fileread), %ebx
movl $(0) ,%ecx
int $0x80
push %eax
movl $(SYS_open), %eax
movl $(filewrite), %ebx
movl $(1), %ecx
int $0x80
push %eax
c1:
movl $(SYS_read) ,%eax
movl 4(%esp), %ebx
movl $buffer, %ecx
movl $4 ,%edx
int $0x80
cmp $0, %eax
jle end
movl $(SYS_write) ,%eax
movl (%esp),%ebx
movl $buffer,%ecx
movl $4,%edx
int $0x80
jmp c1
end:
addl $8, %esp
movl $(SYS_exit),%eax
xorl %ebx,%ebx
int $0x80
ret
This is specifically for pentium ones
I am actually lacking codes for assembly,,didn;t get any...if you have any please give..
----------------------------------------------------------------
#include<asm/unistd.h>
#include<syscall.h>
.data
buffer: .int 0
fileread:
.string "fileread.S"
filewrite:
.string "filewrite.S"
.text
.globl _start
_start:
movl $(SYS_open), %eax
movl $(fileread), %ebx
movl $(0) ,%ecx
int $0x80
push %eax
movl $(SYS_open), %eax
movl $(filewrite), %ebx
movl $(1), %ecx
int $0x80
push %eax
c1:
movl $(SYS_read) ,%eax
movl 4(%esp), %ebx
movl $buffer, %ecx
movl $4 ,%edx
int $0x80
cmp $0, %eax
jle end
movl $(SYS_write) ,%eax
movl (%esp),%ebx
movl $buffer,%ecx
movl $4,%edx
int $0x80
jmp c1
end:
addl $8, %esp
movl $(SYS_exit),%eax
xorl %ebx,%ebx
int $0x80
ret