|
|
1.1 ! root 1: page 60,132 ! 2: .model large ! 3: ! 4: ; Put character to console (local) ! 5: ! 6: .data ! 7: wid db 79 ;columns per screen (zero based) ! 8: lps db 24 ;lines per screen (zero based) ! 9: col db 0 ;current column ! 10: lin db 0 ;current line ! 11: atr db 7 ;current attribute ! 12: pag db 0 ;current display page ! 13: ! 14: .code ! 15: .8086 ! 16: ! 17: public _lputc,_lputs,_lclini,_lclxy,_lclwx,_lclwy,_lclatr ! 18: ! 19: _lclini proc ! 20: push bp ! 21: mov bp,sp ! 22: mov ax,[bp+6] ;fetch parameter 1 (16-bit int) ! 23: dec al ! 24: mov lps,al ;set lines per screen ! 25: mov ah,0fh ! 26: int 10h ;get video mode ! 27: dec ah ! 28: mov wid,ah ;set screen width ! 29: mov pag,bh ;set current display page ! 30: mov ah,3 ! 31: int 10h ;get cursor position ! 32: cmp dh,lps ! 33: jc cuupd ;current line within range ! 34: mov dh,lps ;else set to maximum ! 35: cuupd: mov ah,2 ;set cursor and update current pointers ! 36: int 10h ;move cursor to last line ! 37: mov col,dx ;set current column and line ! 38: xor ax,ax ! 39: pop bp ! 40: ret ! 41: _lclini endp ! 42: ! 43: _lclxy proc ! 44: push bp ! 45: mov bp,sp ! 46: mov dx,[bp+6] ;get parameter 1, x (column) ! 47: dec dl ! 48: mov col,dl ! 49: mov ax,[bp+8] ;get parameter 2, y (line) ! 50: dec al ! 51: mov lin,al ! 52: mov dh,al ! 53: mov bh,pag ! 54: mov ah,2 ! 55: int 10h ;set cursor ! 56: xor ax,ax ! 57: pop bp ! 58: ret ! 59: _lclxy endp ! 60: ! 61: _lclwx proc ! 62: xor ah,ah ! 63: mov al,col ;return x (column) ! 64: inc al ! 65: ret ! 66: _lclwx endp ! 67: ! 68: _lclwy proc ! 69: xor ah,ah ! 70: mov al,lin ;return y (line) ! 71: inc al ! 72: ret ! 73: _lclwy endp ! 74: ! 75: _lclatr proc ! 76: push bp ! 77: mov bp,sp ! 78: xor ah,ah ! 79: mov al,atr ;get old attribute in ax ! 80: mov dx,[bp+6] ;fetch parameter 1 (16-bit int) ! 81: mov atr,dl ;set current attribute ! 82: pop bp ! 83: ret ! 84: _lclatr endp ! 85: ! 86: _lputc proc ! 87: push bp ! 88: mov bp,sp ! 89: mov ax,[bp+6] ;fetch parameter 1 (16-bit int) ! 90: ! 91: cmp ax,100h ! 92: jz clreol ;clear to end of line ! 93: cmp al,7 ! 94: jz outbl ;bell ! 95: cmp al,8 ! 96: jz outbs ;backspace ! 97: cmp al,10 ! 98: jz outlf ;line feed ! 99: cmp al,12 ! 100: jz outcs ;screen clear ! 101: cmp al,13 ! 102: jnz nonctl ;carriage return ! 103: mov col,0 ;set column zero ! 104: jmp updc ! 105: ! 106: clreol: mov ax,920h ! 107: mov bx,atr ;get page (bh) and attribute (bl) ! 108: mov cl,wid ;line length ! 109: sub cl,col ;get remainder ! 110: inc cl ;include current position ! 111: xor ch,ch ;replication factor in cx ! 112: int 10h ;clear to end of line ! 113: jmp pexit ! 114: ! 115: outbs: mov al,col ! 116: or al,al ! 117: jz pexit ;at column zero, no action ! 118: dec col ! 119: jmp updc ;move cursor back one column ! 120: ! 121: outbl: mov ax,0e07h ;write in tty mode (ah) bell (al) ! 122: mov bx,atr ;get page (bh) and attribute (bl) ! 123: int 10h ;beep ! 124: jmp updc ;make sure cursor is not changed ! 125: ! 126: outcs: mov ax,600h ;scroll (clear screen) ! 127: mov bh,atr ;current attribute ! 128: xor cx,cx ;upper left corner of window (0,0) ! 129: mov dx,wid ;lower right corner of window (wid,lps) ! 130: int 10h ;scroll window up one line ! 131: mov col,cx ;new cursor ! 132: jmp updc ! 133: ! 134: nonctl: mov ah,9 ! 135: mov bx,atr ;get page (bh) and attribute (bl) ! 136: mov cx,1 ! 137: int 10h ;write char and attr at cursor position ! 138: mov ah,col ! 139: inc col ;advance cursor on line ! 140: cmp ah,wid ! 141: jc updc ;not at end of line, update cursor and exit ! 142: ! 143: mov col,0 ;set column zero (cr) ! 144: outlf: mov ah,lin ! 145: cmp ah,lps ! 146: jc upda ;not at end of screen, update cursor and exit ! 147: jnz updn ;past end of screen, cr only ! 148: ! 149: mov ax,601h ;scroll (ah) number of lines (al) ! 150: mov bh,atr ;current attribute ! 151: xor cx,cx ;upper left corner of window (0,0) ! 152: mov dx,wid ;lower right corner of window (wid,lps) ! 153: int 10h ;scroll window up one line ! 154: ! 155: updn: dec lin ;leave current line number unchanged ! 156: upda: inc lin ;advance to next line ! 157: updc: mov ah,2 ! 158: mov bh,pag ! 159: mov dx,col ! 160: int 10h ;update cursor position ! 161: ! 162: pexit: xor ax,ax ;return zero ! 163: pop bp ! 164: ret ! 165: _lputc endp ! 166: ! 167: _lputs proc ! 168: push bp ! 169: mov bp,sp ! 170: push es ! 171: mov ax,[bp+8] ;string segment ! 172: mov bx,[bp+6] ;string offset ! 173: mov es,ax ! 174: xor dh,dh ! 175: nxtch: mov dl,es:[bx] ;character to output ! 176: or dl,dl ! 177: jz sexit ! 178: ! 179: inc bx ;address next character ! 180: jnz nowrap ! 181: mov ax,es ! 182: add ax,100h ;add 64k to segment pointer ! 183: mov es,ax ! 184: nowrap: push bx ;save offset ! 185: push dx ;arg 1 ! 186: call _lputc ;put character ! 187: pop dx ! 188: pop bx ! 189: jmp nxtch ! 190: ! 191: sexit: mov ax,[bp+6] ! 192: mov dx,[bp+8] ! 193: pop es ! 194: pop bp ! 195: ret ! 196: _lputs endp ! 197: ! 198: end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.