home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turbo Toolbox
/
Turbo_Toolbox.iso
/
1991
/
04
/
review
/
sievetay.dec
< prev
next >
Wrap
Text File
|
1990-11-14
|
5KB
|
245 lines
TITLE C:\TM2\TEST\SIEVETAY.DEC - MODULE SieveTaylor
; Module created 11-15-1990/05:08 by TOBJ2ASM
EXTRN InOut_Read:FAR
EXTRN InOut_Write:FAR
EXTRN InOut_WriteCard:FAR
EXTRN InOut_WriteLn:FAR
EXTRN InOut_WriteString:FAR
EXTRN RTInit_S:BYTE
DGROUP GROUP DATA, CONST, BSS, HEAP, STACK
TGROUP GROUP TYPES
.286
.287
SieveTaylor_TEXT SEGMENT PARA 'CODE'
ASSUME CS:SieveTaylor_TEXT
SieveTest PROC NEAR
; (* $LineNumbers+ $Optimize:Speed $LoadTimeInit- $Large- *)
; MODULE SieveTaylor;
;
; FROM InOut IMPORT Read, Write, WriteString, WriteCard, WriteLn;
;
; CONST
; Size = 8190;
; ITER = 2000;
;
; VAR
; flag :ARRAY [0..Size] OF BOOLEAN;
; ch :CHAR;
; count :CARDINAL;
;
; PROCEDURE SieveTest;
; VAR i, j, k, prime :CARDINAL;
; BEGIN
PUSH AX
PUSH CX
PUSH DX
PUSH BX
PUSH SI
PUSH DI
PUSH ES
; FOR i := 1 TO ITER DO
MOV SI,1
; count := 0;
ASSUME DS:DGROUP
lbl1: MOV WORD PTR @Bss+8192,0
; FOR j := 0 TO Size DO
MOV AX,257
MOV DI,OFFSET DGROUP:@Bss
PUSH DS
POP ES
MOV CX,4095
CLD
REPNE STOSW
STOSB
; flag[j] := TRUE;
; END;
; FOR j := 0 TO Size DO
MOV DI,CX
MOV AX,3
; IF flag[j] THEN
lbl2: TEST BYTE PTR @Bss[DI],1
JZ lbl5
; prime := j+j+3;
MOV DX,AX
; k := j+prime;
MOV BX,DI
ADD BX,DX
; WHILE k <= Size DO
lbl3: CMP BX,8190
JA lbl4
; flag[k] := FALSE;
MOV BYTE PTR @Bss[BX],0
; INC(k,prime);
ADD BX,DX
; END;
CMP BX,8190
JA lbl4
MOV BYTE PTR @Bss[BX],0
ADD BX,DX
CMP BX,8190
JA lbl4
MOV BYTE PTR @Bss[BX],0
ADD BX,DX
CMP BX,8190
JA lbl4
MOV BYTE PTR @Bss[BX],0
ADD BX,DX
CMP BX,8190
JA lbl4
MOV BYTE PTR @Bss[BX],0
ADD BX,DX
CMP BX,8190
JA lbl4
MOV BYTE PTR @Bss[BX],0
ADD BX,DX
CMP BX,8190
JA lbl4
MOV BYTE PTR @Bss[BX],0
ADD BX,DX
JMP lbl3
; INC(count);
lbl4: INC WORD PTR @Bss+8192
; END;
; END;
lbl5: ADD AX,2
INC DI
CMP DI,8190
JBE lbl2
; END;
INC SI
CMP SI,2000
JA lbl6
JMP lbl1
; END SieveTest;
lbl6: POP ES
POP DI
POP SI
POP BX
POP DX
POP CX
POP AX
RET
SieveTest ENDP ; Size: 174 Byte
PUBLIC _main
_main PROC FAR
;
; BEGIN
PUSH BP
MOV BP,SP
SUB SP,2
; WriteString("Hit a key to start 2000 ITERATIONS");
MOV AX,33
PUSH AX
PUSH SS
MOV AX,OFFSET DGROUP:Const0
PUSH AX
CALL InOut_WriteString
; Read(ch); WriteLn;
LEA AX,[BP-1]
PUSH AX
CALL InOut_Read
CALL InOut_WriteLn
; SieveTest;
CALL SieveTest
; Write(7C); WriteCard(count,5);
MOV AX,7
PUSH AX
CALL InOut_Write
PUSH WORD PTR @Bss+8192
MOV AL,5
PUSH AX
CALL InOut_WriteCard
; END SieveTaylor.
MOV SP,BP
POP BP
RET
_main ENDP ; Size: 62 Byte
SieveTaylor_TEXT ENDS ; Size: 236 Byte
TYPES SEGMENT WORD PUBLIC 'TYPES'
TYPES ENDS
DATA SEGMENT WORD PUBLIC 'DATA'
DATA ENDS
CONST SEGMENT WORD PUBLIC 'CONST'
Const0 DB 'Hit a key to start 2000 ITERATIONS'
CONST ENDS ; Size: 34 Byte
BSS SEGMENT WORD PUBLIC 'BSS'
@Bss DB 8194 DUP (?)
BSS ENDS ; Size: 8194 Byte
HEAP SEGMENT WORD PUBLIC 'HEAP'
HEAP ENDS
STACK SEGMENT PARA STACK 'STACK'
STACK ENDS
END