|
-
April 8th, 2005, 03:07 PM
#1
Calculating memory address
Code:
1: void __fastcall fastpixel(long* surface)
2: {
3: int iCount = 1152*864;
4: __asm
5: {
6: // Assign pointers to register
7: push edi;
8: push ecx;
9: push eax;
10: mov edi, [surface] ; //put dest addr to edi reg
11: mov ecx, [iCount] ;// put count to ecx reg
12:
13: codeloop:
14: mov eax, [edi] ; //mov a byte of src data to low
15: xor eax, 0x00ffffff ;
16: mov [edi], eax ;
17: add edi,4;
18: dec ecx ; //decrement count by 1
19: jnz codeloop ; //jump to codeloop if not 0
20: pop edi;
21: pop ecx;
22: pop eax;
23: }
24: }
Ok so I've got this lovely bit of code that I've constructed and I need a few clerifications:
in theory I should have been able to replace lines 14 to 16 with this:
first:
xor [edi], 0x00FFFFFF
how ever this just turns my screen blue :\
second:
I seem to need to use add edi,4 instead of just inc because inc only seems to move it 1 byte forward, is there a way to fix this?
third:
This is in the help docs for MASM32 but I have no clue what idex, scale, and displacement are reffering to.
[ Base Address + Index * Scale + Displacement ]
[ebx + ecx * 4 + 8]
ebx is the base address.
ecx is the index.
4 is the scale based on the data size.
8 is the displacement in BYTES.
In C, you merely shoot yourself in the foot.
In C++, you accidentally create a dozen instances of yourself and shoot them all in the foot. Providing emergency medical care is impossible, because you can't tell which are bitwise copies and which are just pointing at others and saying, "That's me, over there."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|