Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Opening a file

Hi! I`m having a problem opening a file in 16 bit assembly. Here`s part of program which prompts user to input filename and using it should open the file but instead it just gives error message. I made a mistake somewhere I think..
Thanks in advance for your help! :)

.model small
.stack 100h

iveskite db 'Type your filename.$'
klaid db 'Error reading file.$'
endln db 13, 10, "$"
filename db 20,0,20 dup(?),0
handle dw ?


mov ax, @data
mov ds, ax

mov ah, 09h
mov dx, offset iveskite
int 21h

mov ah, 09h
mov dx, offset endln
int 21h

mov ah, 0ah ;filename input
mov dx, offset filename
int 21h

mov ax, 3d00h
mov dx, offset filename ;open file
int 21h
jc klaida

mov handle, ax
jmp quit


mov ah, 09h
mov dx, offset endln
int 21h

mov ah, 09h ;output error message
mov dx, offset klaid
int 21h

mov ax,04C00h ;close program
int 21h

end main
Sign In or Register to comment.