Skip to content

Comment on The smallest Hello World program

Comments

Here's a tiny DOS COM file that does it in 18 bytes:

    ;; 18 bytes
    DB 'HELLO_WOIY<$'  ; executes as machine code, returning SP to original position without overwriting return address
    
    mov  dx, si    ; mov dx,0100h MS-DOS (all versions), FreeDOS 1.0, many other DOSes
    xchg ax, bp    ; mov ah,9     MS-DOS 4.0 and later, and FreeDOS 1.0
    int  21h
    ret
(credits: https://stackoverflow.com/questions/72635031/assembly-hello-...)

Well, it prints something that is the same length as the correct message at least.

COM files for CP/M and DOS really are a no-nonsense executable format.

I'm a bit disappointed that Linux (or BSD, macOS, etc.) doesn't support them (or similar) out of the box, though Windows will sort of run them via ntvdm.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.