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

  1.  
  2. ;   FILENAME: IWRITEPS.ASM
  3. ;
  4. ;   Copyright (c) 1988 by Borland International
  5. ;
  6. ;   DESCRIPTION: This module implements a routine that displays Turbo Pascal
  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 iwriteps
  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 of
  17. ;   286/386 specific instructions. For example:
  18. ;
  19. ;       TASM /dMDL=memorymodel /jP286 iwriteps
  20. ;
  21. ;   NOTE: This module requires that main program define the identifier
  22. ;   DisplayPage and initialize it.
  23.  
  24. %tabsize 4
  25.  
  26. ifndef  MDL
  27.     display "Error: This module requires that you provide a memory model"
  28.     display "       definition on the command line. I.E. /dMDL=SMALL."
  29.     err ; Force a fatal error
  30. else
  31.  
  32.     ideal                       ; Use TASM's Ideal mode
  33.     model   MDL             ; Define the memory model
  34.  
  35.     include "imacros.mac"
  36.     include "dos.inc"
  37.     include "idos.mac"      ; Include DOS interface macros
  38.     include "ibios.mac"
  39.     include "bios.inc"
  40.  
  41.     dataseg
  42.     global  DisplayPage:byte        ; declare extrn variable
  43.  
  44.     codeseg
  45.  
  46.     global  WritePascalString:proc  ; declare public proc
  47.  
  48.     proc    WritePascalString
  49.  
  50.     ;   This routine displays a string to the screen by calling the BIOS
  51.     ;   service to display a character in TTY mode. It expects a far pointer
  52.     ;   to the string to be passed on the stack. Note that the length of the
  53.     ;   string is limited to 255 bytes.
  54.     ;
  55.     ;   Input
  56.     ;       StrAddress - Far pointer to string to display
  57.     ;   Output
  58.     ;       none
  59.     ;   Calling convention
  60.     ;       Pascal
  61.     ;   Registers modified
  62.     ;       di, es, Flags
  63.  
  64.     ARG StrAddress:dword=ParamSize  ; Define parameters passed on the stack
  65.  
  66.         push    bp
  67.         mov     bp, sp
  68.         xor     cx, cx
  69.         les     di, [StrAddress]    ; Get the address of the string
  70.         mov     cl, [byte es:di]    ; Get the length of the string
  71.         inc     di                  ; Point to the first character to display
  72.         jcxz    short Exit
  73.     DisplayChar:                    ; Display the next character
  74.         CharacterOutput <[byte es:di]>
  75.         inc     di                  ; Point to the next character
  76.         loop    DisplayChar
  77.     Exit:
  78.         pop     bp
  79.         ret     ParamSize           ; Clean up the stack since we're using
  80.                                     ; Pascal calling conventions
  81.     endp    WritePascalString
  82.  
  83. endif   ; ifndef MDL
  84.  
  85. end
  86.