flat assembler
Message board for the users of flat assembler.
Index
> Linux > Exercise with getdents64 |
Author |
|
revolution 30 Jan 2023, 07:59
Hans-Joachim Rudolph wrote: If there is anything to make the code simpler or better readable, please let me know. You can define structures with struc to remove some of the magic values. Code: add rsi, 16 ; cf. `man getdents` for 64-bit struct <--- can use a structure member Code: ;... mov edi, stdout ; fd syscall mov eax, sys_write mov esi, nl mov edx, 1 mov edi, 1 ; <--- isn't this also stdout? syscall ;... |
|||
30 Jan 2023, 07:59 |
|
FlierMate11 30 Jan 2023, 08:01
This is a cool program, it works nicely in Linux.
But as you said, a list sorting would be better. Hope to see you progress further!
|
||||||||||
30 Jan 2023, 08:01 |
|
Tomasz Grysztar 30 Jan 2023, 12:59
Hans-Joachim Rudolph wrote:
You would need to use size override if the declared size of labeled data was different from the size you wanted to use in the instruction. Code: add bx, word[rsi] ; now points to next entry Code: add word[rsi], 1 Of course you may want to keep size annotations for reasons like readability - it might be important to stress out that a given instruction must operate on a byte. But this also has its drawbacks - if for any reason you change the data definition, for example from DB to DW, the instruction without size override would automatically adapt, while the instruction that forces size is going to keep using the original one and you may then end up with a hidden bug. It all depends on the circumstances, though. Also, for numeric equates I would generally recommend = instead of EQU - the latter is a plain substitution of text at the preprocessing stage, and it may lead to unexpected results if you start using it with expressions. Although for simple numbers, like used here, it is completely safe. |
|||
30 Jan 2023, 12:59 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.