3 ms·
You can just use ret at the end, saving 3 bytes. Also, the initial value of bp is 09xx on every version of MS-DOS since 4.0, so you can also start off with an x
by userbinator 4y ago
You can just use ret at the end, saving 3 bytes. Also, the initial value of bp is 09xx on every version of MS-DOS since 4.0, so you can also start off with an xchg ax,bp to save another byte.
xchg ax,bp
mov dx,107
int 21
ret
db "hello, world" 0d 0a '$'
22 bytes, of which 15 is the message.
- EvanAnderson 4y agoI was going to suggest the RET but I didn't remember the BP being set to save the additional byte. Nice, albeit sacrificing some compatibility. For anybody interested some DOS default register values documented: http://www.fysnet.net/yourhelp.htm http://www.fysnet.net/yourhelp.htm
- userbinator 4y agoIt's an old demoscene trick, so perhaps a bit obscure but somewhat common in the sizecoding community.
- jart 4y agoWow from feedback to commit in 30 minutes. https://github.com/susam/hello/commit/36fa08e7cafb7c5268b651831f2d255a0862dcef https://github.com/susam/hello/commit/36fa08e7cafb7c5268b651...
- arthurcolle 4y agoseems like a reasonable pace on a Sunday
- susam 4y agoUpdated the repository to use your RET suggestion. Thanks!
- ithinkso 4y agoWith no attribution nevertheless :) (/s) I love how, without the 'hello, world' message itself, 25% of your entire HELLO.ASM codebase is from a random HN comment Edit: I saw the new commit, HN is lovely
- susam 4y agoThanks for pointing out the missing attribution. Added a credits section to the README here: https://github.com/susam/hello#credits https://github.com/susam/hello#credits By the way, I noticed just now that @userbinator occurs in the credits section of an earlier repository of mine too: https://github.com/susam/tucl#credits https://github.com/susam/tucl#credits :)
- userbinator 4y agoPersonally, I don't think it's necessary. After all, it wasn't me who came up with the idea and it's probably one that has been rediscovered multiple times in the past.
- DiggyJohnson 4y agoI genuinely think you’re misusing the smiley face or sarcasm tag if you think it’s possible for that first line to include both.
- alrlroipsp 4y agoAs seen in 2022: Hello world example with 350 contributors. Beat the enterprise Fizbuzz by 25 contribs.
- torotonnato 4y agoOur PR dept wanted a more chill out version. Shaving a byte to the sound of ukuleles: db '4LOHA- W0rld' 0d 0a '$' xchg ax, bp xchg cx, dx int 21 ret