From: ?a/b on
I'm a hobby programmer (tipicaly 2-3 hours of programming for day)
How it is possible that in a language definited 100% wrong i a poor
beginner can write something like this?
In your opinion your professional "atoi" is better than my "ato_i"?

/* assembly language with indentation and <9 instruction for line
/* that someone say "it is 100% wrong"
/* int cf(void);
_cf: a=0; a++=0; ret

/* eax __stdcall ato_i(char* string, char* pos)
/* 0 i, 4 r, 8 c, 12 b, 16 Ra, 20 string, 24 pos
ato_i:
< b, c, r, i
<< @string=[s+20], @pos=[s+24]
i=(a)string; c=0; #.c1; /* in c il segno
..c0: ++i; .c1: B*i==' '#.c0; B*i==9#.c0;
B*i=='+'!#.c2 | ++i; #.c3;
..c2: B*i=='-'!#.c3 | ++i; ++c;
..c3: B*i>'9' #.ce;
B*i<'0' #.ce;
#.c5;
..ce: a=(a)pos; r=(a)string; *a=r; a=0; #.ca;
..c4: ++i; .c5: B*i=='0'#.c4
a=0; b=0;
..c6: bl=*i;
bl>'9'#.c8
bl<'0'#.c8
mul D*dieci| r#.ci /* in ci +/-oo
b-='0'; a+=b| jc .ci
a&0x80000000 | jnz .ci
++i; #.c6;
..ci: a=0x7FFFFFFF; r=1;
..c7: ++i; bl=*i; bl>'9'#.a0;
bl<'0'#.a0; #.c7
..c8: r=0;
..a0: c==0#.c9; neg a
..c9: b=(a)pos; *b=i;
r!=0!#.ca; stc; #.cf
..ca: clc;
..cf:
>> @string, @pos
> b, c, r, i
ret 8

; int cf(void);
_cf:
mov eax, 0
adc eax, 0
ret


; assembly language

; eax _ato_i(char* string, char* pos)
; 0 i, 4 r, 8 c, 12 b, 16 Ra, 20 string, 24 pos
ato_i:
push ebx
push ecx
push edx
push esi
%define @string [esp+20]
%define @pos [esp+24]
mov esi, @string ; in c il segno
mov ecx, 0
jmp short .c1
..c0:
inc esi
..c1:
cmp byte[esi], ' '
je .c0
cmp byte[esi], 9
je .c0
cmp byte[esi], '+'
jne .c2
inc esi
jmp short .c3
..c2:
cmp byte[esi], '-'
jne .c3
inc esi
inc ecx
..c3:
cmp byte[esi], '9'
ja .ce
cmp byte[esi], '0'
jb .ce
jmp short .c5
..ce:
mov eax, @pos
mov edx, @string
mov [eax], edx
mov eax, 0
jmp short .ca
..c4:
inc esi
..c5:
cmp byte[esi], '0'
je .c4
mov eax, 0
mov ebx, 0
..c6:
mov bl, [esi]
cmp bl, '9'
ja .c8
cmp bl, '0'
jb .c8
mul dword[dieci] ; in ci +/-oo
cmp edx, 0
jne .ci
sub ebx, '0'
add eax, ebx
jc .ci
test eax, 0x80000000
jnz .ci
inc esi
jmp short .c6
..ci:
mov eax, 0x7FFFFFFF
mov edx, 1
..c7:
inc esi
mov bl, [esi]
cmp bl, '9'
ja .a0
cmp bl, '0'
jb .a0
jmp short .c7
..c8:
mov edx, 0
..a0:
cmp ecx, 0
je .c9
neg eax
..c9:
mov ebx, @pos
mov [ebx], esi
cmp edx, 0
je .ca
stc
jmp short .cf
..ca:
clc
..cf:
%undef @string
%undef @pos
pop esi
pop edx
pop ecx
pop ebx
ret 8

/* C language */
#include <stdio.h>
#include <stdlib.h>

static const char *pcp = "[insert a number (EOF for end)]> ";

int skip_line(FILE* pf)
{int c; while( (c=fgetc(pf))!='\n' && c!=EOF ); return c;}


int __stdcall ato_i(char* string, char** pos);
int cf(void); /* for to find what is in carry falg[CF] */



int main(void)
{char buf[256]={0}, *pb;
int i, z;
/*/////////////////////////////*/
la:;
while(1)
{printf("%s", pcp); fflush(stdout);
buf[256-2]=0;
if( fgets(buf, 256, stdin )!=0 )
{if(buf[256-2]!=0 && buf[256-2]!='\n')
{printf("Linea troppo lunga\n");
if(feof(stdin)) return 0;
if( skip_line(stdin) == EOF )
return 0;
goto la;
}
if( (i=ato_i( buf, &pb ), cf())==1 )
{if(i>0) printf("overflow+ ");
else printf("overflow- ");
}
printf("numero=%i stringa=\"%s\" ", i, pb);
printf("buf=%p pb=%p \n",
(void*) buf, (void*)pb);
}// if fgets
if(feof(stdin)) return 0;
}//while
}

From: Betov on
"?a\\/b" <al(a)f.g> ?crivait news:8q873299e66khsj6s31pdsopn8b6mtfsl8@
4ax.com:

> I'm a hobby programmer (tipicaly 2-3 hours of programming for day)
> How it is possible that in a language definited 100% wrong i a poor
> beginner can write something like this?
> In your opinion your professional "atoi" is better than my "ato_i"?
>
> /* assembly language with indentation and <9 instruction for line
> /* that someone say "it is 100% wrong"
> /* int cf(void);
> _cf: a=0; a++=0; ret
>
> /* eax __stdcall ato_i(char* string, char* pos)
> /* 0 i, 4 r, 8 c, 12 b, 16 Ra, 20 string, 24 pos
> ato_i:
> < b, c, r, i
> << @string=[s+20], @pos=[s+24]
> i=(a)string; c=0; #.c1; /* in c il segno
> .c0: ++i; .c1: B*i==' '#.c0; B*i==9#.c0;

Well, this question has already been addressed several time...

* "atoi" or "ato_i", or whatever are utterly un-acceptable.

If this is for switching from Ascii to Integer, the name
must be "AsciiToInteger", and nothing else. If this is for
switching from Decimal-Ascii to the EAX Register, the Name is
DecimalAsciiToEax and nothing else, and so on... The words
are in any english Dictionary and there is no reason for
inventing any new one, that a beginner would have to _LEARN_,
before using.

* The readability of lines like the last one is, so to say,
negative:

> .c0: ++i; .c1: B*i==' '#.c0; B*i==9#.c0;

Well, we can guess that ".c0:" is a Pseudo Local Label. So
should therefore be ".c1:"(?). But what with the other two
".c0"s, preceded by some "#", this does evidently not belong
to any known Assembly syntax, and, therefore requires, first
-before even trying to read 1) An acception of the Syntax,
2) a serious study of the Syntax. Which is absurd vaste of time,
as long as we already have one, which, even if considered bad
by some very particular fellows, like Herbert, has, at least,
the advantage of being generaly read by all Asmers.

Then, what does "++i" mean?

Then, in the second "B*i==" , what is the value of "B", and what
is "B" (Stack // Data // Code ???!!!...). What is the meaning
of "=="?

Then, in Assembly, comments are ";", not separators. And so on...

Then writing multiple Statements on a single Line -which is a
very good thing, massively encreasing the readability- requires
having separators, which are very visible so that the readers'
eyes, could detects the lines parts, at first sight. Here, this
is the opposite: You have first to do the absurd effort for
searching where the Instructions are. Scaring.

In short, as you have been told many times, inventing private
Syntaxes like yours may be programming fun, but is definitively
absurd to try to inflict to the other, as long as you will
always be the only one able to read this. The next step would be
to replace the Chars with Chineese drawings, and the Digits by
true arabian Digits, in some Unicode Format.

;)

Betov.

< http://rosasm.org >



From: James Daughtry on
¬a\/b wrote:
> I'm a hobby programmer (tipicaly 2-3 hours of programming for day)

That's irrelevant, in my opinion.

> How it is possible that in a language definited 100% wrong i a poor
> beginner can write something like this?

Anyone who tells you your language definition is 100% wrong is either
deluded, or merely stating an opinion. However, that doesn't mean your
syntax will be usable by programmers without a significant amount of
work in learning it.

> In your opinion your professional "atoi" is better than my "ato_i"?

I'll only comment on the language features, if you don't mind. First,
ato_i is an awkward name to type. :-)

> /* assembly language with indentation and <9 instruction for line
> /* that someone say "it is 100% wrong"
> /* int cf(void);

I assume that /* begins a comment and a line break ends it? That's a
break from convention where /* is expected to be paired with */. You're
looking at some confusing syntax errors if you don't allow that.

> _cf: a=0; a++=0; ret

In general, multi-line statements should be avoided except for closely
related operations. Also, it's generally accepted that whitespace
between tokens aids readability. In this case, it would be much more
readable as:

_cf:
a = 0;
a++ = 0;
ret

Now, are you using a++ as a = a + 1? Or does it do something different?
If you're using it in the C manner, your code is wrong because it
assigns 0 to a twice, not to a and a+1. If you want the latter, you
need to use ++a = 0.

> /* eax __stdcall ato_i(char* string, char* pos)
> /* 0 i, 4 r, 8 c, 12 b, 16 Ra, 20 string, 24 pos
> ato_i:
> < b, c, r, i

What does the < operator do?

> << @string=[s+20], @pos=[s+24]

What does the << operator do? What does the @ prefix do? I'll assume
that @ is a local label designation for data.

> i=(a)string; c=0; #.c1; /* in c il segno

Are you using i as an index, or a character, or a pointer to the
string? What does # do? Presumably it's an unconditional jump.

> .c0: ++i; .c1: B*i==' '#.c0; B*i==9#.c0;

Bunching up multiple labels on one line is a bad thing in my opinion.
Multiple instructions if they're closely related, but never multiple
labels. What does B* mean?

> B*i=='+'!#.c2 | ++i; #.c3;

What does a ! prefix on a jump mean? What about the | operator? Don't
you use a semicolon to separate statements?

> .c2: B*i=='-'!#.c3 | ++i; ++c;
> .c3: B*i>'9' #.ce;
> B*i<'0' #.ce;
> #.c5;
> .ce: a=(a)pos; r=(a)string; *a=r; a=0; #.ca;

It seems you use * for dereferencing a pointer, and you use the comma
operator like C does, but that opens up new questions about your use of
other operators such as @.

> .c4: ++i; .c5: B*i=='0'#.c4
> a=0; b=0;
> .c6: bl=*i;
> bl>'9'#.c8
> bl<'0'#.c8
> mul D*dieci| r#.ci /* in ci +/-oo

Wait, where did dieci come from? And what's the r prefix for a jump?
Assuming it's a jump. What does D* mean?

> b-='0'; a+=b| jc .ci
> a&0x80000000 | jnz .ci

And now you'er using conditional jump instructions familiar to an
assembly programmer. That's a sudden change. Lack of consistency is
murder for any language.

> ++i; #.c6;
> .ci: a=0x7FFFFFFF; r=1;
> .c7: ++i; bl=*i; bl>'9'#.a0;
> bl<'0'#.a0; #.c7
> .c8: r=0;
> .a0: c==0#.c9; neg a
> .c9: b=(a)pos; *b=i;
> r!=0!#.ca; stc; #.cf
> .ca: clc;
> .cf:
> >> @string, @pos
> > b, c, r, i
> ret 8

All in all, I find your syntax ugly, and the formatting you use doesn't
help that at all. Two things promote a good language: 1) Consistent
syntax and semantics and 2) Encouragement of a readable format.

You don't seem to have a consistent syntax, and I'm not sure about
semantics. But if everything is consistent, it makes learning the
language and using it effectively much easier. If your language syntax
encourages sloppy code, people will write sloppy code. That's a problem
I've seen with assembly, and with C, to a certain extent with C++, and
most definitely with Perl. It takes considerable discipline to avoid
write-only code, but you can go a long way toward fixing that by
considering how people will use your syntax and setting a good example
through design and practice. A good comparison in that respect is Perl
and Python. Perl encourages sloppy code and Python encourages the
opposite. This seeps through the design itself, so Perl programmers
have to train themselves to write Perl with discipline, but Python
programmers get the same effect with far less work.

From: Frank Kotler on
?a\/b wrote:
> I'm a hobby programmer (tipicaly 2-3 hours of programming for day)
> How it is possible that in a language definited 100% wrong i a poor
> beginner can write something like this?

Because you wrote the language! (Is this not obvious to you???)

English is not your native language, yet you speak (write) English when
you post. Why is that? English isn't any "better" than your native
language, it's just more commonly understood. If you were a resident of
a country with a population of one, so that you were the *only* one who
spoke your native language, would you post in it? I'd consider it pretty
rude to do so! That's what you're doing with your made-up "assembly
language"!

Best,
Frank
From: ?a/b on
On 05 Apr 2006 11:34:58 GMT, Betov <betov(a)free.fr> wrote:
>"a\\/b" <al(a)f.g>news:8q873299e66khsj6s31pdsopn8b6mtfsl8(a)4ax.com:
>> I'm a hobby programmer (tipicaly 2-3 hours of programming for day)
>> How it is possible that in a language definited 100% wrong i a poor
>> beginner can write something like this?
>> In your opinion your professional "atoi" is better than my "ato_i"?
>> /* assembly language with indentation and <9 instruction for line
>> /* that someone say "it is 100% wrong"
>> /* int cf(void);
>> _cf: a=0; a++=0; ret
>>
>> /* eax __stdcall ato_i(char* string, char* pos)
>> /* 0 i, 4 r, 8 c, 12 b, 16 Ra, 20 string, 24 pos
>> ato_i:
>> < b, c, r, i
>> << @string=[s+20], @pos=[s+24]
>> i=(a)string; c=0; #.c1; /* in c il segno
>> .c0: ++i; .c1: B*i==' '#.c0; B*i==9#.c0;
>
>Well, this question has already been addressed several time...
>
>* "atoi" or "ato_i", or whatever are utterly un-acceptable.
>
> If this is for switching from Ascii to Integer, the name
> must be "AsciiToInteger", and nothing else.

ok, ok AsciiToInt

> If this is for
> switching from Decimal-Ascii to the EAX Register, the Name is
> DecimalAsciiToEax and nothing else,

but in assembly, in C and perhaps in *many others* programming
language eax (90% of time i have seen) is "what the function return"

>and so on... The words
> are in any english Dictionary and there is no reason for
> inventing any new one, that a beginner would have to _LEARN_,
> before using.

ok

>* The readability of lines like the last one is, so to say,
> negative:

>> .c0: ++i; .c1: B*i==' '#.c0; B*i==9#.c0;
^ label ^ label ^jmp ^jmp

i could to write there too
..c0: ++i; .c1: B*i==' '#.c0; B*i==9#.c0; B*i==10#.c0;
for spaces={' ', '\t', '\n'}

>Well, we can guess that ".c0:" is a Pseudo Local Label.

yes; it should be a local label (not pseudo i think)
when there are ":" are labels when there is "#" are jump to label
if there is an error and i type "B*i==' '#.c0:" assembler say
note ^
"error: invalid combination of opcode and operands"
and so for many type errors. i have found 0% type error until now,
when use it

>So
>should therefore be ".c1:"(?). But what with the other two
>".c0"s, preceded by some "#",

that is the jump character

>this does evidently not belong
>to any known Assembly syntax, and, therefore requires, first
>-before even trying to read 1) An acception of the Syntax,
>2) a serious study of the Syntax. Which is absurd vaste of time,
>as long as we already have one, which, even if considered bad
>by some very particular fellows, like Herbert, has, at least,
>the advantage of being generaly read by all Asmers.

you think that the power is in how many people write in a language?
It is not; the clue is what a language can do in the reality
if there is "something to show"

>Then, what does "++i" mean?

"inc esi"

>Then, in the second "B*i==" , what is the value of "B", and what
>is "B" (Stack // Data // Code ???!!!...). What is the meaning
>of "=="?

"B" means "byte", [ "D" means "dword", "W" means "word" etc]
*i means [esi],

i write many times cmp\jmp in one instruction

"B*i==' '#.c0;" <-> "cmp byte[esi], ' '
je .c0
"
because it is easy
(i can write "B[i]<>' '; je .c0" or "B*i<>' '; je .c0" too)
the idea is write a language that is
"letters""points""letters""points" etc;
where points are {+,-, =, ==, #, <, >, >=, <=, ^=, |=, &, &= etc}
because it is more easy to look for the eye and it is easy to
implement too (in the way not hide something)

>Then, in Assembly, comments are ";", not separators. And so on...

*wrong* ";" is a wonderful char for separate instruction when eyes
look (especially "instruction; instruction; ")

>Then writing multiple Statements on a single Line -which is a
>very good thing, massively encreasing the readability- requires
>having separators, which are very visible so that the readers'
>eyes, could detects the lines parts, at first sight.

it is ";" for me. "; " is "very visible"

>Here, this
>is the opposite: You have first to do the absurd effort for
>searching where the Instructions are. Scaring.

no i know where are the compare instructions, where are the branch,
where are instructions and what they means at first look
(in 2 seconds)

more i see it, more i think "how it is easy" and "how is nice"
typically i write a function in that language (easily more than others
languages and in less time) than i have some errors at first time
point out from nasmw compiler, i correct them soon,
than i have some showy errors in the run time
i correct them in "10 minutes" with the debugger
and all goes well for ever (80% of times).

i think that there is a door to break in the assembly area
it is the door for make assembly *easy*

the close door is: jump instructions are not for structured
programming; more instructions for line are not good, why indentation
in assembly?

>In short, as you have been told many times, inventing private
>Syntaxes like yours may be programming fun, but is definitively
>absurd to try to inflict to the other, as long as you will
>always be the only one able to read this.

that language is easy to follow, readable 100% (for who know it, me at
last)

if all this is false how i, a poor beginner, can write that "ato_i"
routine? (seems to me many time better than any "atoi" routine by
professional programmers) and this should be one fact

and this could repeat for the routines that all you like
if there is some small routine, mine will be better until
i'm a nobody in programming area and any of you could turn off my
little pc forever. my language is assembly and it is **easy**
(at last for me)

>The next step would be
>to replace the Chars with Chineese drawings, and the Digits by
>true arabian Digits, in some Unicode Format.
>
>;)
>
>Betov.
>
>< http://rosasm.org >