home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / ASM / STRTUP10.ZIP / STARTUP.ZIP / LIBSRC / PRINT.ASM < prev    next >
Encoding:
Assembly Source File  |  1997-02-28  |  2.6 KB  |  133 lines

  1.     page 60, 132
  2.     title    PRINT - A String Printing Procedure
  3.     name    PRINT
  4. comment ÷
  5.     PRINT                            V1.00
  6. ==========================================================================
  7. NAME
  8.     PRINT - A String Printing Procedure
  9.  
  10. SYNOPSIS
  11.     mov    ax, seg STRING        ; only if STRING not in DS segment
  12.     mov    ds, ax
  13.     mov    dx, offset STRING
  14.     call    PRINT
  15.  
  16. DESCRIPTION
  17.        This procedure prints the passed ASCIIZ string, DS:DX, to stdout.
  18.  
  19. CAUTION
  20.     Must be ASCIIZ string.
  21.  
  22. RETURNS
  23.     Nothing.
  24.  
  25. PROGRAMMING NOTES
  26.     Assembled with Microsoft MASM V6.11a
  27.  
  28. REGISTER USAGE
  29.     Small Data Memory Models:
  30.     AX, BX, CX, DX, and DI.
  31.  
  32.     Additional registers used in Large Data Memory Models:
  33.     ES.  ES register is preserved.
  34.  
  35. MEMORY UTILIZATION
  36.     DATA
  37.         None
  38.     CODE
  39.                     8086    80286+
  40.         Small Code Model:           20
  41.         Large Code model:           26
  42.  
  43.     STACK
  44.         Small Code Model:            4
  45.         Large Code model:            6
  46.  
  47. EXTERNAL LIBRARIES
  48.     None
  49.     
  50. EXTERNAL PROCEDURES
  51.     None
  52.  
  53. INTERUPTS CALLED
  54.     Int 21h Function 40h - Write File or Device
  55.  
  56. GLOBAL NAMES
  57.     PRINT
  58.  
  59. AUTHOR
  60.     Raymond Moon - 6 Oct 95
  61.  
  62.     Copyright (c) 1995 - Raymond Moon
  63.     ALL RIGHTS RESERVED
  64.  
  65. HISTORY
  66.     Version    - Date        - Remarks
  67.     1.00    -  6 Oct 95    - Orginal
  68. ==========================================================================
  69.     ÷ Commend End
  70.  
  71. ;----------------------------
  72. ; A    Make the small memory model the default.
  73.  
  74. ifndef    memmod
  75. memmod    equ    <small>
  76. endif
  77.  
  78. ;----------------------------
  79. ; B    Specify processor, memory model, language and ES register assume.
  80.  
  81.     include procesor.inc            ; Specify target processor
  82. %    .model memmod, fortran
  83.     assume es:DGROUP
  84.  
  85. ;=========================================================================
  86. ;    CODE
  87. ;=========================================================================
  88. ; C    Start Code Segment and define PRINT procedure
  89.  
  90.     .CODE
  91.  
  92. Print    proc
  93.  
  94. ;----------------------------
  95. ; D    If large data models, save ES and set ES to DS
  96.  
  97. if    @DataSize
  98.     push    es            ; Save ES
  99.     mov    ax, ds            ; AX = DS
  100.     mov    es, ax            ; ES = DS
  101. endif
  102.  
  103. ;----------------------------
  104. ; E    DS:DX => ASCIIZ string to print.  Need to determine the size.
  105.  
  106.     mov    cx, -1            ; Set CX to -1
  107.     xor    al, al            ; AL = Null
  108.     mov    di, dx            ; DI => string start
  109.     repne    scasb            ; Continue until Null found
  110.     not    cx            ; Convert CX to string length + 1
  111.     dec    cx            ; CX = length
  112.  
  113. ;----------------------------
  114. ; F    Display string to screen
  115.  
  116.     mov    ah, 40h
  117.     mov    bx, 1
  118.     int    21h
  119.  
  120. ;----------------------------
  121. ; G    Restore ES if required
  122.  
  123. if    @DataSize
  124.     pop    es            ; Restore ES
  125. endif
  126.  
  127. ;----------------------------
  128. ; H    Return
  129.  
  130.     ret
  131. Print    endp
  132.     end
  133.