Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
freefal
on Nov 19, 2018
|
parent
|
context
|
favorite
| on:
Paint16b: A 16 byte paint program written in 12 li...
But why not explicitly set the register to 1 rather than assume its 0 and increment it by 1?
amenghra
on Nov 19, 2018
|
next
[–]
On x86, some instructions are longer than others. Incrementing is a single byte. Setting the value 1 if you don’t assume anything is going to be 2 bytes (al, ah, bl, etc.) or 4 bytes for (ax, bx, etc.)
This online x86/x64 assembler is great:
https://defuse.ca/online-x86-assembler.htm
boomlinde
on Nov 19, 2018
|
prev
|
next
[–]
Saves one byte, I assume. Register targets are typically encoded in the opcode while direct values follow the opcode byte.
kevinmhickey
on Nov 19, 2018
|
prev
[–]
Probably because (IIRC) mov is 2 bytes and inc is only 1 byte and they're optimizing for minimum size.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: