flat assembler
Message board for the users of flat assembler.

Index > Heap > Test.

Goto page Previous  1, 2, 3 ... 7, 8, 9, 10, 11  Next
Author
Thread Post new topic Reply to topic
MHajduk



Joined: 30 Mar 2006
Posts: 6034
Location: Poland
MHajduk
Laughing Cool
Post 23 Dec 2007, 12:03
View user's profile Send private message Visit poster's website Reply with quote
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1
I will consider it a promotion Wink
Now the thread is one level up Smile

Thanks Tomasz or should I thank Vid Confused

Smile

_________________
Code:
 o__=-
 )
(\
 /\  
    
Post 24 Dec 2007, 04:36
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Quote:

Thanks Tomasz or should I thank Vid

Pick one randomly, it is the same Laughing
Post 24 Dec 2007, 04:41
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17280
Location: In your JS exploiting you and your system
revolution
0.1 wrote:
Thanks Tomasz or should I thank Vid
Who is Vid? Maybe you mean vid? Wink

Also, I thought LocoDelAssembly moved this thread, but remember he can also delete it, so you had better be nice and thank him.
Post 24 Dec 2007, 04:53
View user's profile Send private message Visit poster's website Reply with quote
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1
*oops*
Thanks a lot Loco !
I almost forgot that you are also a moderator now !
Shocked

_________________
Code:
 o__=-
 )
(\
 /\  
    
Post 24 Dec 2007, 06:00
View user's profile Send private message Reply with quote
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1
Suppose I have a 64 bit number in edx:eax.
How do I print it?
Code:
mov edx, 0x70000000
mov eax, 0x00000007
; How to print it (on console)?
    


I tried it. I got it working for Hex format:
Code:
        format PE console
        entry start

        include 'win32a.inc'

        section '.code' code readable executable
start:
        mov edx, 0x70000000
        mov eax, 0x00000007

        push eax
        push edx
        push _fmt
        call [printf]
        add esp, 12

        ret

        section '.data' readable writable
_fmt db '%08x%08x',0

        section '.idata' import data readable
library msvcrt,'msvcrt.dll'

import msvcrt,\
       printf,'printf'
    

How to print it in Dec format?

_________________
Code:
 o__=-
 )
(\
 /\  
    
Post 24 Dec 2007, 09:37
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17280
Location: In your JS exploiting you and your system
revolution
0.1 wrote:
How to print it in Dec format?
Use 64 bit arithmetic. Here is some old code I found on my HDD:
Code:
_print_integer_64:
    ;edi:esi=integer
    or      edi,edi
     jns     .b
  not     edi
 neg     esi
 cmc
 adc     edi,0
       push    esi edi
     mov     al,'-'
    call    _print_char
 pop     edi esi
    .b:
_print_unsigned_64:
   test    edi,edi
     mov     eax,esi
     jz      _print_unsigned_32
  mov     edx,edi
     push    -1
    .a:       mov     ebp,0cccccccdh
      mov     ebx,edx
     mov     ecx,eax
     mul     ebp
 mov     edi,edx
     mov     eax,ebx
     mul     ebp
 add     edi,eax
     adc     edx,0
       mov     esi,edx
     sub     ebp,1
       mov     eax,ecx
     mul     ebp
 add     edi,eax
     adc     esi,edx
     mov     eax,ebx
     sbb     ebx,ebx
     mul     ebp
 add     eax,esi
     adc     edx,0
       sub     edx,ebx
     and     eax,-8
      sub     ecx,eax
     shrd    eax,edx,2
   shr     edx,2
       sub     ecx,eax ;ecx=remainder
      shrd    eax,edx,1
   shr     edx,1   ;edx:eax=quotient
       push    ecx
 jnz     .a
  jmp     _print_unsigned_32.entry64

_print_unsigned_32:
    ;eax=integer
       push    -1
    .entry64:
     mov     ebx,0cccccccdh
    .a:   mov     ecx,eax
     mul     ebx
 and     edx,-8
      mov     eax,edx
     sub     ecx,edx
     shr     edx,2
       sub     ecx,edx
     push    ecx
 shr     eax,3
       jnz     .a
  pop     eax
    .b:      add     al,'0'
    call    _print_char
 pop     eax
 test    al,10h
      jz      .b
  ret    
It uses edi:esi as the input but you can change that right?
Post 24 Dec 2007, 10:22
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Quote:
Suppose I have a 64 bit number in edx:eax.
How do I print it?

use latest FASMLIB Laughing
Post 24 Dec 2007, 10:49
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1
Prints wrong values Sad
Code:
        format PE console
        entry start

        include 'win32a.inc'

        section '.code' code readable executable
start:
        push esi
        push edi

        mov edx, 0x12345678
        mov eax, 0x9abcdef0

        push eax
        push edx
        push _fmt
        call [printf]
        add esp, 12

; This does not print it right Sad
        mov edi, 123456789
        mov esi, 987654321
        call _print_integer_64

        pop edi
        pop esi

        ret

_print_integer_64:
    ;edi:esi=integer
        or      edi,edi
        jns     .b
        not     edi
        neg     esi
        cmc
        adc     edi,0
        push    esi edi
        mov     al,'-'
        call    _print_char
        pop     edi esi
    .b:
_print_unsigned_64:
        test    edi,edi
        mov     eax,esi
        jz      _print_unsigned_32
        mov     edx,edi
        push    -1
    .a: mov     ebp,0cccccccdh
        mov     ebx,edx
        mov     ecx,eax
        mul     ebp
        mov     edi,edx
        mov     eax,ebx
        mul     ebp
        add     edi,eax
        adc     edx,0
        mov     esi,edx
        sub     ebp,1
        mov     eax,ecx
        mul     ebp
        add     edi,eax
        adc     esi,edx
        mov     eax,ebx
        sbb     ebx,ebx
        mul     ebp
        add     eax,esi
        adc     edx,0
        sub     edx,ebx
        and     eax,-8
        sub     ecx,eax
        shrd    eax,edx,2
        shr     edx,2
        sub     ecx,eax ;ecx=remainder
        shrd    eax,edx,1
        shr     edx,1   ;edx:eax=quotient
        push    ecx
        jnz     .a
        jmp     _print_unsigned_32.entry64

_print_unsigned_32:
    ;eax=integer
        push    -1
    .entry64:
        mov     ebx,0cccccccdh
    .a: mov     ecx,eax
        mul     ebx
        and     edx,-8
        mov     eax,edx
        sub     ecx,edx
        shr     edx,2
        sub     ecx,edx
        push    ecx
        shr     eax,3
        jnz     .a
        pop     eax
    .b: add     al,'0'
        call    _print_char
        pop     eax
        test    al,10h
        jz      .b
        ret

_print_char:
        push eax
; Oops I had this in my code. *embarrassed*
;        call putchar
        call [putchar]
        add esp, 4
        ret

        section '.data' readable writable
_fmt db '%08x%08x ',0

        section '.idata' import data readable
library msvcrt,'msvcrt.dll'

import msvcrt,\
       printf,'printf',\
       putchar,'putchar'

; Output:
; 123456789abcdef0 530242872211826865
    

PS: Thanks vid! But I never really felt a need to use fasmlib Shocked *biting my tounge*

_________________
Code:
 o__=-
 )
(\
 /\  
    


Last edited by 0.1 on 24 Dec 2007, 11:09; edited 2 times in total
Post 24 Dec 2007, 11:00
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17280
Location: In your JS exploiting you and your system
revolution
0.1: Your '_print_char' is broken.

edit: okay you saw it.

Also the value is printed correctly. What is 123456789*2^32+987654321?


Last edited by revolution on 24 Dec 2007, 11:09; edited 1 time in total
Post 24 Dec 2007, 11:06
View user's profile Send private message Visit poster's website Reply with quote
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1
Yeah! No complains from Windows! *damn* Corrected Wink
Post 24 Dec 2007, 11:08
View user's profile Send private message Reply with quote
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1
And by the way, why are you hidden?
Post 24 Dec 2007, 11:11
View user's profile Send private message Reply with quote
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1
revolution wrote:
0.1: Your '_print_char' is broken.

edit: okay you saw it.

Also the value is printed correctly. What is 123456789*2^32+987654321?

Errrrr Shocked *confused*
Why it was not:
Upper part in edi
Lower part in esi

edi:0000000000000000 well ... didn't count the Zer0es
-----------esi---------

_________________
Code:
 o__=-
 )
(\
 /\  
    
Post 24 Dec 2007, 11:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17280
Location: In your JS exploiting you and your system
revolution
0.1 wrote:
And by the way, why are you hidden?
I presume you mean me? I'm hidden because the site admin thinks I am too ugly to show myself.
Post 24 Dec 2007, 11:17
View user's profile Send private message Visit poster's website Reply with quote
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1
Of course you!
Post 24 Dec 2007, 11:21
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Quote:
Thanks vid! But I never really felt a need to use fasmlib *biting my tounge*

Or at least download it, and look at it's 64bit to ascii routines (src/conv/ext_q_dec.inc, src/conv/ext_q_hex.inc).
Post 24 Dec 2007, 11:36
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17280
Location: In your JS exploiting you and your system
revolution
I once tried to upload my photo but my computer exploded, so then I bought a stronger computer and tried again, but then my ISP exploded. After that I got worried about blowing up the planet, so I never tried again.
Post 24 Dec 2007, 11:38
View user's profile Send private message Visit poster's website Reply with quote
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1
Before even visiting the link to download, I am worried about the complexity of your code!
*biting my nails*
Post 24 Dec 2007, 11:46
View user's profile Send private message Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
0.1 wrote:
...why are you hidden?
revolution wrote:
...I'm hidden because the site admin thinks I am too ugly to show myself....

http://academic.reed.edu/humanities/110Tech/BodyLanguage/html/diskobolos1.html
note the disk soon to be revolving.

vid, reassuring 0.1 on the facility of using the downloaded 64 bit to ascii routines:
http://academic.reed.edu/humanities/110Tech/BodyLanguage/html/doryphoros1.html
Smile
Post 24 Dec 2007, 12:37
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Quote:
Before even visiting the link to download, I am worried about the complexity of your code!
*biting my nails*

Those two routines aren't THAT complex. They have quite rich interface (support limiting size of output buffer, support padding with '0' or ' '), but good thing is that they don't call anything else. I think copy-pasting to your code would work fine. Just give it a try Razz
Post 24 Dec 2007, 12:40
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3 ... 7, 8, 9, 10, 11  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.