Skip to content

Instantly share code, notes, and snippets.

@cswingler
Last active February 11, 2018 06:20
Show Gist options
  • Save cswingler/ae231564f7dcf92d37f95e52cbcd414f to your computer and use it in GitHub Desktop.
Save cswingler/ae231564f7dcf92d37f95e52cbcd414f to your computer and use it in GitHub Desktop.
DEBUG.COM Hello World - Commented
; This can be run with DEBUG.COM: Run DEBUG.COM < HELLO.ASM.
; You'll get a HELLO.COM output that outputs "Hello world!"
; This was sourced from http://www2.latech.edu/~acm/helloworld/dosdebug.html, comments are mine.
; Switch to DEBUG.COM assemble mode:
a
mov ah,9 ; 0100 : Put 9 (output to stdout) to ah
mov dx,108 ; 0102 : put 0108 in dx (which should contain the string "Hello world!$" )
int 21 ; 0105 : Kick the MS-DOS API, which reads from ah
ret ; 0107 : Return from procedure
; 0108: Our data:
db "Hello world!$"
; 0115 : Get out of assemble entry mode with the following empty line:
; Write 15 (number of bytes to write to disk) to register cx:
r cx
15
; Set the output filename:
n hello.com
; Write the assembled program:
w
; Quit DEBUG.COM:
q
@cswingler
Copy link
Author

Comments in this are weird. A couple rules I found:

  • Debug.com extensions (in this case, db "Hello world!$") cannot have inline comments - the comment will be interpreted as part of the byte sequence.
  • Debug.com commands (those executed outside of assemble mode) also cannot have inline comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment