summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2025-09-28Reorganize pipe codeHEADmasterMatt Hunter1-16/+13
A few modifications are made for code size: - Move write before read, to avoid unconditional jump - Set stack pointer out in _start (runtime optimization) - Don't explicitly zero uninitialized registers Signed-off-by: Matt Hunter <m@lfurio.us>
2025-09-28Move exit callMatt Hunter1-7/+3
exit is now only called from one place, so move the syscall to that location to avoid the extra unconditional jump. There is now no longer an exit label. mov al, 1 is replaced with inc eax, as this overall saves 1 byte. Since lace's exit status is no longer defined, drop the instruction to zero ebx before exiting. Now that explicit error checking is removed, there is no need to use this value for anything. Signed-off-by: Matt Hunter <m@lfurio.us>
2025-09-28Statically define socket endpointMatt Hunter2-44/+19
Instead of opening and reading a sockaddr_in struct from an external file at runtime, define this data in the executable with constants. Furthermore, arrange to store this data in a yet unused portion of the main ELF header so it effectively consumes no additional space. It overlaps the ELF "shoff" and "flags", and the program header "align" fields. The full size of struct sockaddr_in is actually 16 bytes, but the last 8 bytes are padding, and failing to zero them out appears to have no adverse effect on behavior. So this padding area will just be populated by the next few fields in the ELF header, interpreted as garbage. In the program code, remove the initial syscalls for open() and read() and their associated error checking. Also remove the error check after connect(), as the program will properly exit without performing any IO without it. Going forward, we make no guarantees about lace's exit status. Signed-off-by: Matt Hunter <m@lfurio.us>
2023-01-15Remove unnecessary stack allocationsMalfurious1-5/+1
Subtracting esp to allocate space on the stack is only necessary to preserve data that is already lower on the stack. By the time we use either the sockaddr struct or the temporary io buffer, we are finished accessing older stack values, so they can be overwritten. This saves 2 unnecessary instructions from the program. Signed-off-by: Malfurious <m@lfurio.us>
2023-01-14Write to stdout instead of stdinMalfurious1-2/+3
The previous version breaks if stdin is directed from a file, such as /dev/null. Signed-off-by: Malfurious <m@lfurio.us>
2023-01-13Improve code commentsMalfurious1-3/+3
Signed-off-by: Malfurious <m@lfurio.us>
2023-01-13Fix error handling for open() callMalfurious1-1/+1
Zero is a valid return value, so don't jmp to exit if the fd is equal to it. However, we would never expect zero to be returned as stdin is not closed. Signed-off-by: Malfurious <m@lfurio.us>
2023-01-12Fix bug in exit routineMalfurious1-0/+1
If an error condition is met during the pipe IO syscalls, eax will be filled with a negative value. We need to then zero the rest of the register before attempting to exit, so we don't continue on to execute garbage. Signed-off-by: Malfurious <m@lfurio.us>
2023-01-12Remove the use of ebpMalfurious1-4/+3
Removes an unnecessary instruction. Signed-off-by: Malfurious <m@lfurio.us>
2023-01-12Initial working version of laceMalfurious2-0/+149
Signed-off-by: Malfurious <m@lfurio.us>