print.asm 840 B

1234567891011121314151617181920212223242526272829303132
  1. ;;;
  2. ; print_string
  3. ; ------------
  4. ; Print a string from memory.
  5. ;
  6. ; Parameters:
  7. ; - bx: pointer to string
  8. ;
  9. ; Internal Variables:
  10. ; - ah: scrolling teletype BIOS routine code
  11. ; - al: Byte containing character to print
  12. ; - bx: shifting pointer to string
  13. print_string:
  14. pusha ; save the state of all registers to the stack
  15. mov ah, 0x0e ; scrolling teletype BIOS routine code
  16. print_string_start:
  17. mov al, [bx] ; load first letter into `al'
  18. cmp al, 0
  19. je print_string_end ; if null-termination then return
  20. int 0x10 ; print the letter
  21. add bx, 0x1 ; offset to next character
  22. jmp print_string_start ; go back to beginning
  23. print_string_end:
  24. mov al, 0xA
  25. int 0x10
  26. mov al, 0xD
  27. int 0x10
  28. popa ; return the state of all the registers
  29. ret