Redxone

[8086 DOS] How to make a simple printing program.

Feb 2nd, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Define program model and data stack
  2. ; 100h means our stack is 100 bytes long.
  3. .model small
  4. .stack 100h
  5.  
  6. .data
  7.     ; Allocate bytes under the name "hello" end with byte $ because the dos print interrupt
  8.     ; Needs to know when to stop printing the string, $ is that indication.
  9.     hello db 10,13,'This is my first printed string!$'
  10. .code
  11.     ; Load our data segment into our ds register.
  12.     mov ax, @data
  13.     mov ds, ax
  14.     ; Prepare our print interrupt
  15.     mov ax, 09h
  16.     ; Load into the DX register (Data MSB/LSB) -> DS:(hello)
  17.     ; Our data segment + the offset of where our hello is located. (Similar to a pointer)
  18.     lea dx, hello
  19.     ; Interrupt into DOS and call our print function.
  20.     int 21h
  21.     ; We need to return the control back to dos so our program doesn't freeze when it ends.
  22.     mov ah, 4ch
  23.     int 21h
  24.     ; And that's how you print a simple string in 8086 ASM xD
  25. end
Add Comment
Please, Sign In to add comment