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