|
|
1.1 ! root 1: Microsoft (R) Macro Assembler Version 5.10 3/15/92 16:16:11 ! 2: lclol Page 1-1 ! 3: ! 4: ! 5: ;************************************************************************ ! 6: ;* * ! 7: ;* lclol: direct BIOS interface console output for C * ! 8: ;* * ! 9: ;* prototypes: int lclini(int); initialize * ! 10: ;* int lclatr(int); set attributes * ! 11: ;* void lclxy(int,int); set cursor position * ! 12: ;* int lclwx(void); get current column * ! 13: ;* int lclwy(void); get current line * ! 14: ;* void putlch(int); put character * ! 15: ;* long putls(char far *); put string * ! 16: ;* * ! 17: ;************************************************************************ ! 18: ! 19: setmod %mm ! 20: .data ! 21: 0000 4F wid db 79 ;columns per screen (zero based) ! 22: 0001 18 lps db 24 ;lines per screen (zero based) ! 23: 0002 00 col db 0 ;current column ! 24: 0003 00 lin db 0 ;current line ! 25: 0004 07 atr db 7 ;current attribute ! 26: 0005 00 pag db 0 ;current display page ! 27: 0006 00 xla db 0 ;tab expansion (bit 1), lf->cr/lf (bit 0) ! 28: ! 29: .code ! 30: public _putlch,_putls,_lclini,_lclxy,_lclwx,_lclwy,_lclatr ! 31: ! 32: ; Initialize ! 33: ; Gets current cursor position, attribute, and display page ! 34: ; from BIOS. Integer argument defines the size of the screen. ! 35: ! 36: 0000 _lclini proc ! 37: 0000 55 push bp ! 38: 0001 8B EC mov bp,sp ! 39: 0003 8B 46 06 mov ax,pb[bp] ;fetch parameter 1 (16-bit int) ! 40: 0006 0A E4 or ah,ah ! 41: 0008 74 06 jz noxla ;no translation change ! 42: ! 43: 000A D0 EC shr ah,1 ! 44: 000C 88 26 0006 R mov xla,ah ;set new translation flags ! 45: 0010 FE C8 noxla: dec al ! 46: 0012 79 0F jns clps ;lines specified ! 47: ! 48: 0014 1E push ds ! 49: 0015 33 C0 xor ax,ax ! 50: 0017 8E D8 mov ds,ax ! 51: 0019 A0 0484 mov al,ds:[484h] ;get parameter from BIOS ! 52: 001C 0A C0 or al,al ! 53: 001E 75 02 jnz blps ;use BIOS value if non-zero ! 54: 0020 B0 18 mov al,24 ;else 25 assume lines ! 55: 0022 1F blps: pop ds ! 56: 0023 A2 0001 R clps: mov lps,al ;set lines per screen ! 57: 0026 B4 0F mov ah,0fh ! 58: 0028 CD 10 int 10h ;get video mode ! 59: 002A FE CC dec ah ! 60: 002C 88 26 0000 R mov wid,ah ;set screen width ! 61: Microsoft (R) Macro Assembler Version 5.10 3/15/92 16:16:11 ! 62: lclol Page 1-2 ! 63: ! 64: ! 65: 0030 88 3E 0005 R mov pag,bh ;set current display page ! 66: 0034 B4 03 mov ah,3 ! 67: 0036 CD 10 int 10h ;get cursor position ! 68: 0038 3A 36 0001 R cmp dh,lps ! 69: 003C 72 04 jc cuupd ;current line within range ! 70: 003E 8A 36 0001 R mov dh,lps ;else set to maximum ! 71: 0042 B4 02 cuupd: mov ah,2 ;set cursor and update current pointers ! 72: 0044 CD 10 int 10h ;move cursor to last line ! 73: 0046 89 16 0002 R mov col,dx ;set current column and line ! 74: 004A 32 E4 xor ah,ah ! 75: 004C A0 0001 R mov al,lps ! 76: 004F FE C0 inc al ;return number of lines set ! 77: 0051 5D pop bp ! 78: 0052 CB ret ! 79: 0053 _lclini endp ! 80: ! 81: ; Set current cursor position ! 82: ! 83: 0053 _lclxy proc ! 84: 0053 55 push bp ! 85: 0054 8B EC mov bp,sp ! 86: 0056 8B 56 06 mov dx,pb[bp] ;get parameter 1, x (column) ! 87: 0059 FE CA dec dl ! 88: 005B 88 16 0002 R mov col,dl ! 89: 005F 8B 46 08 mov ax,pb[bp+2] ;get parameter 2, y (line) ! 90: 0062 FE C8 dec al ! 91: 0064 A2 0003 R mov lin,al ! 92: 0067 8A F0 mov dh,al ! 93: 0069 8A 3E 0005 R mov bh,pag ! 94: 006D B4 02 mov ah,2 ! 95: 006F CD 10 int 10h ;set cursor ! 96: 0071 33 C0 xor ax,ax ! 97: 0073 5D pop bp ! 98: 0074 CB ret ! 99: 0075 _lclxy endp ! 100: ! 101: ; Get current cursor position (x,y) ! 102: ! 103: 0075 _lclwx proc ! 104: 0075 32 E4 xor ah,ah ! 105: 0077 A0 0002 R mov al,col ;return x (column) ! 106: 007A FE C0 inc al ! 107: 007C CB ret ! 108: 007D _lclwx endp ! 109: ! 110: 007D _lclwy proc ! 111: 007D 32 E4 xor ah,ah ! 112: 007F A0 0003 R mov al,lin ;return y (line) ! 113: 0082 FE C0 inc al ! 114: 0084 CB ret ! 115: 0085 _lclwy endp ! 116: ! 117: ; Set local attributes ! 118: ! 119: 0085 _lclatr proc ! 120: 0085 55 push bp ! 121: Microsoft (R) Macro Assembler Version 5.10 3/15/92 16:16:11 ! 122: lclol Page 1-3 ! 123: ! 124: ! 125: 0086 8B EC mov bp,sp ! 126: 0088 32 E4 xor ah,ah ! 127: 008A A0 0004 R mov al,atr ;get old attribute in ax ! 128: 008D 8B 56 06 mov dx,pb[bp] ;fetch parameter 1 (16-bit int) ! 129: 0090 88 16 0004 R mov atr,dl ;set current attribute ! 130: 0094 5D pop bp ! 131: 0095 CB ret ! 132: 0096 _lclatr endp ! 133: ! 134: ; Put character to console (local) ! 135: ! 136: 0096 _putlch proc ! 137: 0096 55 push bp ! 138: 0097 8B EC mov bp,sp ! 139: 0099 8B 46 06 mov ax,pb[bp] ;fetch parameter 1 (16-bit int) ! 140: ! 141: 009C 3D 0100 cmp ax,100h ! 142: 009F 74 3A jz clreol ;clear to end of line ! 143: 00A1 3C 07 cmp al,7 ! 144: 00A3 75 0C jnz notbl ;bell ! 145: ! 146: 00A5 B8 0E07 mov ax,0e07h ;write in tty mode (ah) bell (al) ! 147: 00A8 8B 1E 0004 R mov bx,atr ;get page (bh) and attribute (bl) ! 148: 00AC CD 10 int 10h ;beep ! 149: 00AE E9 017D R jmp updc ;make sure cursor is not changed ! 150: ! 151: 00B1 3C 08 notbl: cmp al,8 ! 152: 00B3 75 0E jnz notbs ;backspace ! 153: ! 154: 00B5 A0 0002 R mov al,col ! 155: 00B8 0A C0 or al,al ! 156: 00BA 74 34 jz pexitj ;at column zero, no action ! 157: 00BC FE 0E 0002 R dec col ! 158: 00C0 E9 017D R jmp updc ;move cursor back one column ! 159: ! 160: 00C3 3C 09 notbs: cmp al,9 ! 161: 00C5 74 2C jz outtb ;horizontal tab ! 162: 00C7 3C 0C cmp al,12 ! 163: 00C9 74 4F jz outcs ;screen clear ! 164: 00CB 3C 0A cmp al,10 ! 165: 00CD 74 7F jz outlf ;line feed ! 166: 00CF 3C 0D cmp al,13 ! 167: 00D1 75 5D jnz nonctl ;carriage return ! 168: 00D3 C6 06 0002 R 00 mov col,0 ;set column zero ! 169: 00D8 E9 017D R jmp updc ! 170: ! 171: 00DB B8 0920 clreol: mov ax,920h ! 172: 00DE 8B 1E 0004 R mov bx,atr ;get page (bh) and attribute (bl) ! 173: 00E2 8A 0E 0000 R mov cl,wid ;line length ! 174: 00E6 2A 0E 0002 R sub cl,col ;get remainder ! 175: 00EA FE C1 inc cl ;include current position ! 176: 00EC 32 ED xor ch,ch ;replication factor in cx ! 177: 00EE CD 10 int 10h ;clear to end of line ! 178: 00F0 E9 0189 R pexitj: jmp pexit ! 179: ! 180: 00F3 F6 06 0006 R 02 outtb: test xla,2 ! 181: Microsoft (R) Macro Assembler Version 5.10 3/15/92 16:16:11 ! 182: lclol Page 1-4 ! 183: ! 184: ! 185: 00F8 74 36 jz nonctl ;no tab expansion ! 186: 00FA A0 0002 R mov al,col ! 187: 00FD 24 07 and al,7 ! 188: 00FF B1 08 mov cl,8 ! 189: 0101 2A C8 sub cl,al ! 190: 0103 32 ED xor ch,ch ;number of spaces in cx ! 191: 0105 B0 20 mov al,20h ! 192: 0107 51 tbexp: push cx ! 193: 0108 50 push ax ;parameter 1 ! 194: 0109 9A 0096 ---- R call _putlch ! 195: 010E 58 pop ax ! 196: 010F 59 pop cx ! 197: 0110 80 3E 0002 R 00 cmp col,0 ! 198: 0115 E0 F0 loopnz tbexp ;stop if cursor wraps ! 199: 0117 EB 70 90 jmp pexit ! 200: ! 201: 011A B8 0600 outcs: mov ax,600h ;scroll (clear screen) ! 202: 011D 8A 3E 0004 R mov bh,atr ;current attribute ! 203: 0121 33 C9 xor cx,cx ;upper left corner of window (0,0) ! 204: 0123 8B 16 0000 R mov dx,wid ;lower right corner of window (wid,lps) ! 205: 0127 CD 10 int 10h ;scroll window up one line ! 206: 0129 89 0E 0002 R mov col,cx ;new cursor ! 207: 012D EB 4E 90 jmp updc ! 208: ! 209: 0130 B4 09 nonctl: mov ah,9 ! 210: 0132 8B 1E 0004 R mov bx,atr ;get page (bh) and attribute (bl) ! 211: 0136 B9 0001 mov cx,1 ! 212: 0139 CD 10 int 10h ;write char and attr at cursor position ! 213: 013B 8A 26 0002 R mov ah,col ! 214: 013F FE 06 0002 R inc col ;advance cursor on line ! 215: 0143 3A 26 0000 R cmp ah,wid ! 216: 0147 72 34 jc updc ;not at end of line, update cursor and exit ! 217: ! 218: 0149 C6 06 0002 R 00 mov col,0 ;set column zero (cr) ! 219: 014E F6 06 0006 R 01 outlf: test xla,1 ! 220: 0153 74 05 jz nocrlf ;send lf alone ! 221: 0155 C6 06 0002 R 00 mov col,0 ! 222: 015A 8A 26 0003 R nocrlf: mov ah,lin ! 223: 015E 3A 26 0001 R cmp ah,lps ! 224: 0162 72 15 jc upda ;not at end of screen, update cursor and exit ! 225: 0164 75 0F jnz updn ;past end of screen, cr only ! 226: ! 227: 0166 B8 0601 mov ax,601h ;scroll (ah) number of lines (al) ! 228: 0169 8A 3E 0004 R mov bh,atr ;current attribute ! 229: 016D 33 C9 xor cx,cx ;upper left corner of window (0,0) ! 230: 016F 8B 16 0000 R mov dx,wid ;lower right corner of window (wid,lps) ! 231: 0173 CD 10 int 10h ;scroll window up one line ! 232: ! 233: 0175 FE 0E 0003 R updn: dec lin ;leave current line number unchanged ! 234: 0179 FE 06 0003 R upda: inc lin ;advance to next line ! 235: 017D B4 02 updc: mov ah,2 ! 236: 017F 8A 3E 0005 R mov bh,pag ! 237: 0183 8B 16 0002 R mov dx,col ! 238: 0187 CD 10 int 10h ;update cursor position ! 239: ! 240: 0189 33 C0 pexit: xor ax,ax ;return zero ! 241: Microsoft (R) Macro Assembler Version 5.10 3/15/92 16:16:11 ! 242: lclol Page 1-5 ! 243: ! 244: ! 245: 018B 5D pop bp ! 246: 018C CB ret ! 247: 018D _putlch endp ! 248: ! 249: ; Put string to console (uses _putlch for each character) ! 250: ! 251: 018D _putls proc ! 252: 018D 55 push bp ! 253: 018E 8B EC mov bp,sp ! 254: 0190 06 push es ! 255: 0191 8B 46 08 mov ax,pb[bp+2] ;string segment ! 256: 0194 8B 5E 06 mov bx,pb[bp] ;string offset ! 257: 0197 8E C0 mov es,ax ! 258: 0199 32 F6 xor dh,dh ! 259: 019B 26: 8A 17 nxtch: mov dl,es:[bx] ;character to output ! 260: 019E 0A D2 or dl,dl ! 261: 01A0 74 15 jz sexit ! 262: ! 263: 01A2 43 inc bx ;address next character ! 264: 01A3 75 07 jnz nowrap ! 265: 01A5 8C C0 mov ax,es ! 266: 01A7 05 0100 add ax,100h ;add 64k to segment pointer ! 267: 01AA 8E C0 mov es,ax ! 268: 01AC 53 nowrap: push bx ;save offset ! 269: 01AD 52 push dx ;arg 1 ! 270: 01AE 9A 0096 ---- R call _putlch ;put character ! 271: 01B3 5A pop dx ! 272: 01B4 5B pop bx ! 273: 01B5 EB E4 jmp nxtch ! 274: ! 275: 01B7 8B 46 06 sexit: mov ax,pb[bp] ! 276: 01BA 8B 56 08 mov dx,pb[bp+2] ! 277: 01BD 07 pop es ! 278: 01BE 5D pop bp ! 279: 01BF CB ret ! 280: 01C0 _putls endp ! 281: ! 282: end ! 283: ! 284: Microsoft (R) Macro Assembler Version 5.10 3/15/92 16:16:11 ! 285: lclol Symbols-1 ! 286: ! 287: ! 288: Macros: ! 289: ! 290: N a m e Lines ! 291: ! 292: ASYN . . . . . . . . . . . . . . 3 ! 293: DSS . . . . . . . . . . . . . . 4 ! 294: EOPG . . . . . . . . . . . . . . 2 ! 295: LISTON . . . . . . . . . . . . . 1 ! 296: SETMOD . . . . . . . . . . . . . 9 ! 297: ! 298: Segments and Groups: ! 299: ! 300: N a m e Size Length Align Combine Class ! 301: ! 302: DGROUP . . . . . . . . . . . . . GROUP ! 303: _DATA . . . . . . . . . . . . 16 Bit 0007 WORD PUBLIC 'DATA' ! 304: LCLOL_TEXT . . . . . . . . . . . 16 Bit 01C0 WORD PUBLIC 'CODE' ! 305: ! 306: Symbols: ! 307: ! 308: N a m e Type Value Attr ! 309: ! 310: AA . . . . . . . . . . . . . . . TEXT .model large ! 311: ATR . . . . . . . . . . . . . . L BYTE 0004 _DATA ! 312: ! 313: BLPS . . . . . . . . . . . . . . L NEAR 0022 LCLOL_TEXT ! 314: ! 315: CLPS . . . . . . . . . . . . . . L NEAR 0023 LCLOL_TEXT ! 316: CLREOL . . . . . . . . . . . . . L NEAR 00DB LCLOL_TEXT ! 317: COL . . . . . . . . . . . . . . L BYTE 0002 _DATA ! 318: CUUPD . . . . . . . . . . . . . L NEAR 0042 LCLOL_TEXT ! 319: ! 320: DS1 . . . . . . . . . . . . . . TEXT label byte ! 321: DS2 . . . . . . . . . . . . . . TEXT label word ! 322: DS4 . . . . . . . . . . . . . . TEXT label dword ! 323: DS6 . . . . . . . . . . . . . . TEXT label fword ! 324: DS8 . . . . . . . . . . . . . . TEXT label qword ! 325: ! 326: LIN . . . . . . . . . . . . . . L BYTE 0003 _DATA ! 327: LPS . . . . . . . . . . . . . . L BYTE 0001 _DATA ! 328: ! 329: MB . . . . . . . . . . . . . . . TEXT byte ptr ! 330: MDLC . . . . . . . . . . . . . . TEXT compact ! 331: MDLH . . . . . . . . . . . . . . TEXT huge ! 332: MDLL . . . . . . . . . . . . . . TEXT large ! 333: MDLM . . . . . . . . . . . . . . TEXT medium ! 334: MDLS . . . . . . . . . . . . . . TEXT small ! 335: ML . . . . . . . . . . . . . . . TEXT dword ptr ! 336: MM . . . . . . . . . . . . . . . TEXT l ! 337: MW . . . . . . . . . . . . . . . TEXT word ptr ! 338: ! 339: NOCRLF . . . . . . . . . . . . . L NEAR 015A LCLOL_TEXT ! 340: NONCTL . . . . . . . . . . . . . L NEAR 0130 LCLOL_TEXT ! 341: NOTBL . . . . . . . . . . . . . L NEAR 00B1 LCLOL_TEXT ! 342: NOTBS . . . . . . . . . . . . . L NEAR 00C3 LCLOL_TEXT ! 343: Microsoft (R) Macro Assembler Version 5.10 3/15/92 16:16:11 ! 344: lclol Symbols-2 ! 345: ! 346: ! 347: NOWRAP . . . . . . . . . . . . . L NEAR 01AC LCLOL_TEXT ! 348: NOXLA . . . . . . . . . . . . . L NEAR 0010 LCLOL_TEXT ! 349: NXTCH . . . . . . . . . . . . . L NEAR 019B LCLOL_TEXT ! 350: ! 351: OS . . . . . . . . . . . . . . . TEXT offset ! 352: OUTCS . . . . . . . . . . . . . L NEAR 011A LCLOL_TEXT ! 353: OUTLF . . . . . . . . . . . . . L NEAR 014E LCLOL_TEXT ! 354: OUTTB . . . . . . . . . . . . . L NEAR 00F3 LCLOL_TEXT ! 355: ! 356: PAG . . . . . . . . . . . . . . L BYTE 0005 _DATA ! 357: PB . . . . . . . . . . . . . . . NUMBER 0006 ! 358: PEXIT . . . . . . . . . . . . . L NEAR 0189 LCLOL_TEXT ! 359: PEXITJ . . . . . . . . . . . . . L NEAR 00F0 LCLOL_TEXT ! 360: ! 361: S . . . . . . . . . . . . . . . TEXT short ! 362: SEXIT . . . . . . . . . . . . . L NEAR 01B7 LCLOL_TEXT ! 363: ! 364: TBEXP . . . . . . . . . . . . . L NEAR 0107 LCLOL_TEXT ! 365: ! 366: UPDA . . . . . . . . . . . . . . L NEAR 0179 LCLOL_TEXT ! 367: UPDC . . . . . . . . . . . . . . L NEAR 017D LCLOL_TEXT ! 368: UPDN . . . . . . . . . . . . . . L NEAR 0175 LCLOL_TEXT ! 369: ! 370: WID . . . . . . . . . . . . . . L BYTE 0000 _DATA ! 371: ! 372: XLA . . . . . . . . . . . . . . L BYTE 0006 _DATA ! 373: ! 374: @CODE . . . . . . . . . . . . . TEXT lclol_TEXT ! 375: @CODESIZE . . . . . . . . . . . TEXT 1 ! 376: @CPU . . . . . . . . . . . . . . TEXT 257 ! 377: @DATASIZE . . . . . . . . . . . TEXT 1 ! 378: @FILENAME . . . . . . . . . . . TEXT lclol ! 379: @VERSION . . . . . . . . . . . . TEXT 510 ! 380: _lclatr . . . . . . . . . . . . F PROC 0085 LCLOL_TEXT Global Length = 0011 ! 381: _lclini . . . . . . . . . . . . F PROC 0000 LCLOL_TEXT Global Length = 0053 ! 382: _lclwx . . . . . . . . . . . . . F PROC 0075 LCLOL_TEXT Global Length = 0008 ! 383: _lclwy . . . . . . . . . . . . . F PROC 007D LCLOL_TEXT Global Length = 0008 ! 384: _lclxy . . . . . . . . . . . . . F PROC 0053 LCLOL_TEXT Global Length = 0022 ! 385: _putlch . . . . . . . . . . . . F PROC 0096 LCLOL_TEXT Global Length = 00F7 ! 386: _putls . . . . . . . . . . . . . F PROC 018D LCLOL_TEXT Global Length = 0033 ! 387: ! 388: ! 389: 338 Source Lines ! 390: 351 Total Lines ! 391: 74 Symbols ! 392: ! 393: 47354 + 412354 Bytes symbol space free ! 394: ! 395: 0 Warning Errors ! 396: 0 Severe Errors
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.