quote:Original post by Jx
The registers EAX, EBX, ECX etc can only be used for storing whole numbers like 4, 32, 65536 etc etc. The floating point registers are used for holding values like 3.14159, -0.910192 etc.
The type of data should be pretty irrelevant. You should be fine putting floats, ints, strings, pointers, and whatever in e(a|b|c|d)x as long as they are 32 bits. Although, one should be careful what operations you do to them
quote:Original post by _the_phantom_
That said, I personal wouldnt use assember any more (unless it was an small mircoprocessor) because i'm pretty certain the compiler can turn my C/C++ into better assembler than I could write
??? I highly doubt that, not knowing your assembly skills though. MSVC++ seems to have extremely bad common sense, escpecially when it comes to utilizing registers and hold their values. Instead it constantly "resolves" indirections etc.
This piece of crap came to mind now. It is a part of my line routine for drawing a horizontal line. The first column is the C code, second the assembly MSVC++ produced, the third is how I would have implement it in Motorola 680x0 assembly. If I tried, I'm sure could reduce the x86 assembly a lot.
if(nPixelCountY == 0) [4] cmp DWORD PTR _nPixelCountY$[ebp], 0 [2] tst.l d1 [2] jne SHORT $L667 [2] bne.b .type2 while(nPixelCountX--) [3] mov edx, DWORD PTR _nPixelCountX$[ebp] [3] mov eax, DWORD PTR _nPixelCountX$[ebp] [3] sub eax, 1 [3] mov DWORD PTR _nPixelCountX$[ebp], eax [2] test edx, edx [2] je SHORT $L670 *pAddress++ = dwColorARGB32; [3] mov ecx, DWORD PTR _pAddress$[ebp] [3] mov edx, DWORD PTR _dwColorARGB32$[ebp] [2] mov DWORD PTR [ecx], edx [2] move.l d2,(a0)+ [3] mov eax, DWORD PTR _pAddress$[ebp] [3] add eax, 4 [3] mov DWORD PTR _pAddress$[ebp], eax [2] jmp SHORT $L669 [4] dbra d0,.type1_loop
EDIT: The number inside the brackets are the instruction size. And the labels I've used: .type2 is somewhere after this stuff, and .type1_loop is pointing to the previous move.l instruction
EDIT 2: The disgusting part of this is that this routine should be able to run without any memory access but when putting the pixel there. Instead it is 5 read accesses and 3 writes (including the pixel putting).
[edited by - CWizard on September 12, 2002 5:23:32 PM]