diff options
| author | mithe24 <mithe24@student.sdu.dk> | 2025-09-29 16:53:18 +0200 |
|---|---|---|
| committer | mithe24 <mithe24@student.sdu.dk> | 2025-10-29 13:49:57 +0100 |
| commit | 703af39239b9dbb8a4159cc39fc483e4cc8df1b6 (patch) | |
| tree | 8d331b974bf430ee3a9df91fc0e5e04078fdd7f5 /snippets/fileHandling.s | |
| parent | c6d80b48f91d8eaadf0d87bdd0bba6a4c5f1324d (diff) | |
| download | sorter-703af39239b9dbb8a4159cc39fc483e4cc8df1b6.tar.gz sorter-703af39239b9dbb8a4159cc39fc483e4cc8df1b6.zip | |
chore: Added provided code snippets
Diffstat (limited to '')
| -rw-r--r-- | snippets/fileHandling.s | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/snippets/fileHandling.s b/snippets/fileHandling.s new file mode 100644 index 0000000..17a9428 --- /dev/null +++ b/snippets/fileHandling.s @@ -0,0 +1,16 @@ +# int getFileSize(int fd) +# +# Returns the size (in bytes) of the file indicated by the file descriptor. +.section .data +.Lstat: .space 144 # size of the fstat struct +.section .text +.globl getFileSize +.type getFileSize, @function +getFileSize: + movq $5, %rax # fstat + # rdi already contains the fd + movq $.Lstat, %rsi # buffer to write fstat data into + syscall + movq $.Lstat, %rax + movq 48(%rax), %rax # position of size in the struct + ret |