home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / compiler / ubasic / ubmpqs32 / mpqshd2.asm < prev    next >
Assembly Source File  |  1990-08-05  |  11KB  |  786 lines

  1. ;MPQSHD2.ASM 3.2
  2. ;    MACHINE LANGUAGE SUBROUTINE
  3. ;    FOR MULTIPLE POLYNOMIAL QUADRATIC SIEVE
  4. ;    Hard Disk version
  5. ;    1989/90 by YUJI KIDA
  6. ;
  7. .386P
  8.  
  9. code    segment    use16
  10.     assume cs:code,ds:code
  11.  
  12.  
  13.     INCLUDE    UBP.MAC
  14.     include    mpqshd.h
  15.  
  16.     org    100h
  17. start:
  18.     JMP    START0
  19.  
  20.     org    104h
  21. sieveout:
  22.     mov    eax,cr0        ;reset PE bit
  23.     and    eax,07ffffffeh
  24.     mov    cr0,eax
  25.  
  26.     db    0eah        ;jmp far ptr flushrl
  27.     dw    offset flushrl
  28. csegmem    dw    ?
  29.  
  30.     ; âèâAâïüEâéü[âhé╔ò£ïA
  31. flushrl:
  32.     sti
  33.     mov    ax,ss
  34.     mov    ds,ax
  35.     mov    es,ax
  36.     retf
  37.  
  38.  
  39.     align    4
  40. primeadrnow    dd    ?
  41. lastprime    dd    ?
  42.  
  43. lpvindexadr    dd    ?
  44. lpvdataadr    dd    ?
  45.  
  46. pmodecsseg    dw    ?
  47.  
  48. primes        dw    ?
  49.  
  50. P_OFF    DW    ?
  51. P_SEG    DW    ?
  52. Y_OFF    DW    ?
  53. Y_SEG    DW    ?
  54.  
  55. L_OFF    DW    ?
  56. L_SEG    DW    ?
  57.  
  58. X_OFF    DW    ?
  59. X_SEG    DW    ?
  60.  
  61. A2_OFF    DW    ?
  62. A2_SEG    DW    ?
  63. B_OFF    DW    ?
  64. B_SEG    DW    ?
  65. M_OFF    DW    ?
  66. M_SEG    DW    ?
  67. W_OFF    DW    ?
  68. W_SEG    DW    ?
  69.  
  70. Ew_OFF    DW    ?
  71. Ew_SEG    DW    ?
  72.  
  73. X1_OFF    DW    ?
  74. X1_SEG    DW    ?
  75.  
  76. IniLog    DW    ?
  77. CutLog    DW    ?
  78.  
  79. lpvnow        dw    0
  80. lpvcount    dw    0
  81.  
  82.  
  83. ;üÖüÖ COMMAND é╠ÉUéΦò¬é»
  84.  
  85.  
  86. START0:
  87.     MOV_AX    AR0        ;ARRAY[0] é┼âRâ}âôâhôné╡
  88.     MOV    BX,offset CMD_TBL
  89.     SHL    AX,1
  90.     ADD    BX,AX
  91.     JMP    CS:[BX]
  92.  
  93. CMD_TBL:
  94.     DW    INITMPQS,SETR1R2,SIEVE,SIEVE_ANS,SETDATA
  95.     DW    DECOMPOSE,lpvinit,setlpvdata,qsort,isort
  96.     dw    getpair,initmpqs2
  97.  
  98.  
  99. ;
  100. ; get matching pair
  101. ; command#=10
  102.  
  103. getpair:
  104.     xor    ebx,ebx
  105.     mov    bx,cs:[lpvnow]
  106.     cmp    bx,cs:[lpvcount]
  107.     jae    short nomorepair
  108.     shl    ebx,1
  109.     add    ebx,cs:[lpvindexadr]
  110.     xor    eax,eax
  111.     mov    ax,fs:[ebx]
  112.     add    ebx,2
  113.     mov    edx,t_byte
  114.     mul    edx
  115.     add    eax,cs:[lpvdataadr]
  116.     mov    esi,eax
  117. getpair10:
  118.     xor    eax,eax
  119.     mov    ax,fs:[ebx]
  120.     mov    edx,t_byte
  121.     mul    edx
  122.     add    eax,cs:[lpvdataadr]
  123.     mov    edi,eax
  124.     mov    eax,fs:[esi]    ;prev w#
  125.     cmp    eax,fs:[edi]    ;current w#
  126.     je    short getpairmatch
  127.     mov    esi,edi    
  128.     add    ebx,2
  129.     mov    ax,cs:[lpvnow]
  130.     inc    ax
  131.     mov    cs:[lpvnow],ax
  132.     cmp    ax,cs:[lpvcount]
  133.     jb    short getpair10
  134.  
  135. nomorepair:
  136.     les    di,dword ptr cs:[ew_off]
  137.     mov    word ptr es:[di],0
  138.  
  139. getpairret:
  140.     mov    ax,ss
  141.     mov    ds,ax
  142.     mov    es,ax
  143.     retf
  144.  
  145. getpairmatch:
  146.     inc    cs:[lpvnow]
  147.  
  148.     ;set ew
  149.  
  150. ;    push    esi
  151.     push    edi
  152.  
  153.     les    di,dword ptr cs:[ew_off]
  154.     mov    cx,1
  155.     mov    ax,fs:[esi]
  156.     add    esi,2
  157.     mov    es:[di+2],ax
  158.     mov    ax,fs:[esi]
  159.     add    esi,2
  160.     mov    es:[di+4],ax
  161.     or    ax,ax
  162.     jz    short getpair50
  163.     inc    cx
  164. getpair50:
  165.     mov    es:[di],cx
  166.  
  167.     ;set X
  168.  
  169.     les    di,dword ptr cs:[x_off]
  170.     mov    cx,xword
  171. getpair70:
  172.     mov    ax,fs:[esi]
  173.     add    esi,2
  174.     stosw
  175.     loop    getpair70
  176.  
  177.     pop    esi
  178. ;    push    esi
  179.     add    esi,wbyte
  180.  
  181.     ;set X1
  182.  
  183.     les    di,dword ptr cs:[x1_off]
  184.     mov    cx,xword
  185. getpair90:
  186.     mov    ax,fs:[esi]
  187.     add    esi,2
  188.     stosw
  189.     loop    getpair90
  190.  
  191.     jmp    getpairret
  192.  
  193.  
  194. ;
  195. ; quick sort
  196. ; command#=8
  197.  
  198. qsort:
  199.     mov    cs:[lpvnow],0
  200.     mov    cx,cs:[lpvcount]
  201.     dec    cx
  202.     mov    cs:[lpvcount],cx
  203.  
  204.     cli
  205.  
  206.     mov    eax,cr0        ;set PE bit
  207.     or    eax,1
  208.     mov    cr0,eax
  209.  
  210.     db    0eah        ;goto protect mode
  211.     dw    900h
  212.     dw    offset gdt_code32-gdttbl    ;selector
  213.  
  214. ;
  215. ; insertion sort
  216. ; command#=9
  217.  
  218. isort:
  219.     mov    cx,cs:[lpvcount]
  220.     dec    cx
  221.  
  222.     cli
  223.  
  224.     mov    eax,cr0        ;set PE bit
  225.     or    eax,1
  226.     mov    cr0,eax
  227.  
  228.     db    0eah        ;goto protect mode
  229.     dw    0a00h
  230.     dw    offset gdt_code32-gdttbl    ;selector
  231.  
  232. ;
  233. ; set lpv data
  234. ; command#=7
  235.  
  236. setlpvdata:
  237.     xor    eax,eax
  238.     mov    ax,cs:[lpvcount]
  239.     mov    ebx,eax
  240.     shl    ebx,1
  241.     add    ebx,cs:[lpvindexadr]
  242.     mov    fs:[ebx],ax
  243.  
  244.     mov    edx,t_byte
  245.     mul    edx
  246.     add    eax,cs:[lpvdataadr]
  247.     mov    edi,eax
  248.  
  249.     ;set W#
  250.  
  251.     lds    si,dword ptr cs:[w_off]
  252.     xor    eax,eax
  253.     lodsw
  254.     and    ax,01ffh
  255.     mov    cx,ax
  256.     lodsd
  257.     cmp    cx,1
  258.     jne    short setlpvdata10
  259.     and    eax,0000ffffh
  260. setlpvdata10:
  261.     mov    fs:[edi],eax
  262.     add    edi,wbyte
  263.  
  264.     ;set X
  265.  
  266.     lds    si,dword ptr cs:[x_off]
  267.     mov    cx,xword
  268. setlpvdata30:
  269.     lodsw
  270.     mov    fs:[edi],ax
  271.     add    edi,2
  272.     loop    setlpvdata30
  273.  
  274.     inc    cs:[lpvcount]
  275.  
  276.     mov    ax,ss
  277.     mov    ds,ax
  278.     mov    es,ax
  279.     retf
  280.  
  281.  
  282. ;
  283. ; lpv initialize
  284. ; command#=6
  285.  
  286. lpvinit:
  287.     ; check extended memories
  288.  
  289.     xor    eax,eax
  290.     mov    ax,cs:[primes]
  291.     xor    edx,edx
  292.     mov    dx,primeunitbytes
  293.     mul    edx
  294.     add    eax,primeadr
  295.     mov    cs:[lpvindexadr],eax
  296.     mov    fs:[_lpvindexadr],eax
  297.  
  298.     mov    esi,pmodeworkadr-4
  299.     mov    eax,19510701h
  300.     mov    edx,00100000h        ;1Mbytes
  301. lpvinit100:
  302.     add    esi,edx
  303.     mov    fs:[esi],eax
  304.     cmp    fs:[esi],eax
  305.     je    lpvinit100
  306.     mov    eax,esi
  307.     add    eax,4
  308.     sub    eax,edx
  309.     sub    eax,cs:[lpvindexadr]
  310.  
  311.     xor    edx,edx
  312.     mov    ecx,t_byte+2
  313.     div    ecx
  314.  
  315.     mov    ebx,_lpvmaxnumber
  316.     mov    fs:[ebx],eax
  317.  
  318.     shl    eax,1
  319.     add    eax,cs:[lpvindexadr]
  320.  
  321.     mov    cs:[lpvdataadr],eax
  322.     mov    fs:[_lpvdataadr],eax
  323.  
  324.     ;
  325.  
  326.     MOV    BX,V1        ;set Ew ADDRESS
  327.     MOV    AX,CS:[BX]
  328.     MOV    CS:[Ew_OFF],AX
  329.     MOV    AX,CS:[BX+2]
  330.     MOV    CS:[Ew_SEG],AX
  331.  
  332.     MOV    BX,V2        ;set X ADDRESS
  333.     MOV    AX,CS:[BX]
  334.     MOV    CS:[X_OFF],AX
  335.     MOV    AX,CS:[BX+2]
  336.     MOV    CS:[X_SEG],AX
  337.  
  338.     MOV    BX,V3        ;set X1 ADDRESS
  339.     MOV    AX,CS:[BX]
  340.     MOV    CS:[X1_OFF],AX
  341.     MOV    AX,CS:[BX+2]
  342.     MOV    CS:[X1_SEG],AX
  343.  
  344.     mov    ebx,cs:[lpvindexadr]
  345.     mov    word ptr fs:[ebx],0
  346.     mov    ebx,cs:[lpvdataadr]
  347.     mov    dword ptr fs:[ebx],0
  348.     mov    cs:[lpvcount],1
  349.  
  350.     mov    ax,ss
  351.     mov    ds,ax
  352.     mov    es,ax
  353.     retf
  354.  
  355. ;
  356. ;üÖ W é¬ PR() é┼èäéΩéΘé⌐âeâXâg
  357. ;
  358. ;COMMAND#=5
  359.  
  360. decompose:
  361.     mov    ax,_memoseg
  362.     mov    es,ax
  363.  
  364.     mov    ax,cs:[w_off]
  365.     mov    es:[_absQR],ax
  366.     mov    ax,cs:[w_seg]
  367.     mov    es:[_absQR+2],ax
  368.  
  369.     cli
  370.  
  371.     mov    eax,cr0        ;set PE bit
  372.     or    eax,1
  373.     mov    cr0,eax
  374.  
  375.     db    0eah        ;goto protect mode
  376.     dw    700h
  377.     dw    offset gdt_code32-gdttbl    ;selector
  378.  
  379.  
  380. ;
  381. ; âÅü[âNüEâGâèâAé╠Åëè·ë╗
  382. ;COMMAND#=0
  383.  
  384. ;    V1=work(0,0)
  385. ;    V2=P
  386. ;    V3=Y
  387. ;    V4=L
  388. ;    V5=X
  389. ;    V6=A2
  390. ;    V7=B
  391. ;    V8=OF
  392. ;    V9=W#
  393. ;    V10=MP2%(0)
  394.  
  395. ;    AR[1]    NUMBER OF PRIMES \ 2
  396. ;    AR[2]    INITIAL LOG
  397. ;    AR[3]    LIMIT LOG
  398. ;
  399. ;    âüâéâèòsæ½é╠ÅΩìçé═ AR[1]=0 é╔é╖éΘ
  400.  
  401. MEMORY_LACK:
  402.     MOV    BX,AR1
  403.     MOV    WORD PTR CS:[BX],0
  404.     JMP    initout
  405.  
  406. INITMPQS:
  407.     MOV    BX,V1        ;check work(0,0) segment
  408.     MOV    AX,CS:[BX]
  409.     shr    ax,4
  410.     add    ax,CS:[BX+2]
  411.     cmp    ax,_memoseg
  412.     ja    short memory_lack
  413.  
  414.     MOV    BX,V2        ;set P ADDRESS
  415.     MOV    AX,CS:[BX]
  416.     MOV    CS:[P_OFF],AX
  417.     MOV    AX,CS:[BX+2]
  418.     MOV    CS:[P_SEG],AX
  419.  
  420.     MOV    BX,V3        ;set Y ADDRESS
  421.     MOV    AX,CS:[BX]
  422.     MOV    CS:[Y_OFF],AX
  423.     MOV    AX,CS:[BX+2]
  424.     MOV    CS:[Y_SEG],AX
  425.  
  426.     MOV    BX,V4        ;set L ADDRESS
  427.     MOV    AX,CS:[BX]
  428.     MOV    CS:[L_OFF],AX
  429.     MOV    AX,CS:[BX+2]
  430.     MOV    CS:[L_SEG],AX
  431.  
  432.     MOV    BX,V5        ;set X ADDRESS
  433.     MOV    AX,CS:[BX]
  434.     MOV    CS:[X_OFF],AX
  435.     MOV    AX,CS:[BX+2]
  436.     MOV    CS:[X_SEG],AX
  437.  
  438.     MOV    BX,V6        ;set A2 ADDRESS
  439.     MOV    AX,CS:[BX]
  440.     MOV    CS:[A2_OFF],AX
  441.     MOV    AX,CS:[BX+2]
  442.     MOV    CS:[A2_SEG],AX
  443.  
  444.     MOV    BX,V7        ;set B ADDRESS
  445.     MOV    AX,CS:[BX]
  446.     MOV    CS:[B_OFF],AX
  447.     MOV    AX,CS:[BX+2]
  448.     MOV    CS:[B_SEG],AX
  449.  
  450.     MOV    BX,V8        ;set Off ADDRESS
  451.     MOV    AX,CS:[BX]
  452.     MOV    CS:[M_OFF],AX
  453.     MOV    AX,CS:[BX+2]
  454.     MOV    CS:[M_SEG],AX
  455.  
  456.     MOV    BX,V9        ;set W# ADDRESS
  457.     MOV    AX,CS:[BX]
  458.     MOV    CS:[W_OFF],AX
  459.     MOV    AX,CS:[BX+2]
  460.     MOV    CS:[W_SEG],AX
  461.  
  462.     MOV    BX,V10        ;set PMODE segment
  463.     MOV    AX,CS:[BX]
  464.     shr    ax,4
  465.     add    ax,CS:[BX+2]
  466.     sub    ax,ARRAYHEADSEG
  467.     mov    cs:[pmodecsseg],ax
  468.  
  469.     MOV_AX    AR1
  470.     shl    ax,1
  471.     mov    cs:[primes],ax
  472.  
  473.     MOV_AX    AR2
  474.     MOV    CS:[IniLog],AX
  475.  
  476.     MOV_AX    AR3
  477.     MOV    CS:[CutLog],AX
  478.  
  479. init100:
  480.     mov    ax,cs
  481.     mov    ds,ax
  482.     mov    [csegmem],ax
  483.  
  484.     mov    eax,primeadr+primeunitbytes
  485.     mov    [primeadrnow],eax
  486.     mov    [lastprime],0
  487.  
  488. descriptor    struc
  489.     limit_0_15    dw    0
  490.     base_0_15    dw    0
  491.     base_16_23    db    0
  492.     access        db    0
  493.     gran        db    0
  494.     base_24_31    db    0
  495. descriptor    ends
  496.  
  497. code_seg_access    equ    09ah
  498. data_seg_access    equ    092h
  499.  
  500.     ; éfécésé╠ì∞É╗
  501.     ; 32bit code segment in protect mode
  502.  
  503.     mov    ax,[pmodecsseg]
  504.     and    eax,0ffffh
  505.     shl    eax,4
  506.     mov    ebx,eax
  507.     shr    eax,16
  508.     mov    gdt_code32.base_0_15,bx
  509.     mov    gdt_code32.base_16_23,al
  510.  
  511.     ; éfécésé╠ì∞É╗
  512.     ; 16 bit code segment in real mode for return
  513.  
  514.     mov    ax,cs
  515.     and    eax,0ffffh
  516.     shl    eax,4
  517.     mov    ebx,eax
  518.     shr    eax,16
  519.     mov    gdt_code16.base_0_15,bx
  520.     mov    gdt_code16.base_16_23,al
  521.  
  522.     ; éfécésé╠ì∞É╗
  523.     ; 32 bit data segment : start from 00000
  524.  
  525.     ; store "number of primes" and "inilog" and "cutlog" and "M"
  526.  
  527.     mov    ax,_memoseg
  528.     mov    es,ax
  529.  
  530.     xor    di,di
  531.     mov    cx,80h
  532.     xor    ax,ax
  533.     rep    stosw
  534.  
  535.     xor    eax,eax
  536.     mov    ax,cs:[primes]
  537.     mov    es:[_primesR],ax
  538.     cmp    ax,7000h
  539.     jae    short initmpqs200
  540.     mov    ax,7000h
  541. initmpqs200:
  542.     and    ax,0f000h    ;let be a multiple of 1000h
  543.     xor    ecx,ecx
  544.     mov    cx,primeunitbytes
  545.     mul    ecx
  546.     add    eax,pmodeworkadr
  547.  
  548.     mov    es:[_sievetopR],eax
  549.  
  550.     mov    ax,cs:[inilog]
  551.     mov    ah,al
  552.     mov    es:[_inilogR],ax
  553.     mov    es:[_inilogR+2],ax
  554.  
  555.     mov    ax,cs:[cutlog]
  556.     mov    es:[_cutlogR],ax
  557.  
  558.     lds    si,dword ptr cs:[M_off]
  559.     mov    di,_sievewidthR
  560.     lodsw
  561.     and    ax,7fffh    ;make positive
  562.     movsw
  563.     cmp    ax,1
  564.     je    short init150
  565.     movsw
  566. init150:
  567.     ; éfécéséqé╔éfécésö╘Æné≡âZâbâg
  568.  
  569.     mov    ax,cs
  570.     mov    ds,ax
  571.     mov    si,offset gdttbl
  572.     mov    ax,_gdttblseg
  573.     mov    es,ax
  574.     mov    di,0
  575.     mov    cx,10h
  576.     rep    movsw
  577.     
  578.     mov    eax,_gdttbladr
  579.     mov    dword ptr gdtaddr+2,eax
  580.     lgdt    gdtaddr
  581. initout:
  582.     cli
  583.  
  584.     mov    eax,cr0        ;set PE bit
  585.     or    eax,1
  586.     mov    cr0,eax
  587.  
  588.     db    0eah        ;goto protect mode
  589.     dw    0b00h
  590.     dw    offset gdt_code32-gdttbl    ;selector
  591.  
  592. ;
  593. ; set data for each prime
  594. ;command#=4
  595. setdata:
  596.     mov    edi,cs:[primeadrnow]
  597.  
  598.     lds    si,dword ptr cs:[p_off]
  599.     lodsw
  600.     cmp    ax,1
  601.     ja    short setdata20
  602.     xor    eax,eax
  603.     lodsw
  604.     jmp    short setdata30
  605. setdata20:    
  606.     lodsd
  607. setdata30:
  608.     cmp    eax,fs:[_sieveBsize]
  609.     jb    short setdata32
  610.     inc    word ptr fs:[_primes2]
  611.     jmp    short setdata33
  612. setdata32:
  613.     cmp    eax,fs:[_sieveXsize]
  614.     jb    short setdata33
  615.     inc    word ptr fs:[_primes1]
  616. setdata33:
  617.     mov    edx,eax
  618.     sub    eax,cs:[lastprime]
  619.     mov    fs:[edi],ax
  620.     mov    cs:[lastprime],edx
  621.  
  622.     lds    si,dword ptr cs:[y_off]
  623.     xor    eax,eax
  624.     lodsw
  625.     cmp    ax,1
  626.     ja    short setdata40
  627.     jb    short setdata50
  628. setdata45:
  629.     lodsw
  630.     jmp    short setdata50
  631. setdata40:    
  632.     lodsd
  633. setdata50:
  634.     mov    fs:[edi+4],eax
  635.  
  636.     lds    si,dword ptr cs:[l_off]
  637.     mov    ax,[si+2]
  638.     mov    fs:[edi+2],ax
  639.  
  640.     add    edi,primeunitbytes
  641.     mov    cs:[primeadrnow],edi
  642.  
  643.     mov    ax,ss
  644.     mov    ds,ax
  645.     retf
  646.  
  647. ;
  648. ; * sieving main
  649. ;   386 protect mode
  650. ; command#=2
  651.  
  652. SIEVE:
  653.     cli
  654.  
  655.     mov    eax,cr0        ;set PE bit
  656.     or    eax,1
  657.     mov    cr0,eax
  658.  
  659.     db    0eah        ;goto protect mode
  660.     dw    280h
  661.     dw    offset gdt_code32-gdttbl    ;selector
  662.  
  663. ;
  664. ; get a sieved result
  665. ;
  666. ; command#=3
  667. ;                    !! not used now !!
  668. SIEVE_ANS:
  669.     retf
  670.  
  671. ;
  672. ; set sieve start adr R1,R2 for each prime
  673. ;
  674. ; command#=1
  675.  
  676. SETR1R2:
  677.     ;set parameter
  678.  
  679.     mov    ax,_memoseg
  680.     mov    es,ax
  681.  
  682.     ;store A2 by 32bit form
  683.  
  684.     lds    si,dword ptr cs:[A2_OFF]
  685.     mov    di,_A2R
  686.     lodsw
  687.     and    ax,7fffh
  688.     mov    cx,ax
  689.     inc    ax
  690.     shr    ax,1
  691.     stosw
  692.     xor    ax,ax
  693.     stosw
  694.     rep    movsw
  695.     stosw
  696.  
  697.     ;store B by 32bit form
  698.  
  699.     lds    si,dword ptr cs:[B_OFF]
  700.     mov    di,_BR
  701.     lodsw
  702.     and    ax,7fffh
  703.     mov    cx,ax
  704.     inc    ax
  705.     shr    ax,1
  706.     stosw
  707.     xor    ax,ax
  708.     stosw
  709.     rep    movsw
  710.     stosw
  711.  
  712.     cli
  713.  
  714.     mov    eax,cr0        ;set PE bit
  715.     or    eax,1
  716.     mov    cr0,eax
  717.  
  718.     db    0eah        ;goto protect mode
  719.     dw    100h
  720.     dw    offset gdt_code32-gdttbl
  721.  
  722.  
  723. gdtaddr    label    qword
  724.     dw    4*8        ;size of GDT table
  725.     dd    ?
  726.     dw    0
  727.  
  728.  
  729.     ; éfécésâeü[âuâï
  730.  
  731. gdttbl    label    dword
  732. gdt_null    descriptor <,,,,,>
  733. gdt_code32    descriptor <0ffffh,,,code_seg_access,0cfh,0>
  734. gdt_data32    descriptor <0ffffh,0,0,data_seg_access,0cfh,0>
  735. gdt_code16    descriptor <0ffffh,,,code_seg_access,80h,0>
  736.  
  737.  
  738.     ;
  739.     ; * Initialize again
  740.     ; command#=11
  741.  
  742. initmpqs2:
  743.  
  744.     ; check memory size
  745.  
  746.     mov    eax,19510721h
  747.     mov    ebx,0ffffch
  748. initmpqs210:
  749.     add    ebx,100000h
  750.     mov    fs:[ebx],eax
  751.     cmp    fs:[ebx],eax
  752.     je    initmpqs210
  753.     sub    ebx,0ffffch
  754.     sub    ebx,fs:[_sievetop]
  755.     mov    eax,fs:[_sievewidth]
  756.     shl    eax,2
  757. initmpqs220:
  758.     shr    eax,1
  759.     cmp    eax,ebx
  760.     ja    initmpqs220
  761.  
  762.     mov    fs:[_sieveBsize],eax
  763.     add    eax,fs:[_sievetop]
  764.     mov    fs:[_sieveover],eax
  765.  
  766.     mov    eax,fs:[_sieveBsize]
  767.     sub    eax,fs:[_sievetop]
  768.     mov    fs:[_sieveConst],eax
  769.  
  770.     mov    eax,fs:[_sieveBsize]
  771.     shr    eax,sieveRepLog
  772.     mov    fs:[_sieveXsize],eax
  773.  
  774.     xor    edx,edx
  775.     mov    eax,fs:[_sievewidth]
  776.     shl    eax,1
  777.     div    fs:[_sieveBsize]
  778.     mov    bx,AR0
  779.     mov    cs:[bx],ax        ;loop time
  780.  
  781.     retf
  782.  
  783.  
  784. code    ends
  785. end    start
  786.