Quote:
>CGR_PutPixel PROC NEAR
> POP SI ; SI = Return Address : UV 1 U
> POP BX ; BX = Color : UV 1 V
> POP AX ; AX = Y : UV 1 U
> MOV DX, 320 ;?CX = 320 : UV 1 V
> MUL DX ; AX = AX * 320 = Y*320 : NP 11 U
> POP DI ; DI = X : UV 1 U
> ADD DI, AX ; DI = DI + AX = 320Y+X : UV 1 V
> MOV GS:[DI], BL ; Draw The Pixel : UV 1 U
> JMP SI ; Return To Program : PV 2 V
>CGR_PutPixel ENDP
Hi,
I'm a beginner at pentium so this is only tentative, but:
(1) isn't the floating multiply actually faster than integer.....?
remember the register length should be the norm for the segment
i.e. 16-bit in 16-bit protected mode [or real mode] and 32-bit in
32-bit protected.
(2) this code can't go much faster as such, because there's
a CRITICAL PATH through it: you have to load the data before you
multiply the data loaded, before you add to the product, before the
cycle when you use the sum to make the address for the indexed store,
before you execute the indexed store.
What you can do instead is to execute other operations alongside that:
if this is in a loop to output N lots of (X, Y, P) values, you might
do better to have an assembler subroutine to carry out the whole loop.
Quote:
>Hint: 256 + 64 = 320 (use SHL instead)
>Another way to do it is to make a table of 200 word entries:
>0, 320, 640, etc. etc.
>and just look up the Y-position and add the x position
<Hits self on head!!!>
//U. //V.
mov ax,4[sp]; pop si; //note critical path in LH column
shl ax,2; pop bx; //of succesive ax, then di, computations
add ax,0[sp]; pop cx;
shl ax,6; pop di;
add di,ax; /***/
/*pause one step for prefix, would do anyway for address dependency*/
mov GS:[di],bl; /***/
/***/ jmp si; //owzat -- 8 cycles !!!!!!!!!
[I think that works --- pop simply doesn't produce dependencies
on SP for following instructions].
In a 32 bit segment you might also try......
mov eax,8[esp]; pop esi; //set eax up here 2stop address depndncy
/***/ pop ebx; // pop pixel EBX
lea eax,[eax*4+eax]; pop ecx; //mul eax * 5, junk the value in ECX
shl eax,6; pop edi; //nul eax *64, pop X value in EDI
/*pause one step for prefix, would do anyway for address dependency*/
mov GS:[edi+eax],bl; /***/
/***/ jmp esi;
--