home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / Fortran.51 / DISK5 / DOS / NMSGHDR.AS$ / NMSGHDR.bin
Text File  |  1989-10-24  |  3KB  |  179 lines

  1.     page    ,132
  2.     title    nmsghdr - near message handler and finder
  3. ;***
  4. ;nmsghdr.asm - near message handler and finder
  5. ;
  6. ;    Copyright (c) 1986-1990, Microsoft Corporation.  All rights reserved.
  7. ;
  8. ;Purpose:
  9. ;    Near message handler and finder.
  10. ;
  11. ;*******************************************************************************
  12.  
  13.  
  14. ?DF=    1            ; this is special for c startup
  15. include version.inc
  16. ?PLM=    1            ; pascal calling conventions
  17. .xlist
  18. include cmacros.inc
  19. include msdos.inc
  20. .list
  21.  
  22. createSeg _TEXT, code,    word,    public, CODE,    <>
  23.  
  24. createSeg _DATA, data,    word,    public, DATA,    DGROUP
  25.  
  26. createSeg HDR,    nhdr,    byte,    public, MSG,    DGROUP
  27. createSeg MSG,    nmsg,    byte,    public, MSG,    DGROUP
  28. createSeg PAD,    npad,    byte,    common, MSG,    DGROUP
  29. createSeg EPAD, nepad,    byte,    common, MSG,    DGROUP
  30.  
  31. createSeg    DBDATA, dbdata, word, common, DATA, DGROUP ;*
  32.  
  33. defGrp    DGROUP            ; define DGROUP
  34.  
  35. codeOFFSET equ    offset _TEXT:
  36. dataOFFSET equ    offset DGROUP:
  37.  
  38.  
  39. sBegin    nhdr
  40. assumes ds,data
  41.  
  42.     db    '<<NMSG>>'
  43.  
  44.  
  45. stnmsg    label    byte
  46.  
  47. sEnd
  48.  
  49. sBegin    npad
  50. assumes ds,data
  51.  
  52.     dw    -1        ; message padding marker
  53.  
  54. sEnd
  55.  
  56. sBegin    nepad
  57. assumes ds,data
  58.  
  59.     db    -1
  60.  
  61. sEnd
  62.  
  63. sBegin    dbdata                ;*
  64.     assumes    ds,data            ;*  Used to do the running under
  65. externW        ___aDBswpflg        ;*  a debugger screen swapping
  66. externW        ___aDBswpchk        ;*
  67. sEnd    dbdata                ;*
  68.     extrn    __aDBdoswp:ABS        ;*
  69.  
  70.  
  71. sBegin    code
  72. assumes cs,code
  73. assumes ds,data
  74.  
  75. page
  76. ;***
  77. ;__NMSG_TEXT(messagenumber) - find message for given message number
  78. ;
  79. ;Purpose:
  80. ;    This routine returns a near pointer to the message associated with
  81. ;    messagenumber.    If the message does not exist, then a 0 is returned.
  82. ;
  83. ;    This routine assumes DS = DGROUP
  84. ;
  85. ;Entry:
  86. ;    ==PASCAL CALLING CONVENTIONS==
  87. ;    messagenumber = WORD message number of desired message
  88. ;
  89. ;Exit:
  90. ;    AX    = pointer to message text or 0 if no message exists.
  91. ;
  92. ;Uses:
  93. ;
  94. ;Exceptions:
  95. ;
  96. ;*******************************************************************************
  97.  
  98. cProc    __NMSG_TEXT,<PUBLIC>,<si,di>  ; pascal calling
  99.  
  100.     parmW    msgt
  101.  
  102. cBegin
  103.     push    ds
  104.     pop    es
  105.     mov    dx,msgt     ; dx = message number
  106.     mov    si,dataOFFSET stnmsg ; start of near messages
  107.  
  108. tloop:
  109.     lodsw            ; ax = current message number
  110.     cmp    ax,dx
  111.     je    found        ;   found it - return address
  112.     inc    ax
  113.     xchg    ax,si
  114.     jz    found        ;   at end and not found - return 0
  115.     xchg    di,ax
  116.     xor    ax,ax
  117.     mov    cx,-1
  118.     repne    scasb        ; skip until 00
  119.     mov    si,di
  120.     jmp    tloop        ; try next entry
  121.  
  122. found:
  123.     xchg    ax,si
  124. cEnd
  125.  
  126.  
  127. page
  128. ;***
  129. ;__NMSGWRITE(messagenumber) - writes message on stderr
  130. ;
  131. ;Purpose:
  132. ;    This routine writes the message associated with messagenumber
  133. ;    to stderr.
  134. ;
  135. ;Entry:
  136. ;    ==PASCAL CALLING CONVENTIONS==
  137. ;    messagenumber = WORD number of desired message
  138. ;
  139. ;Exit:
  140. ;
  141. ;Uses:
  142. ;
  143. ;Exceptions:
  144. ;
  145. ;*******************************************************************************
  146.  
  147. cProc    __NMSG_WRITE,<PUBLIC>,<di>  ; pascal calling
  148.  
  149.     parmW    msgw
  150.  
  151. cBegin
  152.     push    msgw
  153.     callcrt __NMSG_TEXT    ; find near text pointer
  154.     or    ax,ax
  155.     jz    nowrite     ; don't write anything if not there
  156.  
  157.  
  158.     xchg    dx,ax        ; ds:dx = string address
  159.     mov    di,dx
  160.     xor    ax,ax
  161.     mov    cx,-1
  162.     repne    scasb        ; es = ds from __NMSG_TEXT
  163.     not    cx
  164.     dec    cx        ; cx = string length
  165.     mov    bx,2
  166.     cmp    ___aDBswpflg,__aDBdoswp    ;* Aware debugger as parent?
  167.     jne    @F            ;* No -- skip
  168.     call    ___aDBswpchk        ;* Yes -- see if we need to swap screens
  169. @@:
  170.     callos    write
  171.  
  172.  
  173. nowrite:
  174. cEnd
  175.  
  176. sEnd
  177.  
  178.     end
  179.