Advertisement
Guest User

Untitled

a guest
Sep 4th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; "hello, world!" step-by-step char-by-char way...
  2. ; this is very similar to what int 21h/9h does behind your eyes.
  3. ; instead of $, the string in this example is zero terminated
  4. ; (the Microsoft Corporation has selected dollar to terminate the strings for MS-DOS operating system)
  5.  
  6. name "hello"
  7.  
  8. org     100h   ; compiler directive to make tiny com file.
  9.  
  10. ; execution starts here, jump over the data string:
  11. jmp     start
  12.  
  13. ; data string:
  14. msg db 'Hello, world!', 0
  15.  
  16. start:
  17.  
  18. ; set the index register:
  19.         mov     si, 0
  20.  
  21. next_char:
  22.  
  23. ; get current character:
  24.         mov     al, msg[si]
  25. ; is it zero?
  26. ; if so stop printing:
  27.         cmp     al, 0          
  28.         je      stop
  29.  
  30. ; print character in teletype mode:
  31.         mov     ah, 0eh
  32.         int     10h
  33.  
  34. ; update index register by 1:
  35.         inc     si
  36.  
  37. ; go back to print another char:
  38.         jmp     next_char
  39.  
  40.  
  41. stop:  mov ah, 0  ; wait for any key press.
  42.        int 16h
  43.  
  44. ; exit here and return control to operating system...
  45.         ret    
  46.  
  47. end     ; to stop compiler.
  48.  
  49. this text is not compiled and is not checked for errors,
  50. because it is after the end directive;
  51. however, syntax highlight still works here.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement