home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s196 / 2.img / IBMPC.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-08-13  |  9.6 KB  |  610 lines

  1.     ifndef    ??version
  2. ?debug    macro
  3.     endm
  4. publicdll macro    name
  5.     public    name
  6.     endm
  7. $comm    macro    name,dist,size,count
  8.     comm    dist name:BYTE:count*size
  9.     endm
  10.     else
  11. $comm    macro    name,dist,size,count
  12.     comm    dist name[size]:BYTE:count
  13.     endm
  14.     endif
  15.     ?debug    S "ibmpc.cpp"
  16.     ?debug    C E9D7A80D170969626D70632E637070
  17.     ?debug    C E90010971614443A5C4243435C494E434C5544455C646F732E68
  18. _TEXT    segment byte public 'CODE'
  19. _TEXT    ends
  20. DGROUP    group    _DATA,_BSS
  21.     assume    cs:_TEXT,ds:DGROUP
  22. _DATA    segment word public 'DATA'
  23. d@    label    byte
  24. d@w    label    word
  25. _DATA    ends
  26. _BSS    segment word public 'BSS'
  27. b@    label    byte
  28. b@w    label    word
  29. _BSS    ends
  30. _TEXT    segment byte public 'CODE'
  31.    ;    
  32.    ;    void pascal  cursor(int x, int y)
  33.    ;    
  34.     assume    cs:_TEXT
  35. @CURSOR$QII    proc    near
  36.     push    bp
  37.     mov    bp,sp
  38.    ;    
  39.    ;    {
  40.    ;        rg.x.ax = 0x0200;
  41.    ;    
  42.     mov    word ptr DGROUP:rg,512
  43.    ;    
  44.    ;        rg.x.bx = 0;
  45.    ;    
  46.     mov    word ptr DGROUP:rg+2,0
  47.    ;    
  48.    ;        rg.x.dx = ((y << 8) & 0xff00) + x;
  49.    ;    
  50.     mov    ax,word ptr [bp+4]
  51.     mov    cl,8
  52.     shl    ax,cl
  53.     and    ax,65280
  54.     add    ax,word ptr [bp+6]
  55.     mov    word ptr DGROUP:rg+6,ax
  56.    ;    
  57.    ;        int86(16, &rg, &rg);
  58.    ;    
  59.     mov    ax,offset DGROUP:rg
  60.     push    ax
  61.     mov    ax,offset DGROUP:rg
  62.     push    ax
  63.     mov    ax,16
  64.     push    ax
  65.     call    near ptr _int86
  66.     add    sp,6
  67.    ;    
  68.    ;    }
  69.    ;    
  70.     pop    bp
  71.     ret    4
  72. @CURSOR$QII    endp
  73.    ;    
  74.    ;    void pascal  curr_cursor(int *x, int *y)
  75.    ;    
  76.     assume    cs:_TEXT
  77. @CURR_CURSOR$QPIT1    proc    near
  78.     push    bp
  79.     mov    bp,sp
  80.     push    si
  81.     push    di
  82.     mov    si,word ptr [bp+6]
  83.     mov    di,word ptr [bp+4]
  84.    ;    
  85.    ;    {
  86.    ;        rg.x.ax = 0x0300;
  87.    ;    
  88.     mov    word ptr DGROUP:rg,768
  89.    ;    
  90.    ;        rg.x.bx = 0;
  91.    ;    
  92.     mov    word ptr DGROUP:rg+2,0
  93.    ;    
  94.    ;        int86(16, &rg, &rg);
  95.    ;    
  96.     mov    ax,offset DGROUP:rg
  97.     push    ax
  98.     mov    ax,offset DGROUP:rg
  99.     push    ax
  100.     mov    ax,16
  101.     push    ax
  102.     call    near ptr _int86
  103.     add    sp,6
  104.    ;    
  105.    ;        *x = rg.h.dl;
  106.    ;    
  107.     mov    al,byte ptr DGROUP:rg+6
  108.     mov    ah,0
  109.     mov    word ptr [si],ax
  110.    ;    
  111.    ;        *y = rg.h.dh;
  112.    ;    
  113.     mov    al,byte ptr DGROUP:rg+7
  114.     mov    ah,0
  115.     mov    word ptr [di],ax
  116.    ;    
  117.    ;    }
  118.    ;    
  119.     pop    di
  120.     pop    si
  121.     pop    bp
  122.     ret    4
  123. @CURR_CURSOR$QPIT1    endp
  124.    ;    
  125.    ;    void pascal  set_cursor_type(int t)
  126.    ;    
  127.     assume    cs:_TEXT
  128. @SET_CURSOR_TYPE$QI    proc    near
  129.     push    bp
  130.     mov    bp,sp
  131.    ;    
  132.    ;    {
  133.    ;        rg.x.ax = 0x0100;
  134.    ;    
  135.     mov    word ptr DGROUP:rg,256
  136.    ;    
  137.    ;        rg.x.bx = 0;
  138.    ;    
  139.     mov    word ptr DGROUP:rg+2,0
  140.    ;    
  141.    ;        rg.x.cx = t;
  142.    ;    
  143.     mov    ax,word ptr [bp+4]
  144.     mov    word ptr DGROUP:rg+4,ax
  145.    ;    
  146.    ;        int86(16, &rg, &rg);
  147.    ;    
  148.     mov    ax,offset DGROUP:rg
  149.     push    ax
  150.     mov    ax,offset DGROUP:rg
  151.     push    ax
  152.     mov    ax,16
  153.     push    ax
  154.     call    near ptr _int86
  155.     add    sp,6
  156.    ;    
  157.    ;    }
  158.    ;    
  159.     pop    bp
  160.     ret    2
  161. @SET_CURSOR_TYPE$QI    endp
  162. _TEXT    ends
  163. _DATA    segment word public 'DATA'
  164. _attrib    label    byte
  165.     db    7
  166. _DATA    ends
  167. _TEXT    segment byte public 'CODE'
  168.    ;    
  169.    ;    void pascal  clear_screen()
  170.    ;    
  171.     assume    cs:_TEXT
  172. @CLEAR_SCREEN$QV    proc    near
  173.     push    bp
  174.     mov    bp,sp
  175.    ;    
  176.    ;    {
  177.    ;        cursor(0, 0);
  178.    ;    
  179.     xor    ax,ax
  180.     push    ax
  181.     xor    ax,ax
  182.     push    ax
  183.     call    near ptr @CURSOR$QII
  184.    ;    
  185.    ;        rg.h.al = ' ';
  186.    ;    
  187.     mov    byte ptr DGROUP:rg,32
  188.    ;    
  189.    ;        rg.h.ah = 9;
  190.    ;    
  191.     mov    byte ptr DGROUP:rg+1,9
  192.    ;    
  193.    ;        rg.x.bx = attrib;
  194.    ;    
  195.     mov    al,byte ptr DGROUP:_attrib
  196.     cbw    
  197.     mov    word ptr DGROUP:rg+2,ax
  198.    ;    
  199.    ;        rg.x.cx = 2000;
  200.    ;    
  201.     mov    word ptr DGROUP:rg+4,2000
  202.    ;    
  203.    ;        int86(16, &rg, &rg);
  204.    ;    
  205.     mov    ax,offset DGROUP:rg
  206.     push    ax
  207.     mov    ax,offset DGROUP:rg
  208.     push    ax
  209.     mov    ax,16
  210.     push    ax
  211.     call    near ptr _int86
  212.     add    sp,6
  213.    ;    
  214.    ;    }
  215.    ;    
  216.     pop    bp
  217.     ret    
  218. @CLEAR_SCREEN$QV    endp
  219.    ;    
  220.    ;    int pascal  vmode()
  221.    ;    
  222.     assume    cs:_TEXT
  223. @VMODE$QV    proc    near
  224.     push    bp
  225.     mov    bp,sp
  226.    ;    
  227.    ;    {
  228.    ;        rg.h.ah = 15;
  229.    ;    
  230.     mov    byte ptr DGROUP:rg+1,15
  231.    ;    
  232.    ;        int86(16, &rg, &rg);
  233.    ;    
  234.     mov    ax,offset DGROUP:rg
  235.     push    ax
  236.     mov    ax,offset DGROUP:rg
  237.     push    ax
  238.     mov    ax,16
  239.     push    ax
  240.     call    near ptr _int86
  241.     add    sp,6
  242.    ;    
  243.    ;        return rg.h.al;
  244.    ;    
  245.     mov    al,byte ptr DGROUP:rg
  246.     mov    ah,0
  247.     jmp    short @5@50
  248. @5@50:
  249.    ;    
  250.    ;    }
  251.    ;    
  252.     pop    bp
  253.     ret    
  254. @VMODE$QV    endp
  255.    ;    
  256.    ;    int pascal   scroll_lock()
  257.    ;    
  258.     assume    cs:_TEXT
  259. @SCROLL_LOCK$QV    proc    near
  260.     push    bp
  261.     mov    bp,sp
  262.    ;    
  263.    ;    {
  264.    ;        rg.x.ax = 0x0200;
  265.    ;    
  266.     mov    word ptr DGROUP:rg,512
  267.    ;    
  268.    ;        int86(0x16, &rg, &rg);
  269.    ;    
  270.     mov    ax,offset DGROUP:rg
  271.     push    ax
  272.     mov    ax,offset DGROUP:rg
  273.     push    ax
  274.     mov    ax,22
  275.     push    ax
  276.     call    near ptr _int86
  277.     add    sp,6
  278.    ;    
  279.    ;        return rg.h.al & 0x10;
  280.    ;    
  281.     mov    al,byte ptr DGROUP:rg
  282.     mov    ah,0
  283.     and    ax,16
  284.     jmp    short @6@50
  285. @6@50:
  286.    ;    
  287.    ;    }
  288.    ;    
  289.     pop    bp
  290.     ret    
  291. @SCROLL_LOCK$QV    endp
  292. _TEXT    ends
  293. _BSS    segment word public 'BSS'
  294. _helpfunc    label    word
  295.     db    2 dup (?)
  296. _BSS    ends
  297. _DATA    segment word public 'DATA'
  298. _helpkey    label    word
  299.     db    0
  300.     db    0
  301. _DATA    ends
  302. _BSS    segment word public 'BSS'
  303. _BSS    ends
  304. _DATA    segment word public 'DATA'
  305. _helping    label    word
  306.     db    0
  307.     db    0
  308. _DATA    ends
  309. _BSS    segment word public 'BSS'
  310. _BSS    ends
  311. _TEXT    segment byte public 'CODE'
  312.    ;    
  313.    ;    void pascal  vpoke(unsigned vseg, unsigned adr, unsigned chr)
  314.    ;    
  315.     assume    cs:_TEXT
  316. @VPOKE$QUIUIUI    proc    near
  317.     push    bp
  318.     mov    bp,sp
  319.     push    si
  320.     push    di
  321.     mov    si,word ptr [bp+8]
  322.     mov    cx,word ptr [bp+6]
  323.    ;    
  324.    ;    {
  325.    ;        if (vseg == 45056)            /* monochrome mode */
  326.    ;    
  327.     xor    ax,ax
  328.     or    ax,ax
  329.     jne    short @7@98
  330.     cmp    si,45056
  331.     jne    short @7@98
  332.    ;    
  333.    ;            poke(vseg, adr, chr);
  334.    ;    
  335.     mov    es,si
  336.     mov    bx,cx
  337.     mov    ax,word ptr [bp+4]
  338.     mov    word ptr es:[bx],ax
  339.     jmp    short @7@458
  340. @7@98:
  341.    ;    
  342.    ;        else    {
  343.    ;            _DI = adr;        /* offset of video character */
  344.    ;    
  345.     mov    di,cx
  346.    ;    
  347.    ;            _ES = vseg;        /* video segment */
  348.    ;    
  349.     mov    es,si
  350.    ;    
  351.    ;            asm cld;
  352.    ;    
  353.      cld    
  354.    ;    
  355.    ;            _BX = chr;        /* the attribute and character */
  356.    ;    
  357.     mov    bx,word ptr [bp+4]
  358.    ;    
  359.    ;            _DX = 986;        /* video status port */
  360.    ;    
  361.     mov    dx,986
  362. @7@170:
  363.    ;    
  364.    ;                    //        wait for video retrace to start
  365.    ;            do
  366.    ;                asm in  al,dx;
  367.    ;    
  368.      in      al,dx
  369.    ;    
  370.    ;            while (_AL & 1);
  371.    ;    
  372.     mov    ah,0
  373.     test    ax,1
  374.     jne    short @7@170
  375. @7@218:
  376.    ;    
  377.    ;                    //        wait for video retrace to stop
  378.    ;            do
  379.    ;                asm in  al,dx;
  380.    ;    
  381.      in      al,dx
  382.    ;    
  383.    ;            while (!(_AL & 1));
  384.    ;    
  385.     and    al,1
  386.     mov    ah,0
  387.     or    ax,ax
  388.     je    short @7@218
  389.    ;    
  390.    ;            _AL = _BL;
  391.    ;    
  392.     mov    al,bl
  393.    ;    
  394.    ;            asm stosb;        /* store character */
  395.    ;    
  396.      stosb    
  397. @7@314:
  398.    ;    
  399.    ;                    //        wait for video retrace to start
  400.    ;            do
  401.    ;                asm in  al,dx;
  402.    ;    
  403.      in      al,dx
  404.    ;    
  405.    ;            while (_AL & 1);
  406.    ;    
  407.     mov    ah,0
  408.     test    ax,1
  409.     jne    short @7@314
  410. @7@362:
  411.    ;    
  412.    ;                    //        wait for video retrace to stop
  413.    ;            do
  414.    ;                asm in  al,dx;
  415.    ;    
  416.      in      al,dx
  417.    ;    
  418.    ;            while (!(_AL & 1));
  419.    ;    
  420.     and    al,1
  421.     mov    ah,0
  422.     or    ax,ax
  423.     je    short @7@362
  424.    ;    
  425.    ;            _AL = _BH;
  426.    ;    
  427.     mov    al,bh
  428.    ;    
  429.    ;                    asm stosb;              // store attribute
  430.    ;    
  431.      stosb    
  432. @7@458:
  433.    ;    
  434.    ;        }
  435.    ;    }
  436.    ;    
  437.     pop    di
  438.     pop    si
  439.     pop    bp
  440.     ret    6
  441. @VPOKE$QUIUIUI    endp
  442.    ;    
  443.    ;    int pascal  vpeek(unsigned vseg, unsigned adr)
  444.    ;    
  445.     assume    cs:_TEXT
  446. @VPEEK$QUIUI    proc    near
  447.     push    bp
  448.     mov    bp,sp
  449.     push    si
  450.     push    di
  451.     mov    di,word ptr [bp+6]
  452.     mov    cx,word ptr [bp+4]
  453.    ;    
  454.    ;    {
  455.    ;        int ch, at;
  456.    ;    
  457.    ;            if (vseg == 45056)                              // monochrome mode
  458.    ;    
  459.     xor    ax,ax
  460.     or    ax,ax
  461.     jne    short @8@98
  462.     cmp    di,45056
  463.     jne    short @8@98
  464.    ;    
  465.    ;            return peek(vseg, adr);
  466.    ;    
  467.     mov    es,di
  468.     mov    bx,cx
  469.     mov    ax,word ptr es:[bx]
  470.     jmp    short @8@506
  471. @8@98:
  472.    ;    
  473.    ;        asm push ds;
  474.    ;    
  475.      push     ds
  476.    ;    
  477.    ;            _DX = 986;                      // video status port
  478.    ;    
  479.     mov    dx,986
  480.    ;    
  481.    ;            _DS = vseg;                     // video segment address
  482.    ;    
  483.     mov    ds,di
  484.    ;    
  485.    ;            _SI = adr;                      // video character offset
  486.    ;    
  487.     mov    si,cx
  488.    ;    
  489.    ;        asm cld;
  490.    ;    
  491.      cld    
  492. @8@170:
  493.    ;    
  494.    ;            //        wait for video retrace to start
  495.    ;        do
  496.    ;            asm in  al,dx;
  497.    ;    
  498.      in      al,dx
  499.    ;    
  500.    ;        while (_AL & 1);
  501.    ;    
  502.     mov    ah,0
  503.     test    ax,1
  504.     jne    short @8@170
  505. @8@218:
  506.    ;    
  507.    ;            //        wait for video retrace to stop
  508.    ;        do
  509.    ;            asm in  al,dx;
  510.    ;    
  511.      in      al,dx
  512.    ;    
  513.    ;        while (!(_AL & 1));
  514.    ;    
  515.     and    al,1
  516.     mov    ah,0
  517.     or    ax,ax
  518.     je    short @8@218
  519.    ;    
  520.    ;        asm lodsb;            /* get the character */
  521.    ;    
  522.      lodsb    
  523.    ;    
  524.    ;        _BL = _AL;
  525.    ;    
  526.     mov    bl,al
  527. @8@314:
  528.    ;    
  529.    ;            //        wait for video retrace to start
  530.    ;        do
  531.    ;            asm in  al,dx;
  532.    ;    
  533.      in      al,dx
  534.    ;    
  535.    ;        while (_AL & 1);
  536.    ;    
  537.     mov    ah,0
  538.     test    ax,1
  539.     jne    short @8@314
  540. @8@362:
  541.    ;    
  542.    ;            //        wait for video retrace to stop
  543.    ;        do
  544.    ;            asm in  al,dx;
  545.    ;    
  546.      in      al,dx
  547.    ;    
  548.    ;        while (!(_AL & 1));
  549.    ;    
  550.     and    al,1
  551.     mov    ah,0
  552.     or    ax,ax
  553.     je    short @8@362
  554.    ;    
  555.    ;            asm lodsb;                      // get the attribute
  556.    ;    
  557.      lodsb    
  558.    ;    
  559.    ;        _BH = _AL;
  560.    ;    
  561.     mov    bh,al
  562.    ;    
  563.    ;        _AX = _BX;
  564.    ;    
  565.     mov    ax,bx
  566.    ;    
  567.    ;        asm pop ds;
  568.    ;    
  569.      pop     ds
  570.    ;    
  571.    ;        return _AX;
  572.    ;    
  573.     jmp    short @8@506
  574. @8@506:
  575.    ;    
  576.    ;    }
  577.    ;    
  578.     pop    di
  579.     pop    si
  580.     pop    bp
  581.     ret    4
  582. @VPEEK$QUIUI    endp
  583. _TEXT    ends
  584. _BSS    segment word public 'BSS'
  585. rg    label    word
  586.     db    16 dup (?)
  587.     ?debug    C E9
  588. _BSS    ends
  589. _DATA    segment word public 'DATA'
  590. s@    label    byte
  591. _DATA    ends
  592. _TEXT    segment byte public 'CODE'
  593. _TEXT    ends
  594. _s@    equ    s@
  595. _rg    equ    rg
  596.     public    @CURSOR$QII
  597.     extrn    _int86:near
  598.     public    @CURR_CURSOR$QPIT1
  599.     public    @SET_CURSOR_TYPE$QI
  600.     public    _attrib
  601.     public    @CLEAR_SCREEN$QV
  602.     public    @VMODE$QV
  603.     public    @SCROLL_LOCK$QV
  604.     public    _helpfunc
  605.     public    _helpkey
  606.     public    _helping
  607.     public    @VPOKE$QUIUIUI
  608.     public    @VPEEK$QUIUI
  609.     end
  610.