701 karma · joined May 15, 2021
meet.hn/city/de-Munich
Socials:
- https://github.com/michidk/
- https://www.linkedin.com/in/michael-lohr/
- https://x.com/miichidk/
Interests:
Cloud, Entrepreneurship, IoT, Open Source, Programming, Startups, Web Development, Freelancing
Most of the time as the quarter goes on, we then scrap those OKRs anyway because we didn't manage to do them or they were too specific and requirements changed.
I always had the feeling that what we are doing is bullshit. So great to finally hear it from someone else.
I wonder how many engineering companies actually use OKRs though.
I noticed that I then could also shave of one byte more by using lea esi, [rel msg] instead of lea rsi, [rel msg].
But even if it was 32 bit, then we would't have to copy a 1, since the syscall number for sys_write would be 4 instead of 1.
I get the same total size with both variants in 64 bit mode.
push 1
pop rax
mov rdi, rax
Assembling to 48 89 C7 (3 bytes)seems to be same in size as
push 1
pop rax
push 1
pop rdi
Assembling to 6A 01 5F (3 bytes)of course
With that fixed, is there any reason not to use push here?
> It should be a ‘proper‘ executable binary according to the spec
...
xor rax, rax ; = 0
inc rax ; = 1 - syscall: sys_write
mov rdi, rax ; copy 1 - file descriptor: stdout
lea rsi, [rel msg] ; pointer to message
mov rdx, 14 ; message length
syscall
...
$ nasm -f bin -o elf elf.asm; wc -c elf; ./elf
166 elf
Hello, World!
So I guess NASM already optimizes this quite wellHowever, using the stack-based instructions as xpasky hinted at:
...
push 1 ; syscall: sys_write
pop rax
pop rdi ; copy 1 - file descriptor: stdout
lea rsi, [rel msg] ; pointer to message
push 14 ; message length
pop rdx
syscall
...
I get down to 159 bytes! I updated the article to reflect thatBut lots of developers use formatting plugins to force line breaks anyways - and they are no better then the IDE linewrapping.
It allows me to launch vscode projects and devcontainers I often work on very quickly. Saves me so much time!
No way. We used Terraform before and the code just got unreadable. Simple things like looping can get so complex. Abstraction via modules is really tedious and decreases visibility. CDKTF allowed us to reduce complexity drastically while keeping all the abstracted parts really visible. Best choice we ever made!