home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_07_08 / v7n8128a.txt < prev    next >
Text File  |  1989-10-02  |  3KB  |  120 lines

  1.  
  2. -------------------------------------------------------------
  3. Listing 2
  4. -------------------------------------------------------------
  5.         IDEAL
  6.         %pagesize 56,120
  7.         MODEL    LARGE
  8.         P386
  9. STRUC        descSTRUCTURE     ;global descriptor table entry structure
  10. seglim        dw    ?    ;max size of the segment
  11. loaddr        dw    ?       ;24-bits of address little-endian
  12. hiaddr        db    ?
  13. axright        db    ?    ;access rights must be 93h
  14. res0        dw    ?    ;reserved - must be zero
  15.         ENDS
  16.  
  17.         stack
  18.         DB    512 DUP (?)
  19.  
  20.         dataseg
  21. label        GDT  descstructure    ;User supplied partially filled-in GDT
  22.  descstructure    <0,0,0,0,0>        ;dummy - must be zeros
  23.  descstructure    <0,0,0,0,0>        ;descriptor of this GDT - must be zero
  24. label        movesource    descstructure
  25.  descstructure    <0ffffh,0,0,0,0>    ;descriptor of source block
  26. label        movedest     descstructure
  27.  descstructure    <0ffffh,0,0,0,0>    ;descriptor of destination block
  28.  descstructure    <0,0,0,0,0>        ;BIOS will modify to Protected code seg
  29.  DESCSTRUCTURE    <0,0,0,0,0>        ;BIOS will modify to Protected stk seg
  30.  
  31. POSTER        DB    0
  32. COUNTER        DW    0
  33.  
  34. FILL        DB    2400 DUP (0AAH)    ;source
  35. FELL        DB    2400 DUP (055H)    ;destination
  36.  
  37. MACRO        MAKE_24_BIT_ADDR SEGVAL, OFSET, MEG
  38.         MOV    AX,MEG
  39.         MOV    CX,SEGVAL
  40.         REPT    4
  41.           SHL    CX,1
  42.           RCL    AL,1
  43.         ENDM
  44.         ADD    CX,offset OFSET
  45.         ADC    AL,0        ;fixup if carry out of 16 bits
  46.         ENDM
  47.  
  48. MACRO        PR2HEX    SOURCE         ;print two hex digits
  49.         MOV    DL,SOURCE
  50.         SHR    DL,4
  51.         call    toascii
  52.         MOV    AH,2
  53.         INT    21H
  54.         MOV    DL,SOURCE
  55.         AND    DL,0FH
  56.         call    toascii
  57.         mov    ah,2
  58.         INT    21H
  59.         ENDM
  60.  
  61.         codeseg
  62. proc        start    near
  63.         cld                ;string direction
  64.         mov    ax,dgroup        ;init data seg
  65.         MOV    DS,AX
  66.         MOV    [COUNTER],0
  67.         AND    [POSTER],7FH        ;turn off posting bit
  68.  
  69. ;synchronize to next 976 microsecond beat - goes away and waits
  70.         MOV    CX,0
  71.         MOV    DX,1
  72.         MOV    AH,86H            ;
  73.         INT    15H
  74. ; set up to indicate expiration of 2 hex milliseconds
  75.         MOV    CX,0
  76.         MOV    DX,1951            ; 2 hex millisec = 1/512 sec
  77.         MOV    AH,83H
  78.         MOV    AL,0
  79.         MOV    BX,DS
  80.         MOV    ES,BX
  81.         MOV    BX,OFFSET POSTER
  82.         INT    15H
  83. RECYCLE:
  84.         make_24_bit_addr ds, fill, 0    ;test pattern
  85.         MOV    [MOVESOURCE.LOADDR],CX    ;addr goes into GDT entry for
  86.         MOV    [MOVESOURCE.HIADDR],AL    ;     source
  87.  
  88.         make_24_bit_addr ds, fell, 0    ;address target area
  89.         MOV    [MOVEdest.LOADDR],CX
  90.         MOV    [MOVEdest.HIADDR],AL
  91.         MOV    [MOVEsource.axright],93h;tell 80x86 protection it's ok
  92.         MOV    AX,DS                   ;point ES:SI to our GDT
  93.         MOV    ES,AX
  94.         MOV    SI,OFFSET GDT
  95.         MOV    AH,87H            ;request function 87h
  96.         MOV    CX,1200            ;how many WORDS to move
  97.         INT    15H
  98.  
  99.         INC    [COUNTER]        ;take credit for cycle
  100.         TEST    [POSTER],80H            ;time window expired?
  101.         JZ    RECYCLE            ;no
  102.  
  103.         MOV    BX,[COUNTER]        ;display cycle count
  104.         PR2HEX    BH
  105.         PR2HEX    BL
  106.  
  107.         MOV    AX,4CH         ;terminate program
  108.         INT    21H
  109.         endp
  110. PROC        TOASCII    NEAR
  111.         OR    DL,30H        ;convert 00-0f to 30-3f
  112.         CMP    DL,39H          ;see if 3a-3f
  113.         JBE    @@NAX           ;no, is a decimal digit
  114.         ADD    DL,7        ;convert 3a-3f to 'A'-'F'
  115. @@NAX:
  116.         RET
  117.         ENDP
  118.         end    start
  119.  
  120.