Handing in my Coder Card
-
goto[^] I've only used goto once before as a professional and ended up removing it a few minutes later when I figured out a different way. Sometimes though for simplicity it just makes sense. I think I'll leave it! Anyone who thinks this code should not be checked in, speak now or forever hold your concurrency locks.
I would bet that these lines get stripped out at some point. Someone, somewhere inevitably will call on a holiday breaking this code.
-
goto[^] I've only used goto once before as a professional and ended up removing it a few minutes later when I figured out a different way. Sometimes though for simplicity it just makes sense. I think I'll leave it! Anyone who thinks this code should not be checked in, speak now or forever hold your concurrency locks.
-
goto[^] I've only used goto once before as a professional and ended up removing it a few minutes later when I figured out a different way. Sometimes though for simplicity it just makes sense. I think I'll leave it! Anyone who thinks this code should not be checked in, speak now or forever hold your concurrency locks.
Sometimes things like that can be handled by placing the code in a method.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun -
I feel like wrapping the rest of the code (up to "end") in an else block should cover that, why complicate it with uncommon syntax?
In any decision where I have two blocks of code that are functionally equivalent but one is more nested than the other, I will pick the less nested version. Fewer braces overall in the code.
-
I'm sure the goto bit needs to be debugged. Just saying.
"the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
"No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)int ASMcontarpalabras(char * texto, int text_size,char * palabra, int pal_size)
{
asm
{
mov [ebp-4],0 // suma total
mov [ebp-8],'v' // dice si es inicio de palabra (v o f)
mov esi,[ebp+8] // texto
mov edx,[ebp+12] // tamaño del texto
mov edi,[ebp+16] // palabra
mov ecx,[ebp+20] // tamaño de la palabra
mov ebx,-1 // contador del texto
xor eax,eax // toma las letras del texto y la palabras en al y ah
mov [esi+edx],' ' // pone al final del texto y la palabra un
mov [edi+ecx],' ' // caracter en blanco
inc edxmain_ciclo: inc ebx
cmp ebx,edx
je salir
mov al,esi[ebx] // mueve a al un caracter del texto
cmp al,32 // chequea si es un espacio
je continuar2
cmp [ebp-8],'f' // chequea si es inicio de palabra
je continuar1 // si no salta a continuar1
mov ah,[edi] //mueve a ah la primera letra
cmp al,ah
je comparar
jmp continuar1//*************
comparar: push ecx
push ebx
mov ecx,2
inc ebx // para comparar con la segunda letraciclo: mov al,esi\[ebx\] //texto mov ah,edi\[ecx-1\] //palabra inc ebx inc ecx cmp al,32 //chequea si se acabo la palabra en el texto je check1: cmp ah,32 //chequea si se acabo la palabra je salir\_dif cmp al,ah je ciclo jmp salir\_dif check1: cmp ah,32 //chequea si las palabras son iguales je check2 jmp salir\_dif check2: sub ebx,ecx //chequea si tienen igual longitud cmp ebx,0 jl salir\_igual xor ecx,ecx mov cl,esi\[ebx\] cmp cl,32 je salir\_igual jmp salir\_dif
salir_igual: inc [ebp-4] //encontro una palabra
pop ebx
cmp ebx,edx
je salir_fin // sale si es igual
pop ecx
jmp main_ciclosalir_dif: pop ebx // ...si es diferente
pop ecx
jmp main_ciclosalir_fin: pop ecx // ...si se acabo el texto
pop ebx -
int ASMcontarpalabras(char * texto, int text_size,char * palabra, int pal_size)
{
asm
{
mov [ebp-4],0 // suma total
mov [ebp-8],'v' // dice si es inicio de palabra (v o f)
mov esi,[ebp+8] // texto
mov edx,[ebp+12] // tamaño del texto
mov edi,[ebp+16] // palabra
mov ecx,[ebp+20] // tamaño de la palabra
mov ebx,-1 // contador del texto
xor eax,eax // toma las letras del texto y la palabras en al y ah
mov [esi+edx],' ' // pone al final del texto y la palabra un
mov [edi+ecx],' ' // caracter en blanco
inc edxmain_ciclo: inc ebx
cmp ebx,edx
je salir
mov al,esi[ebx] // mueve a al un caracter del texto
cmp al,32 // chequea si es un espacio
je continuar2
cmp [ebp-8],'f' // chequea si es inicio de palabra
je continuar1 // si no salta a continuar1
mov ah,[edi] //mueve a ah la primera letra
cmp al,ah
je comparar
jmp continuar1//*************
comparar: push ecx
push ebx
mov ecx,2
inc ebx // para comparar con la segunda letraciclo: mov al,esi\[ebx\] //texto mov ah,edi\[ecx-1\] //palabra inc ebx inc ecx cmp al,32 //chequea si se acabo la palabra en el texto je check1: cmp ah,32 //chequea si se acabo la palabra je salir\_dif cmp al,ah je ciclo jmp salir\_dif check1: cmp ah,32 //chequea si las palabras son iguales je check2 jmp salir\_dif check2: sub ebx,ecx //chequea si tienen igual longitud cmp ebx,0 jl salir\_igual xor ecx,ecx mov cl,esi\[ebx\] cmp cl,32 je salir\_igual jmp salir\_dif
salir_igual: inc [ebp-4] //encontro una palabra
pop ebx
cmp ebx,edx
je salir_fin // sale si es igual
pop ecx
jmp main_ciclosalir_dif: pop ebx // ...si es diferente
pop ecx
jmp main_ciclosalir_fin: pop ecx // ...si se acabo el texto
pop ebxI'm pretty confident that the use of "goto" in assembler is de rigueur. :)
Tom Clement Serena Software, Inc. www.serena.com articles[^]
-
goto[^] I've only used goto once before as a professional and ended up removing it a few minutes later when I figured out a different way. Sometimes though for simplicity it just makes sense. I think I'll leave it! Anyone who thinks this code should not be checked in, speak now or forever hold your concurrency locks.
-
int ASMcontarpalabras(char * texto, int text_size,char * palabra, int pal_size)
{
asm
{
mov [ebp-4],0 // suma total
mov [ebp-8],'v' // dice si es inicio de palabra (v o f)
mov esi,[ebp+8] // texto
mov edx,[ebp+12] // tamaño del texto
mov edi,[ebp+16] // palabra
mov ecx,[ebp+20] // tamaño de la palabra
mov ebx,-1 // contador del texto
xor eax,eax // toma las letras del texto y la palabras en al y ah
mov [esi+edx],' ' // pone al final del texto y la palabra un
mov [edi+ecx],' ' // caracter en blanco
inc edxmain_ciclo: inc ebx
cmp ebx,edx
je salir
mov al,esi[ebx] // mueve a al un caracter del texto
cmp al,32 // chequea si es un espacio
je continuar2
cmp [ebp-8],'f' // chequea si es inicio de palabra
je continuar1 // si no salta a continuar1
mov ah,[edi] //mueve a ah la primera letra
cmp al,ah
je comparar
jmp continuar1//*************
comparar: push ecx
push ebx
mov ecx,2
inc ebx // para comparar con la segunda letraciclo: mov al,esi\[ebx\] //texto mov ah,edi\[ecx-1\] //palabra inc ebx inc ecx cmp al,32 //chequea si se acabo la palabra en el texto je check1: cmp ah,32 //chequea si se acabo la palabra je salir\_dif cmp al,ah je ciclo jmp salir\_dif check1: cmp ah,32 //chequea si las palabras son iguales je check2 jmp salir\_dif check2: sub ebx,ecx //chequea si tienen igual longitud cmp ebx,0 jl salir\_igual xor ecx,ecx mov cl,esi\[ebx\] cmp cl,32 je salir\_igual jmp salir\_dif
salir_igual: inc [ebp-4] //encontro una palabra
pop ebx
cmp ebx,edx
je salir_fin // sale si es igual
pop ecx
jmp main_ciclosalir_dif: pop ebx // ...si es diferente
pop ecx
jmp main_ciclosalir_fin: pop ecx // ...si se acabo el texto
pop ebx -
goto[^] I've only used goto once before as a professional and ended up removing it a few minutes later when I figured out a different way. Sometimes though for simplicity it just makes sense. I think I'll leave it! Anyone who thinks this code should not be checked in, speak now or forever hold your concurrency locks.
-
In any decision where I have two blocks of code that are functionally equivalent but one is more nested than the other, I will pick the less nested version. Fewer braces overall in the code.
-
goto[^] I've only used goto once before as a professional and ended up removing it a few minutes later when I figured out a different way. Sometimes though for simplicity it just makes sense. I think I'll leave it! Anyone who thinks this code should not be checked in, speak now or forever hold your concurrency locks.
-
goto[^] I've only used goto once before as a professional and ended up removing it a few minutes later when I figured out a different way. Sometimes though for simplicity it just makes sense. I think I'll leave it! Anyone who thinks this code should not be checked in, speak now or forever hold your concurrency locks.
1991 was the last time I used GOTO, and I was not a professional then X|
Never underestimate the power of human stupidity RAH
-
goto[^] I've only used goto once before as a professional and ended up removing it a few minutes later when I figured out a different way. Sometimes though for simplicity it just makes sense. I think I'll leave it! Anyone who thinks this code should not be checked in, speak now or forever hold your concurrency locks.
Jason Hooper wrote:
used goto ... as a professional
I have, but in scripts (e.g. DCL and BAT files), not in proper programming languages. Except for VAX BASIC, but maybe that stretches the definition of "proper programming language". :~
-
Protip; bugs should be reported[^] bug forum instead of on the lounge.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
-
Protip; bugs should be reported[^] bug forum instead of on the lounge.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt