Annotation of coherent/b/kernel/io.386/vtmmas.s, revision 1.1.1.1

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

unix.superglobalmegacorp.com

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