Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %include "io.inc"
- section .data
- r db "r", 0
- s db "%s", 0
- d db "%d", 0
- in1 db "D:\assembler\5con\data.txt", 0
- k dd 0
- f dd 0
- section .bss
- x resd 1
- section .text
- CEXTERN fopen
- CEXTERN fclose
- CEXTERN fscanf
- EXTERN printf
- global CMAIN
- CMAIN:
- mov ebp, esp; for correct debugging
- sub esp, 4; 4 + 4 = 8
- push r
- push in1; 16
- call fopen
- add esp, 8; 8
- mov dword[f], eax; esi = f
- .while:
- sub esp, 12 ; 20
- push x
- push d
- push dword[f]; 32
- call fscanf
- add esp, 12; 20
- cmp eax, 1
- je .add
- cmp eax, -1
- je .end
- cmp eax, 0
- je .while
- .add:
- add dword[k], 1
- jmp .while
- .end:
- sub esp, 4; 24
- mov ecx, dword[k]
- push ecx
- push d; 32
- call printf
- add esp, 8; 24
- sub esp, 4; 28
- push dword[f]; 32
- call fclose
- add esp, 4; 28
- add esp, 24
- xor eax, eax
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement