Simple way to Get filesize in x86 Assembly Language

后端 未结 2 586
天涯浪人
天涯浪人 2021-01-16 23:34

Assuming that I have opened a file in assembly and have the file handle for that file in register eax. How would I go about getting the size of the file so I can allocate en

2条回答
  •  无人及你
    2021-01-16 23:57

    My solution -- Just use .lcomm to create locations for all the named variables

    movl    inputfile, %ebx         #Move file handler into ebx for system call
    movl    $0x6c, %eax          #Stat Sys Call into eax
    leal    statlocation, %ecx      #Move reserved location for stat structure into
    int     $0x80                    #Execute System Call
    movl    20(%ecx), %eax          #20 to location of size variable, size is now in eax
    

提交回复
热议问题