Write program to read & display contents of file

section .data
file_namedb 'msmalb11m.asm',0
fnotmsgdb 'FIE NOT FOUND...',10
fnmsg_lenequ $-fnotmsg
openmsgdb 'FILE OPENED SUCESSFULLY!',10
omsg_lenequ $-openmsg
filemsgdb 'FILE CONTENTS ARE:-',10
fmsg_lenequ $-filemsg
section .bss
fd_inresd 1
fbuffresb 20
fb_lenequ $-fbuff
act_lenresd 1
%macro print 2
mov eax,4
mov ebx,1
mov ecx,%1
mov edx,%2
int 80h
%endmacro
section .text
global _start
start:
mov eax,5
movebx,file_name
mov ecx,0
mov edx,0777
int 80h
mov [fd_in],eax
bt eax,31
jnc conti1
printfnotmsg,fnmsg_len
jmp exit
conti1:
printopenmsg,omsg_len
printfilemsg,fmsg_len
readfile:
mov eax,3
movebx,[fd_in]
movecx,fbuff
movedx,fb_len
int 80h
mov [act_len],eax
cmp eax,0
je nxt1
printfbuff,[act_len]
jmpreadfile

nxt1:
mov eax,6
movebx,[fd_in]
int 80h
exit:
mov eax,1
mov ebx,0
int 80h

Comments