Re: C# programmer wants to learn assembly?? plz help
- From: "¬a\\/b" <al@xxx>
- Date: Sat, 30 Dec 2006 10:38:47 +0100
On Fri, 29 Dec 2006 20:56:29 -0600, David Jones wrote:
Here's a counter-example: let's say you need to verify that an email
address in a string has the format something@xxxxxxxxxxx? (string +
'@' + string + '.' + string, with only one @ in the string) See how
long it takes you to write it in assembly.
not tested
; r==string a='char'
nextSc:
mov ecx, 0
cmp eax, 256
ja .e
xor ebx, ebx
jmp short .1
..e:
stc
jmp short .f
..0:
inc edx
inc ecx
..1:
mov bl, [edx]
cmp bl, 0
je .2
push ebx
call isalphaM_in_asm_answer_inCF
jc .2
cmp bl, al
jne .0
..2:
cmp bl, al
jne .e
cmp ecx, 0
je .e
inc edx
clc
..f:
ret
;16P
IsEmail:
push ebx
push ecx
push edx
mov edx, [esp+16]
mov eax, '@'
call nextSc
jc .e
mov eax, '.'
call nextSc
jc .e
mov eax, 0
call nextSc
jc .e
jmp short .1
..e:
mov eax, 0
stc
jmp short .f
..1:
mov eax, 1
clc
..f:
pop edx
pop ecx
pop ebx
ret 4
/* r==string a='char'
nextSc:
c=0; a>256#.e;
b^=b; #.1;
..e: stc; #.f;
..0: ++r,c;
..1: bl = *r;
bl==0#.2;
isalphaM_in_asm_answer_inCF(b); jc .2;
bl!=al#.0
..2: bl!=al#.e; c==0#.e;
++r;
clc
..f:
ret
/*16P
IsEmail:
< b, c, r
r=[s+16]; a='@'; nextSc(); jc .e
a='.'; nextSc(); jc .e
a=0 ; nextSc(); jc .e
#.1;
..e: a=0; #.f;
..1: a=1;
..f:
b, c, rret 4
Then compare to ECMAScript: /^[^\s\@]+\@[^\s\@]+\.[^\s\@]+$/.test(str)
does "ecmascript" see the not allowed chars in string like "é" ?
does "ecmascript" see the not allowed chars in string like ".." or
"@@" ?
does "ecmascript" see "1@c." or "1@.qw" or "@a.b" like wrongs?
Guess which one would take longer for me to write.... (hint: if I wrote
you have to see the time for the bug-free version
the code above while I was typing my reply, the ECMAScript version.
didn't take too long -- show me the equivalent with RosAsm, please)
I'm not saying assembly doesn't have its benefits: it's just not always
the best tool for solving a particular problem.
- Follow-Ups:
- Re: C# programmer wants to learn assembly?? plz help
- From: David Jones
- Re: C# programmer wants to learn assembly?? plz help
- References:
- C# programmer wants to learn assembly?? plz help
- From: giddy
- Re: C# programmer wants to learn assembly?? plz help
- From: Frank Kotler
- Re: C# programmer wants to learn assembly?? plz help
- From: //\\\\o//\\\\annabee
- Re: C# programmer wants to learn assembly?? plz help
- From: Herbert Kleebauer
- Re: C# programmer wants to learn assembly?? plz help
- From: Betov
- Re: C# programmer wants to learn assembly?? plz help
- From: Herbert Kleebauer
- Re: C# programmer wants to learn assembly?? plz help
- From: Betov
- Re: C# programmer wants to learn assembly?? plz help
- From: Herbert Kleebauer
- Re: C# programmer wants to learn assembly?? plz help
- From: David Jones
- Re: C# programmer wants to learn assembly?? plz help
- From: David Jones
- C# programmer wants to learn assembly?? plz help
- Prev by Date: Re: Print BX to output
- Next by Date: Re: C# programmer wants to learn assembly?? plz help
- Previous by thread: Re: C# programmer wants to learn assembly?? plz help
- Next by thread: Re: C# programmer wants to learn assembly?? plz help
- Index(es):
Relevant Pages
|