Use backtick code blocks for syntax highlighting

This commit is contained in:
James Gregory 2013-12-31 11:38:48 +11:00
commit f658bfbb40
203 changed files with 26546 additions and 25801 deletions

View file

@ -12,44 +12,46 @@ pages: 1091-1093
**LISTING 58.4 L58-4.ASM**
; Inner loop to draw a single texture-mapped vertical column,
; rather than a horizontal scanline. Maxed-out 32-bit version.
;
; At this point:
; EAX = sum of integral X & Y source pointer advances
; ECX = source pointer increment to advance one in Y
; EDX = fractional source texture Y coordinate in lower
; 15 bits of DX, fractional source texture X coord
; in high word of EDX, bit 15 set to 0
; ESI = initial source texture pointer
; EDI = initial destination pointer
; EBP = fractional Y advance in lower 15 bits of BP,
; fractional X advance in high word of EBP, bit
; 15 set to 0
```nasm
; Inner loop to draw a single texture-mapped vertical column,
; rather than a horizontal scanline. Maxed-out 32-bit version.
;
; At this point:
; EAX = sum of integral X & Y source pointer advances
; ECX = source pointer increment to advance one in Y
; EDX = fractional source texture Y coordinate in lower
; 15 bits of DX, fractional source texture X coord
; in high word of EDX, bit 15 set to 0
; ESI = initial source texture pointer
; EDI = initial destination pointer
; EBP = fractional Y advance in lower 15 bits of BP,
; fractional X advance in high word of EBP, bit
; 15 set to 0
SCANOFFSET=0
SCANOFFSET=0
REPT LOOP_UNROLL
REPT LOOP_UNROLL
mov bl,[esi] ;get image pixel
add edx,ebp ;advance frac Y in DX,
; frac X in high word of EDX
adc esi,eax ;advance source pointer by integral
; X & Y amount, also accounting for
; carry from X fractional addition
mov [edi+SCANOFFSET],bl ;set screen pixel
; (located here to avoid 486
; AGI from previous byte op)
test dh,80h ;carry from Y fractional addition?
jz short @F ;no
add esi,ecx ;yes, advance Y by one
; (produces Pentium AGI for MOV BL,[ESI])
and dh,not 80h ;reset the Y fractional carry bit
@@:
mov bl,[esi] ;get image pixel
add edx,ebp ;advance frac Y in DX,
; frac X in high word of EDX
adc esi,eax ;advance source pointer by integral
; X & Y amount, also accounting for
; carry from X fractional addition
mov [edi+SCANOFFSET],bl ;set screen pixel
; (located here to avoid 486
; AGI from previous byte op)
test dh,80h ;carry from Y fractional addition?
jz short @F ;no
add esi,ecx ;yes, advance Y by one
; (produces Pentium AGI for MOV BL,[ESI])
and dh,not 80h ;reset the Y fractional carry bit
@@:
SCANOFFSET = SCANOFFSET + SCANWIDTH
SCANOFFSET = SCANOFFSET + SCANWIDTH
ENDM
ENDM
```
And there you have it: A five to 10-times speedup of a decent assembly
language texture mapper. All it took was some help from my friends, a
@ -69,12 +71,13 @@ rearranged to eliminate all Pentium stalls save one. When the Y
coordinate fractional part carries and ESI advances, the code executes
as follows:
ADD ESI,ECX ;cycle 1 U-pipe
AND DH,NOT 80H ;cycle 1 V-pipe
;cycle 2 idle AGI on ESI
MOV BL,[ESI] ;cycle 3 U-pipe
ADD EDX,EBP ;cycle 3 V-pipe
```nasm
ADD ESI,ECX ;cycle 1 U-pipe
AND DH,NOT 80H ;cycle 1 V-pipe
;cycle 2 idle AGI on ESI
MOV BL,[ESI] ;cycle 3 U-pipe
ADD EDX,EBP ;cycle 3 V-pipe
```
However, I don't see any way to eliminate this last AGI, which happens
about half the time; even with it, the Pentium execution time for