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

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

unix.superglobalmegacorp.com

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