home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / tasm / iasciizs.asm < prev    next >
Assembly Source File  |  1988-08-28  |  2KB  |  80 lines

  1.  
  2. ;   FILENAME: IASCIIZS.ASM
  3. ;
  4. ;   Copyright (c) 1988 by Borland International
  5. ;
  6. ;   DESCRIPTION: This module implements a routine that displays ASCIIZ
  7. ;   style strings. The module uses Ideal mode syntax.
  8. ;
  9. ;   ASSEMBLY INSTRUCTIONS: To assemble this module use the following
  10. ;   TASM command line.
  11. ;
  12. ;       TASM /dMDL=memorymodel iasciizs
  13. ;
  14. ;   'memorymodel' in the above command line may be replaced by TINY, SMALL,
  15. ;   MEDIUM, COMPACT, LARGE or HUGE. If assembling this module to run on
  16. ;   a 286/386 machine, turn on the P286 directive in order to take advantage
  17. ;   of 286/386 specific instructions. For example:
  18. ;
  19. ;       TASM /dMDL=memorymodel /jP286 iasciizs
  20.  
  21. %tabsize 4
  22.  
  23. ifndef  MDL
  24.     display "Error: This module requires that you provide a memory model"
  25.     display "       definition on the command line. I.E. /dMDL=SMALL."
  26.     err ; Force a fatal error
  27. else
  28.  
  29.     ideal                   ; Use TASM's Ideal mode
  30.     model   MDL             ; Define the memory model
  31.  
  32.     include "imacros.mac"
  33.     include "dos.inc"
  34.     include "idos.mac"
  35.     include "bios.inc"
  36.     include "ibios.mac"
  37.  
  38.     dataseg
  39.     global  DisplayPage:byte        ; declare extrn variable
  40.  
  41.     codeseg
  42.  
  43.     global  WriteASCIIZString:proc  ; declare public proc
  44.  
  45.     proc    WriteASCIIZString
  46.  
  47.     ;   This routine displays a string to the screen by calling the BIOS
  48.     ;   service to display a character in TTY mode. It expects a far pointer
  49.     ;   to the string to be passed on the stack.
  50.     ;
  51.     ;   Input
  52.     ;       StrAddress - Far pointer to string to display
  53.     ;   Output
  54.     ;       none
  55.     ;   Calling convention
  56.     ;       Pascal
  57.     ;   Registers modified
  58.     ;       di, es, Flags
  59.  
  60.     ARG StrAddress:dword=ParamSize  ; Define parameters passed on the stack
  61.  
  62.         push    bp
  63.         mov     bp, sp
  64.         les     di, [StrAddress]    ; Get the address of the string
  65.     DisplayChar:                    ; Display the next character
  66.         cmp     [byte es:di], 0     ; Check for the terminating NULL character
  67.         je      Exit
  68.         CharacterOutput <[byte es:di]>
  69.         inc     di                  ; Point to the next character
  70.         jmp     DisplayChar
  71.     Exit:
  72.         pop     bp
  73.         ret     ParamSize           ; Clean up the stack since we're using
  74.                                     ; Pascal calling conventions
  75.     endp    WriteASCIIZString
  76.  
  77. endif   ; ifndef MDL
  78.  
  79. end
  80.