flat assembler
Message board for the users of flat assembler.
Index
> Windows > regarding convert win32 C macro FD_SET (network) to fasm |
Author |
|
Nikolay Petrov 19 Mar 2006, 20:39
its a proc variant of FD_SET macro from winsock2.h
Code: fdsize = 64 proc FD_SET fd,set; fd is unsigned, set is offset fd_set struct mov edx,[set] mov ecx,[fd] xor eax,eax jmp .while .do: cmp ecx,[edx+4*(eax+1)] je .endw inc eax .while: cmp eax,[edx] jb .do .endw: cmp eax,[edx] jne @f cmp [edx],fdsize jae @f mov [edx+4*(eax+1)],ecx inc [edx] @@: ret endp _________________ regards |
|||
19 Mar 2006, 20:39 |
|
vbVeryBeginner 20 Mar 2006, 07:00
oh,thanks nikolay petrov,
btw, the FD_SET i posted works on my application here is the FD_CLR, Code: proc FD_CLR fd,set push eax ebx ecx edx mov ebx,[fd] ; ebx = fd mov edx,[set] mov eax,[edx] ; eax = fd_count add edx,4 ; so that EDX reffer to fd_array, (skip the fd_count) mov ecx,0 @@: cmp ecx,eax jge .finish cmp ebx,[edx] je .relocate inc ecx jmp @b .relocate: cmp ecx,eax je .reduce push dword [edx+4] pop dword [edx] inc ecx add edx,4 jmp .relocate .reduce: ; fd_count-- dec [set] .finish: pop edx ecx ebx eax ret endp tested and work correctly. |
|||
20 Mar 2006, 07:00 |
|
Nikolay Petrov 20 Mar 2006, 11:25
i don't think. the proc wasn't wrote very correctly, if we see the macro.
for example fd and fd_array is unsigned, but you checked signed; dec [set] -??? its equ dec[ebp+12], but [ebp+12]=[set] and will be no effect into set.fd_count, when proc finish. next is a not bad solution Code: proc FD_CLR fd,set mov edx,[set] mov ecx,[fd] xor eax,eax jmp .in_for .for: cmp ecx,[edx+4*(eax+1)] jne .continue jmp .while .do: mov ecx,dword ptr [edx+4*(eax+2)] mov [edx+4*(eax+1)],ecx inc eax .while: mov ecx,[edx] dec ecx cmp eax,ecx jb .do dec [edx] ret .continue: inc eax .in_for: cmp eax,[edx] jb .for ret endp or Code: proc FD_CLR fd,set mov edx,[set] mov ecx,[fd] xor eax,eax jmp .while .do: cmp ecx,[edx+4*(eax+1)] je .endw inc eax .while: cmp eax,[edx] jb .do ret .endw: push ebx mov ebx,[edx] dec ebx jmp .while2 .do2: mov ecx,[edx+4*(eax+2)] mov [edx+4*(eax+1)],ecx inc eax .while2: cmp eax,ebx jb .do2 dec [edx] pop ebx ret endp by the way, if it isn't a secret why do you copy winsock macros? _________________ regards |
|||
20 Mar 2006, 11:25 |
|
vbVeryBeginner 20 Mar 2006, 23:29
oh yeah,
my mistake |
|||
20 Mar 2006, 23:29 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.