home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 123.img / TASM.ZIP / PRNTSTR.ASM < prev    next >
Assembly Source File  |  1988-10-31  |  2KB  |  43 lines

  1.         DOSSEG
  2.         .MODEL   SMALL
  3.         .STACK   200h
  4.         .DATA
  5. WorldMessage     DB      'Hello, world!',0dh,0ah,0
  6. SolarMessage     DB      'Hello, solar system!',0dh,0ah,0
  7. UniverseMessage  DB      'Hello, universe!',0dh,0ah,0
  8.         .CODE
  9. ProgramStart     PROC    NEAR
  10.         mov   ax,@data
  11.         mov   ds,ax
  12.         mov   bx,OFFSET WorldMessage
  13.         call  PrintString                  ;print Hello, world!
  14.         mov   bx,OFFSET SolarMessage
  15.         call  PrintString                  ;print Hello, solar system!
  16.         mov   bx,OFFSET UniverseMessage
  17.         call  PrintString                  ;print Hello, universe!
  18.         mov   ah,4ch                       ;DOS terminate program fn #
  19.         int   21h                          ;...and done
  20. ProgramStart  ENDP
  21. ;
  22. ; Subroutine to print a null-terminated string on the screen.
  23. ;
  24. ; Input:
  25. ;       DS:BX - pointer to string to print.
  26. ;
  27. ; Registers destroyed: AX, BX
  28. ;
  29. PrintString      PROC    NEAR
  30. PrintStringLoop:
  31.         mov   dl,[bx]                      ;get the next character of the string
  32.         and   dl,dl                        ;is the character's value zero?
  33.         jz    EndPrintString               ;if so, then we're done with the
  34.                                            ; string
  35.         inc   bx                           ;point to the next character
  36.         mov   ah,2                         ;DOS display output function
  37.         int   21h                          ;invoke DOS to print the character
  38.         jmp   PrintStringLoop              ;print the next character, if any
  39. EndPrintString:
  40.         ret                                ;return to calling program
  41.         ENDP  PrintString
  42.         END   ProgramStart
  43.