Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
[alt.lang.asm,comp.lang.c]assembly Vs C Language
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="¬a\\/b, post: 2496280"] Belive it or not, with my little symbols language assembly is 1000 times better than C in **in practice** Can you write what this below does, better and more clear in C? :) /* ritorna -1 D[s+116Funzione_chiamante]==D[s+20qui]==-1 se errore /* ritorna 0 D[s+116Funzione_chiamante]==linea_ricevuta_len se OK /* 0j, 4i, 8r, 12c, 16b, 20ra, 24P_a dg_threadf: < b, c, r, i, j /* 100:4(socket), 104:4(@ibuf), 108:4(ilen) /* 112:4(var), 116:4(Valore ret di dg_threadf), 124:4(& @destAdd) /* 128:4(& @destLen), 132:4(Timeout), 136:16(fromwhere?) /* 156:4(len) i=[s+24]; b=*i; ..0: r=[i+4]; c=[i+8]; j=&[i+36]; a=&[i+56]; D*a=16; recvfrom(b, r, c, 0, j, a); a==SOCKET_ERROR!#.1 ..e: a=-1; D[i+16]=a; #.f; ..1: D[i+32] #.e; /* timeout D[j+20]<8#.e /* risposta troppo piccola r=[j]; c=[i+24]; c=[c]; r!=[c] #.0; /* confronta addr. port /* del messaggio con quelle da ricevere r=[j+4]; r!=[c+4]#.0; D[i+16]=a; a=0; /* fine ok ..f: ret 4 /* int dg_SndRcv( char* ibuf, int ilen, char* obuf, int olen, /* int fd, char* destAdd_cliAdd, int destLen, int* Pint3A) /* funzione che manda domanda(obuf), riceve risposta(ibuf) usando UDP /* se timeout senza risposta o errori ritorna -1 e CF==1 /* altrimenti ritorna lunghezza messaggio ricevuto e CF==0 /* /* "Pint3A" punta a un vettore di 3 interi inizializzato /* per la prima volta a "Pint3A[0]=0; Pint3A[1]=0; Pint3A[2]=4;" /* /* 256+28=284, 256+32=288 /* 0k, 4j, 8i, 12r, 16c, 20b, 24ra, 28P_ibuf, 32P_ilen, 36P_obuf, /* 40P_olen /* 44P_fd, 48P_destAdd, 52P_destLen, 56P_Pint3A dg_SndRcv: < b, c, r, i, j, k s-=256 << @ibuf=[s+284], @ilen=[s+288], @obuf=[s+292], @olen=[s+296] << @fd=[s+300], @destAdd=[s+304], @destLen=[s+308], @Pint3A=[s+312] << @t=[k], @c=[k+4], @delta=[k+8] /* s = 0:4(var), 16:4(Var), 24:4(N.trasmissioni), /* 32:4(Tempo totale), 36:16(NewAddr), 56:4(newLen) /* 100:4(socket), 104:4(@ibuf), 108:4(ilen) /* 112:4(var), 116:4(Valore ret di dg_threadf), 124:4(& @destAdd) /* 128:4(& @destLen), 132:4(Timeout), 136:16(fromwhere?), /* 156:4(len) /* 200:16(& @cliaddr) i=@obuf; k=@Pint3A; D[s+24]=4; /* 1+tre ritrasmissioni D[s+16]=0; D @ibuf==0#.e; i==0#.e; D @destAdd==0!#.a| D @destLen!=0#.e; #.b; ..a: D @destLen<0 ?#.e; ..b: b=@fd; b==-1#.e; D @ilen<=0?#.e; D @olen<0?#.e; k!#.e; j=@t; D[s+32]=j; #.1; ..e: a=-1; stc; ##.f; ..1: D @t!=0!#.2 D @t > 10000#.c; /* 10s se esageratamente grande vai e ricalcola c=@c; c==@delta!#.2 /* aggiorna il timer per velocita' ..c: D @t=0; D @c=0; j=0; /* maggiori ogni "delta" pacchetti D[s+32]=j; /* aggiorna estimatori ogni 200 volte D @delta>200#.2| D @delta <<= 1; /* delta cresce all'inizio ..2: D*s="."; a=s; _P<(a); a=@olen; r=@destAdd; c=@destLen; i=@obuf; sendto(b, i, a, 0, r, c); a!=@olen#.e; D[s+16]#.3; c=@ilen; r=@ibuf; a=&[s+100]; *a=b; D[a+4]=r; D[a+8]=c; i=&[a+12]; r=& @destAdd; c = & @destLen; D[a+24]=r; D[a+28]=c; D[a+32]=0; CreateThread(0, 0, dg_threadf, a, 0, i); a==0#.e; [s+16]=a; ..3: j=@t; ..4: a=@t; Sleep(a); a=[s+16]; c=s; GetExitCodeThread(a, c); a==0#.6; D*s!=STILL_ACTIVE!#.5 b=[s+116]; b<0?#.7; a=[s+32]; @t=a; ++D @c; a=b; clc; ##.f; ..5: a=@t; j+=@t; ++a; D[s+32]+=a; @t=a; /* il tempo aumenta se problemi j>30100!#.4 /* 30 secondi timeout per nuovo sendto --D[s+24]!#.ee; ##.2; /* 1+3 volte rinvia sendto; ..6: ##.e1; ..6a: PrintSockError(); ##.e1; ..6b: ##.9; ..7: D @t=0; D @c=0; D @delta=4; a=-1; stc; ##.f; /* reset ..ee: _P<("Timeout ... \n"); D[s+132]=1; socket(AF_INET, SOCK_DGRAM, 0 ); a==INVALID_SOCKET#.6a; i=a; /* nome del socket client [quello del client] r=&[s+200]; a=&[s+8]; D*a=16; getsockname(b, r, a); a#.6b; inet_addr("127.0.0.1"); a==INADDR_NONE#.9; r=&[s+200]; j^=j; [r+sin_addr]=a; /* printSockAddr_in(r); ..8: r=&[s+200]; a=&[s+8]; c=&[s+4]; sendto(i, c, 0, 0, r, a); a!=0#.9; ..55: Sleep(500); a=[s+16]; c=s; GetExitCodeThread(a, c); a==0#.9; ++j; D*s!=STILL_ACTIVE#.9; j==7#.9; j==3#.8; #.55; ..9: dg_close1(i); jnc .e1; _P<("dg_SndRcv: Errore nel chiudere il socket\n"); /* chiude i=socket, j=thread ..e1: j=[s+16]; CloseHandle(j); a==0#.77; ##.7 /* errore==0 #.77 ..77: TerminateThread(j, 0); CloseHandle(j); ##.7; ..f: /* se dopo 4 volte ancora nessuna risposta esce ret 32 this is the traslation ; ritorna -1 D[s+116Funzione_chiamante]==D[s+20qui]==-1 se errore ; ritorna 0 D[s+116Funzione_chiamante]==linea_ricevuta_len se OK ; 0j, 4i, 8r, 12c, 16b, 20ra, 24P_a dg_threadf: push ebx push ecx push edx push esi push edi ; 100:4(socket), 104:4(@ibuf), 108:4(ilen) ; 112:4(var), 116:4(Valore ret di dg_threadf), 124:4(& @destAdd) ; 128:4(& @destLen), 132:4(Timeout), 136:16(fromwhere?) ; 156:4(len) mov esi, [esp+24] mov ebx, [esi] ..0: mov edx, [esi+4] mov ecx, [esi+8] lea edi, [esi+36] lea eax, [esi+56] mov dword[eax], 16 push eax push edi push 0 push ecx push edx push ebx call recvfrom cmp eax, SOCKET_ERROR jne .1 ..e: mov eax, -1 mov dword[esi+16], eax jmp short .f ..1: ; timeout cmp dword[esi+32] , 0 jne .e cmp dword[edi+20], 8 jb .e ; risposta troppo piccola mov edx, [edi] ; confronta addr. port mov ecx, [esi+24] mov ecx, [ecx] cmp edx, [ecx] jne .0 mov edx, [edi+4] ; del messaggio con quelle da ricevere cmp edx, [ecx+4] jne .0 mov dword[esi+16], eax ; fine ok mov eax, 0 ..f: pop edi pop esi pop edx pop ecx pop ebx ret 4 ; int dg_SndRcv( char* ibuf, int ilen, char* obuf, int olen, ; int fd, char* destAdd_cliAdd, int destLen, int* Pint3A) ; funzione che manda domanda(obuf), riceve risposta(ibuf) usando UDP ; se timeout senza risposta o errori ritorna -1 e CF==1 ; altrimenti ritorna lunghezza messaggio ricevuto e CF==0 ; ; "Pint3A" punta a un vettore di 3 interi inizializzato ; per la prima volta a "Pint3A[0]=0; Pint3A[1]=0; Pint3A[2]=4;" ; ; 256+28=284, 256+32=288 ; 0k, 4j, 8i, 12r, 16c, 20b, 24ra, 28P_ibuf, 32P_ilen, 36P_obuf, 40P_olen ; 44P_fd, 48P_destAdd, 52P_destLen, 56P_Pint3A dg_SndRcv: push ebx push ecx push edx push esi push edi push ebp sub esp, 256 %define @ibuf [esp+284] %define @ilen [esp+288] %define @obuf [esp+292] %define @olen [esp+296] %define @fd [esp+300] %define @destAdd [esp+304] %define @destLen [esp+308] %define @Pint3A [esp+312] %define @t [ebp] %define @c [ebp+4] %define @delta [ebp+8] ; s = 0:4(var), 16:4(Var), 24:4(N.trasmissioni) ; 32:4(Tempo totale), 36:16(NewAddr), 56:4(newLen) ; 100:4(socket), 104:4(@ibuf), 108:4(ilen) ; 112:4(var), 116:4(Valore ret di dg_threadf), 124:4(& @destAdd) ; 128:4(& @destLen), 132:4(Timeout), 136:16(fromwhere?) ; 156:4(len) ; 200:16(& @cliaddr) mov esi, @obuf ; 1+tre ritrasmissioni mov ebp, @Pint3A mov dword[esp+24], 4 mov dword[esp+16], 0 cmp dword @ibuf, 0 je .e cmp esi, 0 je .e cmp dword @destAdd, 0 jne .a cmp dword @destLen, 0 jne .e jmp short .b ..a: cmp dword @destLen, 0 jl .e ..b: mov ebx, @fd cmp ebx, -1 je .e cmp dword @ilen, 0 jle .e cmp dword @olen, 0 jl .e cmp ebp, 0 je .e mov edi, @t mov dword[esp+32], edi jmp short .1 ..e: mov eax, -1 stc jmp .f ..1: cmp dword @t, 0 je .2 cmp dword @t, 10000 ja .c ; 10s se esageratamente grande vai e ricalcola mov ecx, @c ; aggiorna il timer per velocita' cmp ecx, @delta jne .2 ..c: ; maggiori ogni "delta" pacchetti mov dword @t, 0 mov dword @c, 0 mov edi, 0 mov dword[esp+32], edi ; aggiorna estimatori ogni 200 volte cmp dword @delta, 200 ja .2 ; delta cresce all'inizio shl dword @delta, 1 ..2: mov dword[esp], "." mov eax, esp push eax call _P add esp, 4 mov eax, @olen mov edx, @destAdd mov ecx, @destLen mov esi, @obuf push ecx push edx push 0 push eax push esi push ebx call sendto cmp eax, @olen jne .e cmp dword[esp+16], 0 jne .3 mov ecx, @ilen mov edx, @ibuf lea eax, [esp+100] mov [eax], ebx mov dword[eax+4], edx mov dword[eax+8], ecx lea esi, [eax+12] lea edx, @destAdd lea ecx, @destLen mov dword[eax+24], edx mov dword[eax+28], ecx mov dword[eax+32], 0 push esi push 0 push eax push dg_threadf push 0 push 0 call CreateThread cmp eax, 0 je .e mov [esp+16], eax ..3: mov edi, @t ..4: mov eax, @t push eax call Sleep mov eax, [esp+16] mov ecx, esp push ecx push eax call GetExitCodeThread cmp eax, 0 je .6 cmp dword[esp], STILL_ACTIVE je .5 mov ebx, [esp+116] cmp ebx, 0 jl .7 mov eax, [esp+32] mov @t, eax inc dword @c mov eax, ebx clc jmp .f ..5: ; il tempo aumenta se problemi mov eax, @t add edi, @t inc eax add dword[esp+32], eax mov @t, eax cmp edi, 30100 jbe .4 ; 30 secondi timeout per nuovo sendto dec dword[esp+24] jz .ee ; 1+3 volte rinvia sendto; jmp .2 ..6: jmp .e1 ..6a: call PrintSockError jmp .e1 ..6b: jmp .9 ..7: ; reset mov dword @t, 0 mov dword @c, 0 mov dword @delta, 4 mov eax, -1 stc jmp .f ..ee: push _Timeout_$$$_$n call _P add esp, 4 mov dword[esp+132], 1 push 0 push SOCK_DGRAM push AF_INET call socket cmp eax, INVALID_SOCKET je .6a mov esi, eax lea edx, [esp+200] lea eax, [esp+8] mov dword[eax], 16 push eax push edx push ebx call getsockname cmp eax, 0 jne .6b push _127$0$0$1 call inet_addr cmp eax, INADDR_NONE je .9 lea edx, [esp+200] xor edi, edi mov [edx+sin_addr], eax ; printSockAddr_in(r); ..8: lea edx, [esp+200] lea eax, [esp+8] lea ecx, [esp+4] push eax push edx push 0 push 0 push ecx push esi call sendto cmp eax, 0 jne .9 ..55: push 500 call Sleep mov eax, [esp+16] mov ecx, esp push ecx push eax call GetExitCodeThread cmp eax, 0 je .9 inc edi cmp dword[esp], STILL_ACTIVE jne .9 cmp edi, 7 je .9 cmp edi, 3 je .8 jmp short .55 ..9: push esi call dg_close1 jnc .e1 push _dg$SndRcv$_Errore_nel_chiudere_il_socket$n call _P add esp, 4 ; chiude i=socket, j=thread ..e1: ; errore==0 #.77 mov edi, [esp+16] push edi call CloseHandle cmp eax, 0 je .77 jmp .7 ..77: push 0 push edi call TerminateThread push edi call CloseHandle jmp .7 ..f: ; se dopo 4 volte ancora nessuna risposta esce %undef @t %undef @c %undef @delta ; e ritorna -1 %undef @fd %undef @destAdd %undef @destLen %undef @Pint3A %undef @ibuf %undef @ilen %undef @obuf %undef @olen lea esp, [esp+256] pop ebp pop edi pop esi pop edx pop ecx pop ebx ret 32 [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
[alt.lang.asm,comp.lang.c]assembly Vs C Language
Top