add files
[idlebox.git] / read-records.s
blob4761ce0d53b05042f3f51a6d3cb00d16282a0773
1 .include "linux.s"
2 .include "record-def.s"
4 .section .data
5 file_name:
6 .ascii "text.dat\0"
8 .section .bss
9 .lcomm record_buffer, RECORD_SIZE
11 .section .text
12 .globl _start
13 _start:
14 .equ ST_INPUT_DESCRIPTOR, -4
15 .equ ST_OUTPUT_DESCRIPTOR, -8
17 movl %esp, %ebp
18 subl $8, %esp
20 movl $SYS_OPEN, %eax
21 movl $file_name, %ebx
22 movl $0, %ecx
23 movl $0666, %edx
24 int $LINUX_SYSCALL
26 movl %eax, ST_INPUT_DESCRIPTOR(%ebp)
27 movl $STDOUT, ST_OUTPUT_DESCRIPTOR(%ebp)
29 record_read_loop:
30 pushl ST_INPUT_DESCRIPTOR(%ebp)
31 pushl $record_buffer
32 addl $8, %esp
34 cmpl $RECORD_SIZE, %eax
35 jne finished_reading
37 pushl $RECORD_FIRSTNAME + record_buffer
38 call count_chars
39 addl $4, %esp
41 movl %eax, %edx
42 movl ST_OUTPUT_DESCRIPTOR(%ebp), %ebx
43 movl $SYS_WRITE, %eax
44 movl $RECORD_FIRSTNAME + record_buffer, %ecx
45 int $LINUX_SYSCALL
47 pushl ST_OUTPUT_DESCRIPTOR(%ebp)
48 call write_newline
49 addl $4, %esp
51 jmp record_read_loop
53 finished_reading:
54 movl $SYS_EXIT, %eax
55 movl $0, %ebx
56 int $LINUX_SYSCALL