Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

COM files on Windows are always 16-bit. His CON files appear to be the native bit width of the kernel. This means unlike on Windiwsm his COM files cannot execute on both 32-bit and 64-bit versions of the kernel. That one imperfection aside, this is a fantastic achievement.


The zero-byte program should work on either :)

It's also possible to detect which mode the CPU is in:

    bits 16
    mov  ax,start16   ;may load EAX instead,
    jmp  ax           ;skipping this 2-byte instruction

    bits 32
    dec  eax          ;REX prefix in long mode,
    mov  eax,start32  ;may load RAX,
    jmp  eax          ;skipping these 4 bytes
    nop
    nop

    bits 64
    jmp  start64
You can even be compatible with CP/M-80 by putting this at the start:

    add  bx,start8    ;8080: ADD C, JMP start8
    nop               ;immediate may be 16 or 32 bits
    nop


A valid point! Clearly the correct solution would be for the kernel module to check if the filename contains the substring "32", and if so it should load it as a 32-bit binary.


Have you considered building your program into the binfmt module and only running 0 byte executables?




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: