Category : Files from Magazines
Archive   : JAN94.ZIP
Filename : PENT.ASC

 
Output of file : PENT.ASC contained in archive : JAN94.ZIP
_OPTIMIZING PENTIUM CODE_
by Mike Schmit

Example 1:

; with without branch prediction
; (cycles are for a case of non-space character)
loop1:
mov al, [si] ; 1 1
inc si ; 0 0 (0 due to pairing)
cmp al, ' ' ; 1 1
jne foo ; 0 3
call space ;
jmp bar ;
foo:
inc dx ; 1 1
bar:
dec cx ; 0 0
jnz loop1 ; 1 3
; total 4 10



Example 2:


(a)
first subsequent
mov ax, 1 1 1 (numbers are CPU cycle numbers)
inc bx 2 1
mov cx, 1 2 2
call xyz 3 2


(b)

read-after-write (do not pair)
mov al, 1
add bh, ah

mov ax, 1
add bx, ax


Example 3:

(a)

pop bx ; two POPs pair
pop ax ; but then RET
ret ; causes AGI delay

inc bx ; two INCs pair
inc ax
mov cx, [si] ; two MOVs pair
mov dx, [bx] ; AGI delay because BX changed in previous cycle


(b)

add [bx], 2
add [si], 2

write-after-write (do not pair)
mov eax, 1
add eax, ebx

mov ax, 1

mov ax, 2

write-after-read (pairs)
mov ax, bx
inc bx

read-after-read (pairs)
mov eax, ebx
add ecx, ebx


Example 4:


(a)

mov ax, [bx]
add ax, 2
mov [bx], ax
mov ax, [si]
add ax, 2
mov [si], ax


(b)

mov ax, [bx]
add ax, 2
mov [bx], ax
add [si], 2


(c)

mov ax, [bx]
add ax, 2
mov [bx], ax
mov cx, [si]
add cx, 2
mov [si], cx


(d)


mov ax, [bx]
mov cx, [si]
add ax, 2
add cx, 2
mov [bx], ax
mov [si], cx




Example 5:

loop1: lodsb
stosb
or al, al
jne loop1


Figures 2: ASCIIZ string copy with max string length


(a)

; 8088 286 386 486 Pent. w/pair bytes
loop1:
lodsb ; 16 5 5 5 2 2 1
stosb ; 15 3 4 5 3 3 1
or al, al ; 3 2 2 1 1 1 2
jne loop1 ; 16 8 8 3 1 1 2
-------------------------- ---
50 18 19 14 7 7 6


(b)
; 8088 286 386 486 Pent. w/pair bytes
loop2:
mov al, [si] ; 17 5 4 1 1 1 2
inc si ; 3 2 2 1 1 0 1
mov [di], al ; 18 4 2 1 1 1 2
inc di ; 3 2 2 1 1 0 1
cmp al, 0 ; 4 3 2 1 1 1 2
jne loop2 ; 16 9 8 3 1 0 2
-------------------------- ---
61 25 20 8 6 3 11



Figures 4: ASCIIZ string copy with max string length


(a)
; 8088 286 386 486 Pent. w/pair
loop3:
lodsb ; 16 5 5 5 2 2
stosb ; 15 3 4 5 3 3
or al, al ; 3 2 2 1 1 1
loopne loop3 ; 19 10 13 9 8 8
;-----------------------------
53 20 24 20 14 14

(b)
; 8088 286 386 486 Pent. w/pair
loop4:
mov al, [si] ; 17 12 4 1 1 1
inc si ; 3 2 2 1 1 0
mov [di], al ; 18 9 2 1 1 1
inc di ; 3 2 2 1 1 0
cmp al, 0 ; 4 3 2 1 1 1
je exit4 ; 4 3 3 1 1 0
dec cx ; 3 2 2 1 1 1
jnz loop4 ; 16 9 8 3 1 1
exit4:
;-----------------------------
68 42 25 10 8 5




  3 Responses to “Category : Files from Magazines
Archive   : JAN94.ZIP
Filename : PENT.ASC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/