Skip to content

Instantly share code, notes, and snippets.

@kmcallister
Created June 22, 2012 08:59
Show Gist options
  • Save kmcallister/2971501 to your computer and use it in GitHub Desktop.
Save kmcallister/2971501 to your computer and use it in GitHub Desktop.
printable COM file
; $ nasm -fbin print.asm -o print.com
; $ cat print.com
; h<|XP- {P_X(%GGG(%GGWZ- sh LI!XI!Hello, DOS!$
;
; C:\>PRINT.COM
; Hello, DOS!
org 100h
; di <- replace
push word replace+0x7b20
pop ax
push ax ; used below
sub ax, 0x7b20
push ax
pop di
; restore ah <- 0x7c
; 0x49 - 0x7c = 0xcd
pop ax
sub [di], ah
inc di
inc di
inc di
sub [di], ah
; dx <- msg
inc di
inc di
push di
pop dx
; ah <- 0x09 (write string)
sub ax, 0x7320
; prepare ah <- 0x4c (exit)
push word 0x4c20
replace:
db 0x49, 0x21 ; becomes int 0x21
pop ax
db 0x49, 0x21 ; becomes int 0x21
msg:
db "Hello, DOS!$"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment