Annotation of coherent/d/PS2_KERNEL/io.286/mmas_vt.m, revision 1.1

1.1     ! root        1: / (lgl-
        !             2: /      COHERENT Driver Kit Version 1.1.0
        !             3: /      Copyright (c) 1982, 1990 by Mark Williams Company.
        !             4: /      All rights reserved. May not be copied without permission.
        !             5: / -lgl)
        !             6: ////////
        !             7: /
        !             8: /      Memory mapped video driver assembler assist.
        !             9: /
        !            10: ////////
        !            11: /
        !            12: /      virtual terminal additions Copyright 1991, 1992 Todd Fleming
        !            13: /      6/91, 1/92
        !            14: /
        !            15: /      Todd Fleming
        !            16: /      1991 Mountainside Drive
        !            17: /      Blacksburg, VA 24060
        !            18: /      
        !            19: ////////
        !            20: /
        !            21: / State driven code
        !            22: /
        !            23: /      Input:  DS:SI - input string
        !            24: /              ES:DI - current screen location
        !            25: /              SS:BP - terminal information
        !            26: /              CX    - input count
        !            27: /              BP    - references terminal information
        !            28: /              AH    - character attributes
        !            29: /              AL    - character
        !            30: /              BH    - (usually) kept zeroed for efficiency
        !            31: /              DH    - current row
        !            32: /              DL    - current column
        !            33: /
        !            34: ////////
        !            35: 
        !            36:        NCOL    = 80            / number of columns
        !            37:        NCB     = 2             / number of horizontal bytes per char
        !            38:        NCR     = 1             / number of horizontal lines per char
        !            39:        NHB     = 160           / number of horizontal bytes per line
        !            40:        NRB     = NCR*NHB       / number of bytes per character row
        !            41: 
        !            42:        hBUFSIZE = NCOL*25      / 1/2 buffer size for 25 row screen (TBF)
        !            43: 
        !            44:        ATTR    = ah            / attribute byte
        !            45:        ZERO    = bh            / (almost) always zero
        !            46:        ROW     = dh            / currently active vertical position
        !            47:        COL     = dl            / currently active horizontal position
        !            48:        POS     = di            / currently active display address
        !            49: 
        !            50:        INTENSE = 0x08          / high intensity attribute bit
        !            51:        BLINK   = 0x80          / blinking attribute bit
        !            52:        REVERSE = 0x70          / reverse video
        !            53: 
        !            54: ////////
        !            55: /
        !            56: / Magic constants from <sys/io.h>
        !            57: /
        !            58: ////////
        !            59: 
        !            60:        IO_SEG  = 0
        !            61:        IO_IOC  = 2
        !            62:        IO_BASE = 8
        !            63: 
        !            64:        IOSYS   = 0
        !            65:        IOUSR   = 1
        !            66: 
        !            67: ////////
        !            68: /
        !            69: / Data
        !            70: /
        !            71: ////////
        !            72: / Characters
        !            73: AZERO          = 0x30
        !            74: CLOWER         = 0x63
        !            75: HLOWER         = 0x68
        !            76: LLOWER         = 0x6C
        !            77: SEMIC          = 0x3B
        !            78: SPACE          = 0x20
        !            79: 
        !            80: MM_FUNC                = 0             / current state
        !            81: MM_PORT                = 2             / adapter base i/o port
        !            82: MM_BASE                = 4             / adapter base memory address
        !            83: MM_ROW         = 6             / screen row
        !            84: MM_COL         = 7             / screen column
        !            85: MM_POS         = 8             / screen position
        !            86: MM_ATTR                = 10            / attributes
        !            87: MM_N1          = 11            / numeric argument 1
        !            88: MM_N2          = 12            / numeric argument 2
        !            89: MM_BROW                = 13            / base row
        !            90: MM_EROW                = 14            / end row
        !            91: MM_LROW                = 15            / legal row limit
        !            92: MM_SROW                = 16            / saved cursor row
        !            93: MM_SCOL                = 17            / saved cursor column
        !            94: MM_IBROW       = 18            / initial base row
        !            95: MM_IEROW       = 19            / initial end row
        !            96: MM_INVIS       = 20            / cursor invisible mask
        !            97: MM_SLOW                = 22            / slow [no flicker] video update
        !            98: MM_WRAP                = 23            / wrap to start of next line
        !            99: MM_CURTERM     = 24            / flag:1=current virterm (TBF)
        !           100: MM_UNUSED      = 25            / not used, preseve even byte ordering (TBF)
        !           101: MM_DATASIZE    = 26            / size of data structure (TBF)
        !           102: 
        !           103: NVIRTERMS      = 4             / # of virtual terminals (TBF)
        !           104: 
        !           105:        .globl  VIDSLOW_        / Patchable kernel variable.
        !           106:        .globl  mmspecspace_
        !           107:        .prvd
        !           108: mmspecspace_:
        !           109: mmdata:        .word   mminit
        !           110:        .word   0x03B4
        !           111:        .word   0xB000
        !           112:        .byte   0, 0
        !           113:        .word   0
        !           114:        .byte   0x7, 0, 0, 0, 23, 24, 0, 0, 0, 23
        !           115:        .word   0
        !           116: VIDSLOW_:.byte 0
        !           117:        .byte   1
        !           118:        .byte   1,0
        !           119: 
        !           120: .blkb  MM_DATASIZE*[NVIRTERMS-1]       / allocate NVIRTERMS-1 more data spaces
        !           121: 
        !           122: MMDATAADDR:                            / address of structs (TBF)
        !           123: mmdata2                =       mmdata  + MM_DATASIZE
        !           124: mmdata3                =       mmdata2 + MM_DATASIZE
        !           125: mmdata4                =       mmdata3 + MM_DATASIZE
        !           126: / mmdata5              =       mmdata4 + MM_DATASIZE
        !           127: / mmdata6              =       mmdata5 + MM_DATASIZE
        !           128: / mmdata7              =       mmdata6 + MM_DATASIZE
        !           129: / mmdata8              =       mmdata7 + MM_DATASIZE
        !           130: / mmdata9              =       mmdata8 + MM_DATASIZE
        !           131: / mmdata10     =       mmdata9 + MM_DATASIZE
        !           132:  
        !           133:        .word mmdata,  mmdata2, mmdata3, mmdata4
        !           134: /      .word mmdata,  mmdata2, mmdata3, mmdata4, mmdata5
        !           135: /      .word mmdata6, mmdata7, mmdata8, mmdata9, mmdata10
        !           136: 
        !           137:        .shri
        !           138: 
        !           139: //////////////
        !           140: /
        !           141: / mmblankbuf(dest)   blank screen buffer (TBF)
        !           142: / unsigned dest;
        !           143: /
        !           144: / dest is selector
        !           145: /
        !           146: //////////////
        !           147: 
        !           148:        .globl mmblankbuf_
        !           149: mmblankbuf_:
        !           150:        push si
        !           151:        push di
        !           152:        push es
        !           153:        push bp
        !           154:        mov  bp,sp
        !           155: 
        !           156:        mov ax, 10(bp)          / es=dest
        !           157:        mov es, ax
        !           158: 
        !           159:        mov di, $0                      / buffer start
        !           160: 
        !           161:        mov ax, $0x0700         / blank value
        !           162:        mov     cx, $hBUFSIZE   / size of buffer in words
        !           163: 
        !           164:        rep
        !           165:        stosw                           / blank out buffer
        !           166: 
        !           167:        pop bp
        !           168:        pop es
        !           169:        pop     di
        !           170:        pop si
        !           171:        ret
        !           172: 
        !           173: //////////
        !           174: /
        !           175: / mmbufcopy(dest,src) (TBF)
        !           176: / unsigned dest,src
        !           177: /
        !           178: / copies screen buffer from src to dest. dest,src are selectors
        !           179: /
        !           180: //////////
        !           181: 
        !           182:        .globl mmbufcopy_
        !           183: mmbufcopy_:
        !           184:        push    si
        !           185:        push    di
        !           186:        push    ds
        !           187:        push    es
        !           188:        push    bp
        !           189:        mov     bp, sp
        !           190: 
        !           191:        mov     ax, 12(bp)              / es=dest
        !           192:        mov es, ax              
        !           193: 
        !           194:        mov     ax, 14(bp)              / ds=src
        !           195:        mov ds, ax
        !           196: 
        !           197:        mov si,$0
        !           198:        mov di,$0
        !           199:        mov cx,$hBUFSIZE
        !           200:        rep
        !           201:        movsw                           / copy buffer
        !           202:        
        !           203:        pop bp
        !           204:        pop es
        !           205:        pop ds
        !           206:        pop     di
        !           207:        pop     si
        !           208:        ret
        !           209: 
        !           210: ////////
        !           211: /
        !           212: / mmgo ( iop, dev )
        !           213: / IO *iop; dev_t dev
        !           214: /
        !           215: ////////
        !           216: 
        !           217:        .globl  mmgo_
        !           218: 
        !           219: mmgo_:
        !           220:        push    si
        !           221:        push    di
        !           222:        push    bp
        !           223:        mov     bp, sp
        !           224:        push    ds
        !           225:        push    es
        !           226:        cld
        !           227:        mov     bx, 8(bp)               / iop
        !           228:        cmp     bx, $0                  / skip if(iop==NULL)
        !           229:        je      0f
        !           230:        mov     si, IO_BASE(bx)         / iop->io_base
        !           231:        mov     cx, IO_IOC(bx)          / iop->io_ioc
        !           232: 
        !           233:        cmp     IO_SEG(bx), $IOSYS      / user address space
        !           234:        je      0f
        !           235:        mov     bx, uds_
        !           236:        mov     ds, bx
        !           237: 0:
        !           238:        mov     bx, 10(bp)              / bx=dev (TBF)
        !           239:        movb    bh, $0                  / bx=minor(dev) (TBF)
        !           240:        sub     bx, $1                  / bx=minor(dev)-1 (TBF)
        !           241:        shl     bx, $1                  / bx=2*(minor(dev)-1) (TBF)
        !           242:        mov     bp, ss:MMDATAADDR(bx)   / bp=&mmspecspace[minor(dev)-1]; (TBF)
        !           243:   
        !           244:        mov     dx, MM_PORT(bp)         / turn video off if color board
        !           245:        cmp     dx, $0x3B4
        !           246:        je      3f
        !           247:        cmpb    MM_SLOW(bp), $0         / check for slow [flicker-free]
        !           248:        je      2f
        !           249: 
        !           250:        mov     dx, $0x3DA
        !           251: 1:     inb     al, dx                  / wait for vertical retrace
        !           252:        testb   al, $8
        !           253:        je      1b
        !           254: 2:
        !           255:        mov     dx, $0x3D8              / disable video
        !           256:        movb    al, $0x25
        !           257:        outb    dx, al
        !           258: 3:
        !           259:        movb    ROW, MM_ROW(bp)
        !           260:        movb    COL, MM_COL(bp)
        !           261:        mov     es,  MM_BASE(bp)
        !           262:        mov     POS, MM_POS(bp)
        !           263:        sub     bx, bx
        !           264:        movb    ATTR, MM_ATTR(bp)
        !           265:        ijmp    MM_FUNC(bp)
        !           266: 
        !           267: exit:  pop     bx
        !           268:        pop     es
        !           269:        pop     ds
        !           270:        movb    MM_ATTR(bp), ATTR
        !           271:        mov     MM_FUNC(bp), bx
        !           272:        movb    MM_ROW(bp), ROW         / save row,column
        !           273:        movb    MM_COL(bp), COL
        !           274:        mov     MM_POS(bp), POS         / save position
        !           275:        je      4f
        !           276:        mov     dx, MM_PORT(bp)         / adjust cursor location
        !           277:        mov     bx, POS
        !           278:        or      bx, MM_INVIS(bp)
        !           279:        shr     bx, $1
        !           280: 
        !           281:        movb    al, $14
        !           282:        outb    dx, al
        !           283:        inc     dx
        !           284:        movb    al, bh
        !           285:        outb    dx, al
        !           286:        dec     dx
        !           287:        movb    al, $15
        !           288:        outb    dx, al
        !           289:        inc     dx
        !           290:        movb    al, bl
        !           291:        outb    dx, al
        !           292: 
        !           293: 4:
        !           294:        mov     dx, MM_PORT(bp)         / turn video on
        !           295:        add     dx, $4
        !           296:        movb    al, $0x29
        !           297:        outb    dx, al
        !           298:        mov     mmvcnt_, $600           / 600 seconds before video disabled
        !           299: 
        !           300:        mov     bp, sp
        !           301:        mov     bx, 8(bp)
        !           302:        mov     ax, cx
        !           303:        xchg    cx, IO_IOC(bx)
        !           304:        sub     cx, IO_IOC(bx)
        !           305:        add     IO_BASE(bx), cx
        !           306:        pop     bp
        !           307:        pop     di
        !           308:        pop     si
        !           309:        ret
        !           310: 
        !           311: ////////
        !           312: /
        !           313: / mmcursor - cursor update entry point (TBF)
        !           314: /
        !           315: ////////
        !           316: 
        !           317:        .globl  mmcursor_
        !           318: 
        !           319: mmcursor_:
        !           320:        call exit                                               / exit takes care of rest
        !           321:        jmp eval
        !           322: 
        !           323: ////////
        !           324: /
        !           325: / mminit - initialize screen
        !           326: /
        !           327: ////////
        !           328: 
        !           329: mminit:        movb    ss:mmesc_, $CLOWER      / schedule keyboard initialization
        !           330:        
        !           331:        call    int11_                  / read equipment status
        !           332:        and     ax, $0x30               / isolate video bits
        !           333:        cmp     ax, $0x30               / if not monochrome
        !           334:        je      0f
        !           335:        mov     MM_PORT(bp), $0x3D4     /       set color port
        !           336:        mov     MM_BASE(bp), $0xB800    /       set color base
        !           337:        mov     es, MM_BASE(bp)         /
        !           338: 0:                                     /
        !           339:        mov     dx, MM_PORT(bp)         / turn video off
        !           340:        add     dx, $4
        !           341:        movb    al, $0x21
        !           342:        outb    dx, al
        !           343: 
        !           344:        mov     dx, MM_PORT(bp)         / zero display offset
        !           345:        movb    al, $12
        !           346:        outb    dx, al
        !           347:        inc     dx
        !           348:        subb    al, al
        !           349:        outb    dx, al
        !           350:        dec     dx
        !           351:        movb    al, $13
        !           352:        outb    dx, al
        !           353:        inc     dx
        !           354:        subb    al, al
        !           355:        outb    dx, al
        !           356: 
        !           357:        mov     dx, MM_PORT(bp)         / reset border to black
        !           358:        add     dx, $5
        !           359:        subb    al, al
        !           360:        outb    dx, al
        !           361: 
        !           362:        inc     dx                      / reset TECMAR XMSR register
        !           363:        outb    dx, al
        !           364: 
        !           365: mminit2:movb   ss:mmesc_, $CLOWER
        !           366:        mov     MM_INVIS(bp), $0
        !           367:        movb    ATTR, $0x07
        !           368:        movb    MM_ATTR(bp), ATTR
        !           369:        movb    MM_WRAP(bp), $1
        !           370:        movb    ROW, MM_IBROW(bp)
        !           371:        movb    MM_BROW(bp), ROW
        !           372:        movb    bl, MM_IEROW(bp)
        !           373:        movb    MM_EROW(bp), bl
        !           374:        sub     bx, bx
        !           375:        movb    MM_N1(bp), $2
        !           376:        jmp     mm_ed
        !           377: 
        !           378: ////////
        !           379: /
        !           380: / mmspec - schedule special keyboard function
        !           381: /
        !           382: ////////
        !           383: 
        !           384: mmspec:        movb    ss:mmesc_, al
        !           385:        jmp     eval
        !           386: 
        !           387: ////////
        !           388: /
        !           389: / mmbell - schedule beep
        !           390: /
        !           391: ////////
        !           392: 
        !           393: mmbell:        
        !           394:        cmp             MM_CURTERM(bp), $0      / only if not current virterm (TBF)
        !           395:        je              1f
        !           396:        movb    ss:mmbeeps_, $-1
        !           397: 1:     jmp     eval
        !           398: 
        !           399: ////////
        !           400: /
        !           401: / mm_cnl - cursor next line
        !           402: /
        !           403: /      Moves the active position to the first column of the next display line.
        !           404: /      Scrolls the active display if necessary.
        !           405: /
        !           406: ////////
        !           407: 
        !           408: mm_cnl:        subb    COL, COL
        !           409:        incb    ROW
        !           410:        cmpb    ROW, MM_EROW(bp)
        !           411:        jna     repos
        !           412:        movb    ROW, MM_EROW(bp)
        !           413: /      jmp     scrollup
        !           414: 
        !           415: ////////
        !           416: /
        !           417: / scrollup - scroll display upwards
        !           418: /
        !           419: ////////
        !           420: 
        !           421: scrollup:
        !           422:        push    ds
        !           423:        push    si
        !           424:        push    cx
        !           425:        mov     ds, MM_BASE(bp)
        !           426:        movb    bl, MM_BROW(bp)
        !           427:        shlb    bl, $1
        !           428:        mov     di, cs:rowtab(bx)
        !           429:        mov     si, cs:rowtab+2(bx)
        !           430:        movb    bl, ROW
        !           431:        shlb    bl, $1
        !           432:        mov     cx, cs:rowtab(bx)
        !           433:        push    cx
        !           434:        sub     cx, di
        !           435:        shr     cx, $1
        !           436:        cld
        !           437:        rep
        !           438:        movsw
        !           439:        movb    al, $SPACE
        !           440:        pop     di
        !           441:        mov     cx, $NCOL
        !           442:        rep
        !           443:        stosw
        !           444:        pop     cx
        !           445:        pop     si
        !           446:        pop     ds
        !           447:        movb    bl, COL                 / reposition to ROW and COL
        !           448:        shlb    bl, $1
        !           449:        mov     POS, cs:coltab(bx)
        !           450:        movb    bl, ROW
        !           451:        shlb    bl, $1
        !           452:        add     POS, cs:rowtab(bx)
        !           453:        call    exit
        !           454:        jmp     eval
        !           455: 
        !           456: ////////
        !           457: /
        !           458: / repos - reposition cursor
        !           459: /
        !           460: ////////
        !           461: 
        !           462: repos: movb    bl, COL                 / reposition to ROW and COL
        !           463:        shlb    bl, $1
        !           464:        mov     POS, cs:coltab(bx)
        !           465:        movb    bl, ROW
        !           466:        shlb    bl, $1
        !           467:        add     POS, cs:rowtab(bx)
        !           468: /      jmp     eval
        !           469: 
        !           470: ////////
        !           471: /
        !           472: / eval - evaluate input character
        !           473: /
        !           474: ////////
        !           475: 
        !           476: eval:  jcxz    ewait
        !           477:        dec     cx                              / evaluate next char
        !           478:        lodsb
        !           479:        movb    bl, al
        !           480:        shlb    bl, $1
        !           481:        jc      mmputc
        !           482:        ijmp    cs:asctab(bx)
        !           483: 
        !           484: ////////
        !           485: /
        !           486: / mmputc - put character on screen
        !           487: /
        !           488: ////////
        !           489: 
        !           490: mmputc:        stosw                           / Update display memory.
        !           491:        incb    COL
        !           492:        cmpb    COL, $NCOL              / Past end of line?
        !           493:        jge     0f
        !           494:        jcxz    ewait                   / Not past, evaluate next character.
        !           495:        dec     cx
        !           496:        lodsb
        !           497:        movb    bl, al
        !           498:        shlb    bl, $1
        !           499:        jc      mmputc
        !           500:        ijmp    cs:asctab(bx)
        !           501: 
        !           502: 0:     cmpb    MM_WRAP(bp), $0         / Yes past, Wrap around?
        !           503:        jne     0f
        !           504:        sub     di, $2                  / No wrap, adjust back to end of line.
        !           505:        decb    COL
        !           506:        jcxz    ewait                   / Not past, evaluate next character.
        !           507:        dec     cx
        !           508:        lodsb
        !           509:        movb    bl, al
        !           510:        shlb    bl, $1
        !           511:        jc      mmputc
        !           512:        ijmp    cs:asctab(bx)
        !           513: 
        !           514: 0:     subb    COL, COL                / Wrap to next line.
        !           515:        incb    ROW
        !           516:        cmpb    ROW, MM_EROW(bp)        / Past scrolling region?
        !           517:        jg      0f
        !           518:        jcxz    ewait                   / Not past, evaluate next character.
        !           519:        dec     cx
        !           520:        lodsb
        !           521:        movb    bl, al
        !           522:        shlb    bl, $1
        !           523:        jc      mmputc
        !           524:        ijmp    cs:asctab(bx)
        !           525: 
        !           526: 0:     movb    ROW, MM_EROW(bp)        / Yes past, scroll up 1 line.
        !           527:        jmp     scrollup
        !           528: 
        !           529: ////////
        !           530: /
        !           531: / Ewait - wait for next input char to evaluate
        !           532: /
        !           533: ////////
        !           534: 
        !           535: ewait: call    exit
        !           536:        jcxz    ewait
        !           537:        dec     cx
        !           538:        lodsb
        !           539:        movb    bl, al
        !           540:        shlb    bl, $1
        !           541:        jc      mmputc
        !           542:        ijmp    cs:asctab(bx)
        !           543: 
        !           544: ////////
        !           545: /
        !           546: / mm_cr - carriage return
        !           547: /
        !           548: /      Moves the active position to first position of current display line.
        !           549: /
        !           550: ////////
        !           551: 
        !           552: mm_cr: subb    COL, COL
        !           553:        movb    bl, ROW
        !           554:        shlb    bl, $1
        !           555:        mov     POS, cs:rowtab(bx)
        !           556:        jcxz    ewait
        !           557:        dec     cx
        !           558:        lodsb
        !           559:        movb    bl, al
        !           560:        shlb    bl, $1
        !           561:        jc      mmputc
        !           562:        ijmp    cs:asctab(bx)
        !           563: 
        !           564: ////////
        !           565: /
        !           566: / mm_cub - cursor backwards
        !           567: /
        !           568: ////////
        !           569: 
        !           570: mm_cub:        sub     POS, $2
        !           571:        decb    COL
        !           572:        jge     0f
        !           573:        movb    COL, $NCOL-1
        !           574:        decb    ROW
        !           575:        cmpb    ROW, MM_BROW(bp)
        !           576:        jge     0f
        !           577:        subb    COL, COL
        !           578:        movb    ROW, MM_BROW(bp)
        !           579:        movb    bl, ROW
        !           580:        shlb    bl, $1
        !           581:        mov     POS, cs:rowtab(bx)
        !           582: 0:     jcxz    ewait
        !           583:        dec     cx
        !           584:        lodsb
        !           585:        movb    bl, al
        !           586:        shlb    bl, $1
        !           587:        jc      mmputc
        !           588:        ijmp    cs:asctab(bx)
        !           589: 
        !           590: ////////
        !           591: /
        !           592: / Esc state - entered when last char was ESC - transient state.
        !           593: /
        !           594: ////////
        !           595: 
        !           596: 0:     call    exit
        !           597: mm_esc:        jcxz    0b
        !           598:        dec     cx
        !           599:        lodsb
        !           600:        movb    MM_N1(bp), ZERO
        !           601:        movb    MM_N2(bp), ZERO
        !           602:        movb    bl, al
        !           603:        shlb    bl, $1
        !           604:        jc      mmputc
        !           605:        ijmp    cs:esctab(bx)
        !           606: 
        !           607: ////////
        !           608: /
        !           609: / Csi_n1 state - entered when last two chars were ESC [
        !           610: /
        !           611: /      Action: Evaluates numeric chars as numeric parameter 1.
        !           612: /
        !           613: ////////
        !           614: 
        !           615: 0:     call    exit
        !           616: csi_n1:        jcxz    0b
        !           617:        dec     cx
        !           618:        lodsb
        !           619:        cmpb    al, $SEMIC
        !           620:        je      csi_n2
        !           621:        movb    bl, al
        !           622:        subb    bl, $AZERO
        !           623:        cmpb    bl, $9
        !           624:        ja      csival
        !           625:        shlb    MM_N1(bp), $1   / n1 * 2
        !           626:        movb    al, MM_N1(bp)   / n1 * 2
        !           627:        shlb    al, $1          / n1 * 4
        !           628:        shlb    al, $1          / n1 * 8
        !           629:        addb    al, MM_N1(bp)   / n1 * 10
        !           630:        addb    al, bl          / n1 * 10 + digit
        !           631:        movb    MM_N1(bp), al   / n1 = (n1 * 10) + digit
        !           632:        jmp     csi_n1
        !           633: 
        !           634: ////////
        !           635: /
        !           636: / Csi_n2 state - entered after input sequence ESC [ n ;
        !           637: /
        !           638: ////////
        !           639: 
        !           640: 0:     call    exit
        !           641: csi_n2:        jcxz    0b
        !           642:        dec     cx
        !           643:        lodsb
        !           644:        movb    bl, al
        !           645:        subb    bl, $AZERO
        !           646:        cmpb    bl, $9
        !           647:        ja      csival
        !           648:        shlb    MM_N2(bp), $1   / n2 * 2
        !           649:        movb    al, MM_N2(bp)   / n2 * 2
        !           650:        shlb    al, $1          / n2 * 4
        !           651:        shlb    al, $1          / n2 * 8
        !           652:        addb    al, MM_N2(bp)   / n2 * 10
        !           653:        addb    al, bl          / n2 * 10 + digit
        !           654:        movb    MM_N2(bp), al   / n2 = (n2 * 10) + digit
        !           655:        jmp     csi_n2
        !           656: 
        !           657: csival:        movb    bl, al
        !           658:        shlb    bl, $1
        !           659:        jc      mmputc
        !           660:        ijmp    cs:csitab(bx)
        !           661: 
        !           662: ////////
        !           663: /
        !           664: / Csi_gt state - entered after input sequence ESC [ >
        !           665: /      
        !           666: ////////
        !           667: 
        !           668: 0:     call    exit
        !           669: csi_gt:        jcxz    0b
        !           670:        dec     cx
        !           671:        lodsb
        !           672:        movb    bl, al
        !           673:        subb    bl, $AZERO
        !           674:        cmpb    bl, $9
        !           675:        ja      0f
        !           676:        shlb    MM_N1(bp), $1   / n1 * 2
        !           677:        movb    al, MM_N1(bp)   / n1 * 2
        !           678:        shlb    al, $1          / n1 * 4
        !           679:        shlb    al, $1          / n1 * 8
        !           680:        addb    al, MM_N1(bp)   / n1 * 10
        !           681:        addb    al, bl          / n1 * 10 + digit
        !           682:        movb    MM_N1(bp), al   / n1 = (n1 * 10) + digit
        !           683:        jmp     csi_gt
        !           684: 
        !           685: 0:     cmpb    al, $HLOWER
        !           686:        je      mm_cgh
        !           687:        cmpb    al, $LLOWER
        !           688:        je      mm_cgl
        !           689:        jmp     eval
        !           690: 
        !           691: ////////
        !           692: /
        !           693: / Csi_q state - entered after input sequence ESC [ ?
        !           694: /      
        !           695: ////////
        !           696: 
        !           697: 0:     call    exit
        !           698: csi_q: jcxz    0b
        !           699:        dec     cx
        !           700:        lodsb
        !           701:        movb    bl, al
        !           702:        subb    bl, $AZERO
        !           703:        cmpb    bl, $9
        !           704:        ja      0f
        !           705:        shlb    MM_N1(bp), $1   / n1 * 2
        !           706:        movb    al, MM_N1(bp)   / n1 * 2
        !           707:        shlb    al, $1          / n1 * 4
        !           708:        shlb    al, $1          / n1 * 8
        !           709:        addb    al, MM_N1(bp)   / n1 * 10
        !           710:        addb    al, bl          / n1 * 10 + digit
        !           711:        movb    MM_N1(bp), al   / n1 = (n1 * 10) + digit
        !           712:        jmp     csi_q
        !           713: 
        !           714: 0:     cmpb    al, $HLOWER
        !           715:        je      mm_cqh
        !           716:        cmpb    al, $LLOWER
        !           717:        je      mm_cql
        !           718:        jmp     eval
        !           719: 
        !           720: ////////
        !           721: /
        !           722: / mm_cbt - cursor backward tabulation
        !           723: /
        !           724: /      Moves the active position horizontally in the backward direction
        !           725: /      to the preceding in a series of predetermined positions.
        !           726: /
        !           727: ////////
        !           728: 
        !           729: mm_cbt:        orb     COL, $7                 / calculate next tab stop
        !           730:        incb    COL
        !           731:        subb    COL, $16                / step back two tab positions
        !           732:        jg      0f
        !           733:        subb    COL, COL                / cannot step past column 0
        !           734: 0:     jmp     repos                   / reposition cursor
        !           735: 
        !           736: ////////
        !           737: /
        !           738: / mm_cgh - process ESC [ > N1 h escape sequence
        !           739: /
        !           740: /      Recognized sequences:   ESC [ > 13 h    -- Set CRT saver enabled.
        !           741: /
        !           742: ////////
        !           743: 
        !           744: mm_cgh:        cmpb    MM_N1(bp), $13
        !           745:        jne     0f
        !           746:        mov     ss:mmcrtsav_, $1
        !           747: 0:     jmp     eval
        !           748: 
        !           749: ////////
        !           750: /
        !           751: / mm_cgl - process ESC [ > N1 l escape sequence
        !           752: /
        !           753: /      Recognized sequences:   ESC [ > 13 l    -- Reset CRT saver.
        !           754: /
        !           755: ////////
        !           756: 
        !           757: mm_cgl:        cmpb    MM_N1(bp), $13
        !           758:        jne     0f
        !           759:        mov     ss:mmcrtsav_, $0
        !           760: 0:     jmp     eval
        !           761: 
        !           762: ////////
        !           763: /
        !           764: / mm_cha - cursor horizontal absolute
        !           765: /
        !           766: /      Advances the active position forward or backward along the active line
        !           767: /      to the character position specified by the parameter.
        !           768: /      A parameter value of zero or one moves the active position to the
        !           769: /      first character position of the active line.
        !           770: /      A parameter value of N moves the active position to character position
        !           771: /      N of the active line.
        !           772: /
        !           773: ////////
        !           774: 
        !           775: mm_cha:        movb    COL, MM_N1(bp)
        !           776:        decb    COL
        !           777:        jge     0f
        !           778:        subb    COL, COL
        !           779: 0:     cmpb    COL, $NCOL
        !           780:        jb      0f
        !           781:        movb    COL, $NCOL-1
        !           782: 0:     jmp     repos                   / reposition cursor
        !           783: 
        !           784: 
        !           785: ////////
        !           786: /
        !           787: / mm_cht - cursor horizontal tabulation
        !           788: /
        !           789: /      Advances the active position horizontally to the next or following
        !           790: /      in a series of predetermined positions.
        !           791: /
        !           792: ////////
        !           793: 
        !           794: mm_cht:        push    cx
        !           795:        sub     cx, cx
        !           796:        movb    cl, COL
        !           797:        orb     cl, $7
        !           798:        incb    cl
        !           799:        subb    cl, COL
        !           800:        addb    COL, cl
        !           801:        movb    al, $SPACE
        !           802:        rep
        !           803:        stosw
        !           804:        pop     cx
        !           805:        cmpb    COL, $NCOL
        !           806:        jb      0f
        !           807:        subb    COL, $NCOL
        !           808:        incb    ROW
        !           809:        cmpb    ROW, MM_EROW(bp)
        !           810:        jna     0f
        !           811:        movb    ROW, MM_EROW(bp)
        !           812:        jmp     scrollup
        !           813: 0:     jmp     eval
        !           814: 
        !           815: ////////
        !           816: /
        !           817: / mm_cpl - cursor preceding line
        !           818: /
        !           819: /      Moves the active position to the first position of the preceding
        !           820: /      display line.
        !           821: /
        !           822: ////////
        !           823: 
        !           824: mm_cpl:        subb    COL, COL
        !           825:        decb    ROW
        !           826:        cmpb    ROW, MM_BROW(bp)
        !           827:        jnb     0f
        !           828:        movb    ROW, MM_BROW(bp)
        !           829:        jmp     scrolldown
        !           830: 0:     jmp     repos                   / reposition cursor
        !           831: 
        !           832: ////////
        !           833: /
        !           834: / mm_cqh - process ESC [ ? N1 h escape sequence
        !           835: /
        !           836: /      Recognized sequences:   ESC [ ? 4 h     -- Set smooth scroll.
        !           837: /                              ESC [ ? 7 h     -- Set wraparound.
        !           838: /
        !           839: ////////
        !           840: 
        !           841: mm_cqh:        cmpb    MM_N1(bp), $4           / Smooth scroll.
        !           842:        jne     0f
        !           843:        movb    MM_SLOW(bp), $1
        !           844: 0:     cmpb    MM_N1(bp), $7           / Wraparound.
        !           845:        jne     0f
        !           846:        movb    MM_WRAP(bp), $1
        !           847: 0:     jmp     eval
        !           848: 
        !           849: ////////
        !           850: /
        !           851: / mm_cql - process ESC [ ? N1 l escape sequence
        !           852: /
        !           853: /      Recognized sequences:   ESC [ ? 4 l     -- Set jump scroll.
        !           854: /                              ESC [ ? 7 l     -- Reset wraparound.
        !           855: /
        !           856: ////////
        !           857: 
        !           858: mm_cql:        cmpb    MM_N1(bp), $4           / Jump scroll.
        !           859:        jne     0f
        !           860:        movb    MM_SLOW(bp), $0
        !           861: 0:     cmpb    MM_N1(bp), $7           / No wraparound.
        !           862:        jne     0f
        !           863:        movb    MM_WRAP(bp), $0
        !           864: 0:     jmp     eval
        !           865: 
        !           866: ////////
        !           867: /
        !           868: / mm_cud - cursor down
        !           869: /
        !           870: /      Moves the active position downward without altering the
        !           871: /      horizontal position.
        !           872: /
        !           873: ////////
        !           874: 
        !           875: mm_cud:        incb    ROW
        !           876:        cmpb    ROW, MM_EROW(bp)
        !           877:        jna     0f
        !           878:        movb    ROW, MM_EROW(bp)
        !           879: 0:     jmp     repos                   / reposition cursor
        !           880: 
        !           881: ////////
        !           882: /
        !           883: / mm_cuf - cursor forward
        !           884: /
        !           885: /      Moves the active position in the forward direction.
        !           886: /
        !           887: ////////
        !           888: 
        !           889: mm_cuf:        incb    COL
        !           890:        cmpb    COL, $NCOL
        !           891:        jb      0f
        !           892:        subb    COL, $NCOL
        !           893:        incb    ROW
        !           894:        cmpb    ROW, MM_EROW(bp)
        !           895:        jna     0f
        !           896:        movb    ROW, MM_EROW(bp)
        !           897:        movb    COL, $NCOL-1
        !           898: 0:     jmp     repos
        !           899: 
        !           900: ////////
        !           901: /
        !           902: / mm_cup - cursor position
        !           903: /
        !           904: /      Moves the active position to the position specified by two parameters.
        !           905: /      The first parameter (mm_n1) specifies the vertical position (MM_ROW(bp)).
        !           906: /      The second parameter (mm_n2) specifies the horizontal position (MM_COL(bp)).
        !           907: /      A parameter value of 0 or 1 for the first or second parameter
        !           908: /      moves the active position to the first line or column in the
        !           909: /      display respectively.
        !           910: /
        !           911: ////////
        !           912: 
        !           913: mm_cup:        movb    ROW, MM_N1(bp)
        !           914:        decb    ROW
        !           915:        jg      0f
        !           916:        subb    ROW, ROW
        !           917: 0:     addb    ROW, MM_BROW(bp)
        !           918:        cmpb    ROW, MM_EROW(bp)
        !           919:        jb      0f
        !           920:        movb    ROW, MM_EROW(bp)
        !           921: 0:     movb    COL, MM_N2(bp)
        !           922:        decb    COL
        !           923:        jg      0f
        !           924:        subb    COL, COL
        !           925: 0:     cmpb    COL, $NCOL
        !           926:        jb      0f
        !           927:        movb    COL, $NCOL-1
        !           928: 0:     jmp     repos                   / reposition cursor
        !           929: 
        !           930: ////////
        !           931: /
        !           932: / mm_cuu - cursor up
        !           933: /
        !           934: /      Moves the active position upward without altering the horizontal
        !           935: /      position.
        !           936: /
        !           937: ////////
        !           938: 
        !           939: mm_cuu:        decb    ROW
        !           940:        cmpb    ROW, MM_BROW(bp)
        !           941:        jge     0f
        !           942:        movb    ROW, MM_BROW(bp)
        !           943: 0:     jmp     repos                   / reposition cursor
        !           944: 
        !           945: ////////
        !           946: /
        !           947: / mm_dl - delete line
        !           948: /
        !           949: /      Removes the contents of the active line.
        !           950: /      The contents of all following lines are shifted in a block
        !           951: /      toward the active line.
        !           952: /
        !           953: ////////
        !           954: 
        !           955: mm_dl: push    ds
        !           956:        push    si
        !           957:        push    cx
        !           958:        mov     ds, MM_BASE(bp)
        !           959:        movb    bl, ROW
        !           960:        shlb    bl, $1
        !           961:        mov     di, cs:rowtab(bx)
        !           962:        mov     si, cs:rowtab+2(bx)
        !           963:        movb    bl, MM_EROW(bp)
        !           964:        shlb    bl, $1
        !           965:        mov     cx, cs:rowtab(bx)
        !           966:        sub     cx, di
        !           967:        jle     0f
        !           968:        shr     cx, $1
        !           969:        rep
        !           970:        movsw
        !           971:        mov     di, cs:rowtab(bx)
        !           972:        mov     cx, $NCOL
        !           973:        movb    al, $SPACE
        !           974:        rep
        !           975:        stosw
        !           976:        subb    COL, COL
        !           977:        movb    bl, ROW
        !           978:        shlb    bl, $1
        !           979:        mov     di, cs:rowtab(bx)
        !           980: 0:     pop     cx
        !           981:        pop     si
        !           982:        pop     ds
        !           983:        call    exit
        !           984:        jmp     eval
        !           985: 
        !           986: ////////
        !           987: /
        !           988: / mm_dmi - disable manual input
        !           989: /
        !           990: /      Set flag preventing keyboard input, and causing cursor to vanish.
        !           991: /
        !           992: ////////
        !           993: 
        !           994: mm_dmi:
        !           995:        mov     ss:islock_, $1
        !           996:        jmp     eval
        !           997: 
        !           998: ////////
        !           999: /
        !          1000: / mm_ea - erase in area
        !          1001: /
        !          1002: /      Erase some or all of the characters in the currently active area
        !          1003: /      according to the parameter:
        !          1004: /              0 - erase from active position to end inclusive (default)
        !          1005: /              1 - erase from start to active position inclusive
        !          1006: /              2 - erase all of active area
        !          1007: /
        !          1008: ////////
        !          1009: 
        !          1010: mm_ea: movb    al, MM_N1(bp)
        !          1011:        cmpb    al, $0
        !          1012:        jne     0f
        !          1013:        movb    bl, MM_EROW(bp)
        !          1014:        jmp     mm_e0
        !          1015: 0:     cmpb    al, $1
        !          1016:        jne     0f
        !          1017:        movb    bl, MM_BROW(bp)
        !          1018:        jmp     mm_e1
        !          1019: 0:     subb    COL, COL
        !          1020:        movb    ROW, MM_BROW(bp)
        !          1021:        movb    bl, ROW
        !          1022:        shlb    bl, $1
        !          1023:        mov     POS, cs:rowtab(bx)
        !          1024:        movb    bl, MM_EROW(bp)
        !          1025:        subb    bl, ROW
        !          1026:        jmp     mm_e2
        !          1027: 
        !          1028: 
        !          1029: ////////
        !          1030: /
        !          1031: / mm_ed - erase in display
        !          1032: /
        !          1033: /      Erase some or all of the characters in the display according to the
        !          1034: /      parameter
        !          1035: /              0 - erase from active position to end inclusive (default)
        !          1036: /              1 - erase from start to active position inclusive
        !          1037: /              2 - erase all of display
        !          1038: /
        !          1039: ////////
        !          1040: 
        !          1041: mm_ed: movb    al, MM_N1(bp)
        !          1042:        cmpb    al, $0
        !          1043:        jne     0f
        !          1044:        movb    bl, MM_LROW(bp)
        !          1045:        jmp     mm_e0
        !          1046: 0:     cmpb    al, $1
        !          1047:        jne     0f
        !          1048:        subb    bl, bl
        !          1049:        jmp     mm_e1
        !          1050: 0:     subb    COL, COL
        !          1051:        movb    ROW, MM_BROW(bp)
        !          1052:        sub     POS, POS
        !          1053:        movb    bl, MM_LROW(bp)
        !          1054:        jmp     mm_e2
        !          1055: 
        !          1056: ////////
        !          1057: /
        !          1058: / mm_el - erase in line
        !          1059: /
        !          1060: /      Erase some or all of the characters in the line according to the
        !          1061: /      parameter:
        !          1062: /              0 - erase from active position to end inclusive (default)
        !          1063: /              1 - erase from start to active position inclusive
        !          1064: /              2 - erase entire line
        !          1065: /
        !          1066: ////////
        !          1067: 
        !          1068: mm_el: movb    al, MM_N1(bp)
        !          1069:        movb    bl, ROW
        !          1070:        cmpb    al, $0
        !          1071:        je      mm_e0
        !          1072:        cmpb    al, $1
        !          1073:        je      mm_e1
        !          1074:        shlb    bl, $1
        !          1075:        mov     POS, cs:rowtab(bx)
        !          1076:        subb    COL, COL
        !          1077:        subb    bl, bl
        !          1078: /      jmp     mm_e2
        !          1079: 
        !          1080: mm_e2: push    cx
        !          1081:        movb    al, $SPACE
        !          1082: 0:     mov     cx, $NCOL
        !          1083:        rep
        !          1084:        stosw
        !          1085:        decb    bl
        !          1086:        jge     0b
        !          1087:        pop     cx
        !          1088:        jmp     repos
        !          1089: 
        !          1090: mm_e1: push    cx
        !          1091:        mov     cx, POS
        !          1092:        shlb    bl, $1
        !          1093:        mov     POS, cs:rowtab(bx)
        !          1094:        sub     cx, POS
        !          1095:        jl      0f
        !          1096:        movb    al, $SPACE
        !          1097:        shr     cx, $1
        !          1098:        rep
        !          1099:        stosw
        !          1100: 0:     pop     cx
        !          1101:        jmp     repos
        !          1102: 
        !          1103: mm_e0: push    cx
        !          1104:        shlb    bl, $1
        !          1105:        mov     cx, cs:rowtab+2(bx)
        !          1106:        sub     cx, POS
        !          1107:        jl      0f
        !          1108:        movb    al, $SPACE
        !          1109:        shr     cx, $1
        !          1110:        rep
        !          1111:        stosw
        !          1112: 0:     pop     cx
        !          1113:        jmp     repos
        !          1114: 
        !          1115: ////////
        !          1116: /
        !          1117: / mm_emi - enable manual input
        !          1118: /
        !          1119: /      Clear flag preventing keyboard input.
        !          1120: /
        !          1121: ////////
        !          1122: 
        !          1123: mm_emi:
        !          1124:        mov     ss:islock_, $0
        !          1125:        jmp     eval
        !          1126: 
        !          1127: ////////
        !          1128: /
        !          1129: / mm_il - insert line
        !          1130: /
        !          1131: /      Insert a erased line at the active line by shifting the contents
        !          1132: /      of the active line and all following lines away from the active line.
        !          1133: /      The contents of the last line in the scrolling region are removed.
        !          1134: /
        !          1135: ////////
        !          1136: 
        !          1137: scrolldown:
        !          1138: mm_il: push    ds
        !          1139:        push    si
        !          1140:        push    cx
        !          1141:        mov     ds, MM_BASE(bp)
        !          1142:        movb    bl, MM_EROW(bp)
        !          1143:        shlb    bl, $1
        !          1144:        mov     si, cs:rowtab(bx)
        !          1145:        mov     cx, si
        !          1146:        sub     si, $2
        !          1147:        mov     di, cs:rowtab+2(bx)
        !          1148:        sub     di, $2
        !          1149:        movb    bl, ROW
        !          1150:        shlb    bl, $1
        !          1151:        sub     cx, cs:rowtab(bx)
        !          1152:        jle     0f
        !          1153:        shr     cx, $1
        !          1154:        std
        !          1155:        rep
        !          1156:        movsw
        !          1157:        mov     di, cs:rowtab(bx)
        !          1158:        mov     cx, $NCOL
        !          1159:        movb    al, $SPACE
        !          1160:        cld
        !          1161:        rep
        !          1162:        stosw
        !          1163:        subb    COL, COL
        !          1164:        movb    bl, ROW
        !          1165:        shlb    bl, $1
        !          1166:        mov     di, cs:rowtab(bx)
        !          1167: 0:     pop     cx
        !          1168:        pop     si
        !          1169:        pop     ds
        !          1170:        call    exit
        !          1171:        jmp     eval
        !          1172: 
        !          1173: ////////
        !          1174: /
        !          1175: / mm_hpa - horizontal position absolute
        !          1176: /
        !          1177: /      Moves the active position within the active line to the position
        !          1178: /      specified by the parameter.  A parameter value of zero or one
        !          1179: /      moves the active position to the first position of the active line.
        !          1180: /
        !          1181: ////////
        !          1182: 
        !          1183: mm_hpa:        movb    COL, MM_N1(bp)
        !          1184:        decb    COL
        !          1185:        jg      0f
        !          1186:        subb    COL, COL
        !          1187: 0:     cmpb    COL, $NCOL
        !          1188:        jb      0f
        !          1189:        movb    COL, $NCOL-1
        !          1190: 0:     jmp     repos                   / reposition cursor
        !          1191: 
        !          1192: ////////
        !          1193: /
        !          1194: / mm_hpr - horizontal position relative
        !          1195: /
        !          1196: /      Moves the active position forward the number of positions specified
        !          1197: /      by the parameter.  A parameter value of zero or one indicates a
        !          1198: /      single-position move.
        !          1199: /
        !          1200: ////////
        !          1201: 
        !          1202: mm_hpr:        movb    al, MM_N1(bp)
        !          1203:        orb     al, al
        !          1204:        jne     0f
        !          1205:        incb    al
        !          1206: 0:     addb    COL, al
        !          1207:        cmpb    COL, $NCOL
        !          1208:        jb      0f
        !          1209:        movb    COL, $NCOL-1
        !          1210: 0:     jmp     repos                   / reposition cursor
        !          1211: 
        !          1212: ////////
        !          1213: /
        !          1214: / mm_hvp - horizontal and vertical position
        !          1215: /
        !          1216: /      Moves the active position to the position specified by two parameters.
        !          1217: /      The first parameter specifies the vertical position (MM_ROW(bp)).
        !          1218: /      The second parameter specifies the horizontal position (MM_COL(bp)).
        !          1219: /      A parameter value of zero or one moves the active position to the
        !          1220: /      first line or column in the display.
        !          1221: /
        !          1222: ////////
        !          1223: 
        !          1224: mm_hvp:        movb    ROW, MM_N1(bp)
        !          1225:        decb    ROW
        !          1226:        jg      0f
        !          1227:        subb    ROW, ROW
        !          1228: 0:     cmpb    ROW, MM_LROW(bp)
        !          1229:        jna     0f
        !          1230:        movb    ROW, MM_LROW(bp)
        !          1231: 0:     movb    COL, MM_N2(bp)
        !          1232:        decb    COL
        !          1233:        jg      0f
        !          1234:        subb    COL, COL
        !          1235: 0:     cmpb    COL, $NCOL
        !          1236:        jb      0f
        !          1237:        movb    COL, $NCOL-1
        !          1238: 0:     jmp     repos                   / reposition cursor
        !          1239: 
        !          1240: ////////
        !          1241: /
        !          1242: / mm_ind - index
        !          1243: /
        !          1244: /      Causes the active position to move downward one line without changing
        !          1245: /      the horizontal position.  Scrolling occurs if below scrolling region.
        !          1246: /
        !          1247: ////////
        !          1248: 
        !          1249: mm_ind:        incb    ROW
        !          1250:        cmpb    ROW, MM_EROW(bp)
        !          1251:        jg      0f
        !          1252:        jmp     repos
        !          1253: 0:     movb    ROW, MM_EROW(bp)
        !          1254:        jmp     scrollup
        !          1255: 
        !          1256: ////////
        !          1257: /
        !          1258: / mm_new - save cursor position
        !          1259: /
        !          1260: ////////
        !          1261: 
        !          1262: mm_new:        movb    MM_SCOL(bp), COL
        !          1263:        movb    MM_SROW(bp), ROW
        !          1264:        jmp     eval
        !          1265: 
        !          1266: ////////
        !          1267: /
        !          1268: / mm_old - restore old cursor position
        !          1269: /
        !          1270: ////////
        !          1271: 
        !          1272: mm_old:        movb    COL, MM_SCOL(bp)
        !          1273:        movb    ROW, MM_SROW(bp)
        !          1274:        jmp     repos
        !          1275: 
        !          1276: ////////
        !          1277: /
        !          1278: / mm_ri - reverse index
        !          1279: /
        !          1280: /      Moves the active position to the same horizontal position on the
        !          1281: /      preceding line.  Scrolling occurs if above scrolling region.
        !          1282: /
        !          1283: ////////
        !          1284: 
        !          1285: mm_ri: decb    ROW
        !          1286:        cmpb    ROW, MM_BROW(bp)
        !          1287:        jge     0f
        !          1288:        movb    ROW, MM_BROW(bp)
        !          1289:        jmp     scrolldown
        !          1290: 0:     jmp     repos
        !          1291: 
        !          1292: ////////
        !          1293: /
        !          1294: / mm_scr - select cursor rendition
        !          1295: /
        !          1296: /      Invokes the cursor rendition specified by the parameter.
        !          1297: /
        !          1298: /      Recognized renditions are:      0 - cursor visible
        !          1299: /                                      1 - cursor invisible
        !          1300: ////////
        !          1301: 
        !          1302: mm_scr:        decb     MM_N1(bp)
        !          1303:        je      0f
        !          1304:        jg      1f
        !          1305:        mov     MM_INVIS(bp), $0
        !          1306:        jmp     eval
        !          1307: 
        !          1308: 0:     mov     MM_INVIS(bp), $-1
        !          1309: 1:     jmp     eval
        !          1310: 
        !          1311: ////////
        !          1312: /
        !          1313: / mm_sgr - select graphic rendition
        !          1314: /
        !          1315: /      Invokes the graphic rendition specified by the parameter.
        !          1316: /      All following characters in the data stream are rendered
        !          1317: /      according to the parameters until the next occurrence of
        !          1318: /      SGR in the data stream.
        !          1319: /
        !          1320: /      Recognized renditions are:      1 - high intensity
        !          1321: /                                      4 - underline
        !          1322: /                                      5 - slow blink
        !          1323: /                                      7 - reverse video
        !          1324: /                                      8 - concealed on
        !          1325: /                                      30-37 - foreground color
        !          1326: /                                      40-47 - background color
        !          1327: /                                      50-57 - border color
        !          1328: /
        !          1329: ////////
        !          1330: 
        !          1331: mm_sgr:        movb    al, MM_N1(bp)
        !          1332: 
        !          1333:        cmpb    al, $0                  / reset all = 0
        !          1334:        jne     0f
        !          1335:        movb    ATTR, $0x07
        !          1336: 1:     jmp     eval
        !          1337: 
        !          1338: 0:     cmpb    al, $1                  / bold = 1
        !          1339:        jne     0f
        !          1340:        orb     ATTR, $INTENSE
        !          1341:        jmp     1b
        !          1342: 
        !          1343: 0:     cmpb    al, $4                  / underline = 4
        !          1344:        jne     0f
        !          1345:        cmp     MM_PORT(bp), $0x03D4    / color card?
        !          1346:        je      1b                      / yes, ignore underline
        !          1347:        andb    ATTR, $~0x77
        !          1348:        orb     ATTR, $0x01
        !          1349:        jmp     1b
        !          1350: 
        !          1351: 0:     cmpb    al, $5                  / blinking = 5
        !          1352:        jne     0f
        !          1353:        orb     ATTR, $BLINK
        !          1354:        jmp     1b
        !          1355: 
        !          1356: 0:     cmpb    al, $7                  / reverse video = 7
        !          1357:        jne     0f
        !          1358:        movb    al, $0x70
        !          1359:        cmp     MM_PORT(bp), $0x3D4     / color card?
        !          1360:        jne     2f
        !          1361:        movb    al, ATTR                / yes, exchange foreground/background
        !          1362:        andb    al, $0x77
        !          1363:        rolb    al, $1
        !          1364:        rolb    al, $1
        !          1365:        rolb    al, $1
        !          1366:        rolb    al, $1
        !          1367: 2:     andb    ATTR, $~0x77
        !          1368:        orb     ATTR, al
        !          1369:        jmp     1b
        !          1370: 
        !          1371: 0:     cmpb    al, $8                  / concealed on = 8
        !          1372:        jne     0f
        !          1373:        cmp     MM_PORT(bp), $0x3D4     / color card?
        !          1374:        jne     2f
        !          1375: 
        !          1376:        andb    ATTR, $0x70             / Yes,  Set foreground color
        !          1377:        movb    al, ATTR                /       to background color.
        !          1378:        rorb    al, $1
        !          1379:        rorb    al, $1
        !          1380:        rorb    al, $1
        !          1381:        rorb    al, $1
        !          1382:        orb     ATTR, al
        !          1383:        jmp     1b
        !          1384: 
        !          1385: 2:     andb    ATTR, $0x80             / No, set attributes to non-display.
        !          1386:        jmp     1b                      /       retain blink attribute.
        !          1387: 
        !          1388: 0:     cmp     MM_PORT(bp), $0x03D4    / color card?
        !          1389:        jne     1b                      / no, ignore remaining options
        !          1390: 0:     subb    al, $30                 / foreground color
        !          1391:        jl      1f
        !          1392:        cmpb    al, $7
        !          1393:        jg      0f
        !          1394:        movb    bl, al
        !          1395:        andb    ATTR, $~0x07
        !          1396:        orb     ATTR, cs:fcolor(bx)
        !          1397:        jmp     1f
        !          1398: 0:     subb    al, $10
        !          1399:        jl      1f
        !          1400:        cmpb    al, $7
        !          1401:        jg      0f
        !          1402:        movb    bl, al
        !          1403:        andb    ATTR, $~0x70
        !          1404:        orb     ATTR, cs:bcolor(bx)
        !          1405:        jmp     1f
        !          1406: 0:     subb    al, $10
        !          1407:        jl      1f
        !          1408:        cmpb    al, $7
        !          1409:        jg      0f
        !          1410:        movb    bl, al
        !          1411:        movb    al, cs:fcolor(bx)
        !          1412:        push    dx
        !          1413:        mov     dx, MM_PORT(bp)
        !          1414:        add     dx, $5
        !          1415:        outb    dx, al
        !          1416:        pop     dx
        !          1417: /      jmp     1f
        !          1418: 0:
        !          1419: 1:     jmp     eval
        !          1420: 
        !          1421: ////////
        !          1422: /
        !          1423: / mm_ssr - set scrolling region
        !          1424: /
        !          1425: ////////
        !          1426: 
        !          1427: mm_ssr:        movb    al, MM_N1(bp)
        !          1428:        decb    al
        !          1429:        jge     0f
        !          1430:        subb    al, al
        !          1431: 0:     cmpb    al, MM_LROW(bp)
        !          1432:        ja      1f
        !          1433:        movb    bl, MM_N2(bp)
        !          1434:        decb    bl
        !          1435:        jge     0f
        !          1436:        subb    bl, bl
        !          1437: 0:     cmpb    bl, MM_LROW(bp)
        !          1438:        ja      1f
        !          1439:        cmpb    al, bl
        !          1440:        ja      1f
        !          1441:        movb    MM_BROW(bp), al
        !          1442:        movb    MM_EROW(bp), bl
        !          1443:        movb    ROW, al
        !          1444:        subb    COL, COL
        !          1445: 1:     jmp     repos
        !          1446: 
        !          1447: ////////
        !          1448: /
        !          1449: / mm_vpa - vertical position absolute
        !          1450: /
        !          1451: /      Moves the active position to the line specified by the parameter
        !          1452: /      without changing the horizontal position.
        !          1453: /      A parameter value of 0 or 1 moves the active position vertically
        !          1454: /      to the first line.
        !          1455: /
        !          1456: ////////
        !          1457: 
        !          1458: mm_vpa:        movb    ROW, MM_N1(bp)
        !          1459:        decb    ROW
        !          1460:        jg      0f
        !          1461:        subb    ROW, ROW
        !          1462: 0:     cmpb    ROW, MM_LROW(bp)
        !          1463:        jna     0f
        !          1464:        movb    ROW, MM_LROW(bp)
        !          1465: 0:     jmp     repos                   / reposition cursor
        !          1466: 
        !          1467: ////////
        !          1468: /
        !          1469: / mm_vpr - vertical position relative
        !          1470: /
        !          1471: /      Moves the active position downward the number of lines specified
        !          1472: /      by the parameter without changing the horizontal position.
        !          1473: /      A parameter value of zero or one moves the active position
        !          1474: /      one line downward.
        !          1475: /
        !          1476: ////////
        !          1477: 
        !          1478: mm_vpr:        movb    al, MM_N1(bp)
        !          1479:        orb     al, al
        !          1480:        jne     0f
        !          1481:        incb    al
        !          1482: 0:     addb    ROW, al
        !          1483:        cmpb    ROW, MM_LROW(bp)
        !          1484:        jb      0f
        !          1485:        movb    ROW, MM_LROW(bp)
        !          1486: 0:     jmp     repos                   / reposition cursor
        !          1487: 
        !          1488: ////////
        !          1489: /
        !          1490: / asctab - table of functions indexed by ascii characters
        !          1491: /
        !          1492: ////////
        !          1493: 
        !          1494: asctab:        .word   eval,   eval,   eval,   eval    /* NUL  SOH  STX  ETX  */
        !          1495:        .word   eval,   eval,   eval,   mmbell  /* EOT  ENQ  ACK  BEL  */
        !          1496:        .word   mm_cub, mm_cht, mm_cnl, mm_ind  /* BS   HT   LF   VT   */
        !          1497:        .word   eval,   mm_cr,  eval,   eval    /* FF   CR   SO   SI   */
        !          1498:        .word   eval,   eval,   eval,   eval    /* DLE  DC1  DC2  DC3  */
        !          1499:        .word   eval,   eval,   eval,   eval    /* DC4  NAK  SYN  ETB  */
        !          1500:        .word   eval,   eval,   eval,   mm_esc  /* CAN  EM   SUB  ESC  */
        !          1501:        .word   eval,   eval,   eval,   eval    /* FS   GS   RS   US   */
        !          1502:        .word   mmputc, mmputc, mmputc, mmputc  /*   ! " # \040 - \043 */
        !          1503:        .word   mmputc, mmputc, mmputc, mmputc  /* $ % & quote \044 - \047 */
        !          1504:        .word   mmputc, mmputc, mmputc, mmputc  /* ( ) * + \050 - \053 */
        !          1505:        .word   mmputc, mmputc, mmputc, mmputc  /* , - . / \054 - \057 */
        !          1506:        .word   mmputc, mmputc, mmputc, mmputc  /* 0 1 2 3 \060 - \063 */
        !          1507:        .word   mmputc, mmputc, mmputc, mmputc  /* 4 5 6 7 \064 - \067 */
        !          1508:        .word   mmputc, mmputc, mmputc, mmputc  /* 8 9 : ; \070 - \073 */
        !          1509:        .word   mmputc, mmputc, mmputc, mmputc  /* < = > ? \074 - \077 */
        !          1510:        .word   mmputc, mmputc, mmputc, mmputc  /* @ A B C \100 - \103 */
        !          1511:        .word   mmputc, mmputc, mmputc, mmputc  /* D E F G \104 - \107 */
        !          1512:        .word   mmputc, mmputc, mmputc, mmputc  /* H I J K \110 - \113 */
        !          1513:        .word   mmputc, mmputc, mmputc, mmputc  /* L M N O \114 - \117 */
        !          1514:        .word   mmputc, mmputc, mmputc, mmputc  /* P Q R S \120 - \123 */
        !          1515:        .word   mmputc, mmputc, mmputc, mmputc  /* T U V W \124 - \127 */
        !          1516:        .word   mmputc, mmputc, mmputc, mmputc  /* X Y Z [ \130 - \133 */
        !          1517:        .word   mmputc, mmputc, mmputc, mmputc  /* \ ] ^ _ \134 - \137 */
        !          1518:        .word   mmputc, mmputc, mmputc, mmputc  /* ` a b c \140 - \143 */
        !          1519:        .word   mmputc, mmputc, mmputc, mmputc  /* d e f g \144 - \147 */
        !          1520:        .word   mmputc, mmputc, mmputc, mmputc  /* h i j k \150 - \153 */
        !          1521:        .word   mmputc, mmputc, mmputc, mmputc  /* l m n o \154 - \157 */
        !          1522:        .word   mmputc, mmputc, mmputc, mmputc  /* p q r s \160 - \163 */
        !          1523:        .word   mmputc, mmputc, mmputc, mmputc  /* t u v w \164 - \167 */
        !          1524:        .word   mmputc, mmputc, mmputc, mmputc  /* x y z { \170 - \173 */
        !          1525:        .word   mmputc, mmputc, mmputc, mmputc  /* | } ~ ? \174 - \177 */
        !          1526: 
        !          1527: ////////
        !          1528: /
        !          1529: / esctab - table of functions indexed by ESC characters.
        !          1530: /
        !          1531: ////////
        !          1532: 
        !          1533: esctab:        .word   mmputc, mmputc, mmputc, mmputc  /* NUL  SOH  STX  ETX  */
        !          1534:        .word   mmputc, mmputc, mmputc, mmputc  /* EOT  ENQ  ACK  BEL  */
        !          1535:        .word   mmputc, mmputc, mmputc, mmputc  /* BS   HT   LF   VT   */
        !          1536:        .word   mmputc, mmputc, mmputc, mmputc  /* FF   CR   SO   SI   */
        !          1537:        .word   mmputc, mmputc, mmputc, mmputc  /* DLE  DC1  DC2  DC3  */
        !          1538:        .word   mmputc, mmputc, mmputc, mmputc  /* DC4  NAK  SYN  ETB  */
        !          1539:        .word   mmputc, mmputc, mmputc, mmputc  /* CAN  EM   SUB  ESC  */
        !          1540:        .word   mmputc, mmputc, mmputc, mmputc  /* FS   GS   RS   US   */
        !          1541:        .word   eval,   eval,   eval,   eval    /*   ! " # \040 - \043 */
        !          1542:        .word   eval,   eval,   eval,   eval    /* $ % & quote \044 - \047 */
        !          1543:        .word   eval,   eval,   eval,   eval    /* ( ) * + \050 - \053 */
        !          1544:        .word   eval,   eval,   eval,   eval    /* , - . / \054 - \057 */
        !          1545:        .word   eval,   eval,   eval,   eval    /* 0 1 2 3 \060 - \063 */
        !          1546:        .word   eval,   eval,   eval,   mm_new  /* 4 5 6 7 \064 - \067 */
        !          1547:        .word   mm_old, eval,   eval,   eval    /* 8 9 : ; \070 - \073 */
        !          1548:        .word   eval,   mmspec, mmspec, eval    /* < = > ? \074 - \077 */
        !          1549:        .word   eval,   eval,   eval,   eval    /* @ A B C \100 - \103 */
        !          1550:        .word   mm_ind, mm_cnl, eval,   eval    /* D E F G \104 - \107 */
        !          1551:        .word   eval,   eval,   eval,   eval    /* H I J K \110 - \113 */
        !          1552:        .word   eval,   mm_ri,  eval,   eval    /* L M N O \114 - \117 */
        !          1553:        .word   eval,   eval,   eval,   eval    /* P Q R S \120 - \123 */
        !          1554:        .word   eval,   eval,   eval,   eval    /* T U V W \124 - \127 */
        !          1555:        .word   eval,   eval,   eval,   csi_n1  /* X Y Z [ \130 - \133 */
        !          1556:        .word   eval,   eval,   eval,   eval    /* \ ] ^ _ \134 - \137 */
        !          1557:        .word   mm_dmi, eval,   mm_emi, mminit2 /* quote a b c \140 - \143 */
        !          1558:        .word   eval,   eval,   eval,   eval    /* d e f g \144 - \147 */
        !          1559:        .word   eval,   eval,   eval,   eval    /* h i j k \150 - \153 */
        !          1560:        .word   eval,   eval,   eval,   eval    /* l m n o \154 - \157 */
        !          1561:        .word   eval,   eval,   eval,   eval    /* p q r s \160 - \163 */
        !          1562:        .word   mmspec, mmspec, eval,   eval    /* t u v w \164 - \167 */
        !          1563:        .word   eval,   eval,   eval,   eval    /* x y z { \170 - \173 */
        !          1564:        .word   eval,   eval,   eval,   eval    /* | } ~ ? \174 - \177 */
        !          1565: 
        !          1566: 
        !          1567: ////////
        !          1568: /
        !          1569: / csitab - table of functions indexed by ESC [ characters.
        !          1570: /
        !          1571: ////////
        !          1572: 
        !          1573: csitab:        .word   eval,   eval,   eval,   eval    /* NUL  SOH  STX  ETX  */
        !          1574:        .word   eval,   eval,   eval,   eval    /* EOT  ENQ  ACK  BEL  */
        !          1575:        .word   eval,   eval,   eval,   eval    /* BS   HT   LF   VT   */
        !          1576:        .word   eval,   eval,   eval,   eval    /* FF   CR   SO   SI   */
        !          1577:        .word   eval,   eval,   eval,   eval    /* DLE  DC1  DC2  DC3  */
        !          1578:        .word   eval,   eval,   eval,   eval    /* DC4  NAK  SYN  ETB  */
        !          1579:        .word   eval,   eval,   eval,   eval    /* CAN  EM   SUB  ESC  */
        !          1580:        .word   eval,   eval,   eval,   eval    /* FS   GS   RS   US   */
        !          1581:        .word   eval,   eval,   eval,   eval    /*   ! " # \040 - \043 */
        !          1582:        .word   eval,   eval,   eval,   eval    /* $ % & quote \044 - \047 */
        !          1583:        .word   eval,   eval,   eval,   eval    /* ( ) * + \050 - \053 */
        !          1584:        .word   eval,   eval,   eval,   eval    /* , - . / \054 - \057 */
        !          1585:        .word   eval,   eval,   eval,   eval    /* 0 1 2 3 \060 - \063 */
        !          1586:        .word   eval,   eval,   eval,   eval    /* 4 5 6 7 \064 - \067 */
        !          1587:        .word   eval,   eval,   eval,   eval    /* 8 9 : ; \070 - \073 */
        !          1588:        .word   eval,   eval,   csi_gt, csi_q   /* < = > ? \074 - \077 */
        !          1589:        .word   eval,   mm_cuu, mm_cud, mm_cuf  /* @ A B C \100 - \103 */
        !          1590:        .word   mm_cub, mm_cnl, mm_cpl, mm_cha  /* D E F G \104 - \107 */
        !          1591:        .word   mm_cup, mm_cht, mm_ed,  mm_el   /* H I J K \110 - \113 */
        !          1592:        .word   mm_il,  mm_dl,  eval,   mm_ea   /* L M N O \114 - \117 */
        !          1593:        .word   eval,   eval,   eval,   mm_ind  /* P Q R S \120 - \123 */
        !          1594:        .word   mm_ri,  eval,   eval,   eval    /* T U V W \124 - \127 */
        !          1595:        .word   eval,   eval,   mm_cbt, eval    /* X Y Z [ \130 - \133 */
        !          1596:        .word   eval,   eval,   eval,   eval    /* \ ] ^ _ \134 - \137 */
        !          1597:        .word   mm_hpa, mm_hpr, eval,   eval    /* ` a b c \140 - \143 */
        !          1598:        .word   mm_vpa, mm_vpr, mm_hvp, mm_cup  /* d e f g \144 - \147 */
        !          1599:        .word   eval,   eval,   eval,   eval    /* h i j k \150 - \153 */
        !          1600:        .word   eval,   mm_sgr, eval,   eval    /* l m n o \154 - \157 */
        !          1601:        .word   eval,   eval,   mm_ssr, eval    /* p q r s \160 - \163 */
        !          1602:        .word   eval,   eval,   mm_scr, eval    /* t u v w \164 - \167 */
        !          1603:        .word   eval,   eval,   eval,   eval    /* x y z { \170 - \173 */
        !          1604:        .word   eval,   eval,   eval,   eval    /* | } ~ ? \174 - \177 */
        !          1605: 
        !          1606: ////////
        !          1607: /
        !          1608: / coltab - integer array of offsets to each column
        !          1609: /
        !          1610: ////////
        !          1611: 
        !          1612: coltab:        .word    0*NCB,  1*NCB,  2*NCB,  3*NCB
        !          1613:        .word    4*NCB,  5*NCB,  6*NCB,  7*NCB
        !          1614:        .word    8*NCB,  9*NCB, 10*NCB, 11*NCB
        !          1615:        .word   12*NCB, 13*NCB, 14*NCB, 15*NCB
        !          1616:        .word   16*NCB, 17*NCB, 18*NCB, 19*NCB
        !          1617:        .word   20*NCB, 21*NCB, 22*NCB, 23*NCB
        !          1618:        .word   24*NCB, 25*NCB, 26*NCB, 27*NCB
        !          1619:        .word   28*NCB, 29*NCB, 30*NCB, 31*NCB
        !          1620:        .word   32*NCB, 33*NCB, 34*NCB, 35*NCB
        !          1621:        .word   36*NCB, 37*NCB, 38*NCB, 39*NCB
        !          1622:        .word   40*NCB, 41*NCB, 42*NCB, 43*NCB
        !          1623:        .word   44*NCB, 45*NCB, 46*NCB, 47*NCB
        !          1624:        .word   48*NCB, 49*NCB, 50*NCB, 51*NCB
        !          1625:        .word   52*NCB, 53*NCB, 54*NCB, 55*NCB
        !          1626:        .word   56*NCB, 57*NCB, 58*NCB, 59*NCB
        !          1627:        .word   60*NCB, 61*NCB, 62*NCB, 63*NCB
        !          1628:        .word   64*NCB, 65*NCB, 66*NCB, 67*NCB
        !          1629:        .word   68*NCB, 69*NCB, 70*NCB, 71*NCB
        !          1630:        .word   72*NCB, 73*NCB, 74*NCB, 75*NCB
        !          1631:        .word   76*NCB, 77*NCB, 78*NCB, 79*NCB
        !          1632: 
        !          1633: ////////
        !          1634: /
        !          1635: / rowtab - array of offsets to each row
        !          1636: /
        !          1637: ////////
        !          1638: 
        !          1639: rowtab:        .word    0*NRB,  1*NRB,  2*NRB,  3*NRB
        !          1640:        .word    4*NRB,  5*NRB,  6*NRB,  7*NRB
        !          1641:        .word    8*NRB,  9*NRB, 10*NRB, 11*NRB
        !          1642:        .word   12*NRB, 13*NRB, 14*NRB, 15*NRB
        !          1643:        .word   16*NRB, 17*NRB, 18*NRB, 19*NRB
        !          1644:        .word   20*NRB, 21*NRB, 22*NRB, 23*NRB
        !          1645:        .word   24*NRB, 25*NRB, 26*NRB, 27*NRB
        !          1646:        .word   28*NRB, 29*NRB, 30*NRB, 31*NRB
        !          1647: 
        !          1648: ////////
        !          1649: /
        !          1650: / fcolor - foreground color
        !          1651: / bcolor - background color
        !          1652: /
        !          1653: /      indexed by ansi color (black,red,green,brown,blue,magenta,cyan,white)
        !          1654: /      yields graphics color (black,blue,green,cyan,red,magenta,brown,white)
        !          1655: /              which is properly shifted for installation in attribute byte.
        !          1656: /
        !          1657: ////////
        !          1658: 
        !          1659: fcolor:        .byte   0x00, 0x04, 0x02, 0x06, 0x01, 0x05, 0x03, 0x07
        !          1660: bcolor:        .byte   0x00, 0x40, 0x20, 0x60, 0x10, 0x50, 0x30, 0x70
        !          1661: 
        !          1662: ////////
        !          1663: /
        !          1664: / mm_voff()    -- turn video display off
        !          1665: /
        !          1666: ////////
        !          1667:        .globl  mm_voff_
        !          1668: mm_voff_:
        !          1669:        mov     dx, mmdata+MM_PORT
        !          1670:        add     dx, $4
        !          1671:        movb    al, $0x21
        !          1672:        outb    dx, al
        !          1673:        ret
        !          1674: 
        !          1675: ////////
        !          1676: /
        !          1677: / mm_von()     -- turn video display on
        !          1678: /
        !          1679: ////////
        !          1680:        .globl  mm_von_
        !          1681: mm_von_:
        !          1682:        mov     dx, mmdata+MM_PORT      / enable video display
        !          1683:        add     dx, $4
        !          1684:        movb    al, $0x29
        !          1685:        outb    dx, al
        !          1686:        mov     mmvcnt_, $900           / 900 seconds before video disabled
        !          1687:        ret

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.