Re: Formatting in assembly




¬a\/b wrote:
main:
call 'msvcrt._write',1,msg1,D$msg1_len
call 'msvcrt._read',0,buf,blen

dec eax | mov D$n,eax

call atoi,buf,D$n
call itoa,result,eax,D$n
call 'msvcrt._write',1,result,D$n
ide_exit

msvcrt._write(1,msg1,D$msg1_len);
etc

....
/* if return 1 OK, if return 0 error
itoa:
j=[s+4]; a=[s+8]; c=[s+12]; b=10;
c<>1; <#.ce; =#.c5;
.c0: { r=0; div b; /* r=a%10, a=a/10
rl+='0'; *j=rl; ++j; a==0#.c2;
.c1: --c#.c0;
}
.c2: i=[s+4]; B*j=0; c==0#.ce; --j;
#.c4;
.c3: {al=*i; *j<->al; *i=al; --j; ++i;
.c4: i<j#.c3
}
a=1;#.cf;
.c5: B*j=0;
.ce: a=0
.cf:
ret

NOT TESTED

What language is that? :-)

for me this itoa seems wrong at last because don't end the string with
\0 and not has some return error code

There's no need to terminate the string with 0 if you don't intend to
use any code that expects such a sentinel, which I didn't.

.



Relevant Pages

  • Re: Macro2D
    ... õ1, eax", 0 ... db "push striIIi", NL ... db ".2: cmp edi, ebp", NL ... db ".4: mov eax, edi", NL ...
    (alt.lang.asm)
  • One RosAsm Pre-parser
    ... cmp eax 0 | ja L0<< ... mov ecx, D ...
    (alt.lang.asm)
  • Re: Fastcode Library Design
    ... cmp ecx, SMALLMOVESIZE ... lea edx, ... fild qword ptr [eax] ... mov ecx, ...
    (borland.public.delphi.language.basm)
  • Re: Macro2D
    ... mov, eax ... cmp eax, -1 ... push STD_INPUT_HANDLE ...
    (alt.lang.asm)
  • a problem in n5.dll in windows 95
    ... eax srandMl ... mov ebp, esp ... push dword @lpm ... mov esi, @adw ...
    (alt.lang.asm)