        segment .data
fd      dq      0

        segment .bss
data    resb    1000000000
x       resb    1

        segment .text
        global  main
        extern  open, read
main:       
        push    rbp
        mov     rbp, rsp
        sub     rsp, 32
        
;       if ( argc > 1 ) {   // open a file named in argv[1]
        cmp     ecx, 1
        je      no_file_name
            mov     rcx, [rdx+8] ; get argv[1]
            mov     edx, 0x8000  ; O_RDONLY | O_BINARY
            call    open
            mov     [fd], eax
;       }              
no_file_name:
        mov     ecx, [fd]
        lea     rdx, [data]
        mov     r8d, 2000000
        call    read
    
        leave
        ret

