Hello,

I want to display content of a file with the name has been entered by the user, but I have to enter the name of the file when I run the program (eg:. / myprogram test.asm). I would not have to specify the file name each time you run, but whether the user to do so when prompted for the name. I said that reading and viewing work properly. That's what I've done so far:

segment .data 
nom_fichier : db "Entrez le nom du fichier : ", 10
nom_fichier_len equ $-nom_fichier
 bufsize dw      1024

segment .bss
fichier        resb 32
 buf     resb    1024
;; Message qui demande à l'utilisateur d'entrer un nom de fichier
	mov eax, 4
	mov ebx, 1
	mov ecx, nom_fichier
	mov edx, nom_fichier_len
	int 0x80
	
	;; Lecture nom du fichier
	mov eax, 3
	mov ebx, 0
	mov ecx, fichier
	mov edx, 32
	int 0x80

  ; get the filename in ebx 
	pop   ebx
    pop   ebx               
    pop   ebx              
    pop   ebx    
	
  ; ouvrir le fichier - open
    mov   eax,  5           ; ouverture
    mov   ecx,  0           ;   lecture seulement
    int   80h               
  ; lire le fichier - read
    mov     eax,  3         ; lecture
    mov     ebx,  eax       ;   descripteur
    mov     ecx,  buf       ;   *buf,
    mov     edx,  bufsize   ;   *bufsize
    int     80h             

  ; afficher le contenu à l'écran- display
    mov     eax,  4         ; affiche à l'écran
    mov     ebx,  1         
    int     80h

Thanks

Hi,
I think that your code is for a linux system. If I am right, you can read this:
http://board.flatassembler.net/topic.php?t=5361
It seems that at the program start the arguments are in the stack:
[esp] argc.
[esp + 4] argv[0]
[esp + 8] argv[1]
...
This, of course, if you program for 32 bits.

Bon courage.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.