News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Display one byte in decimal form to console window?

Started by joemc, March 01, 2010, 04:00:11 AM

Previous topic - Next topic

joemc

in C++
    char buffer[513]
    int len=recv(Socket,buffer,512,0);
    for(int i=0;len>i;++i)
        std::cout << (int)buffer[i]<<' ';


all i can figure out in masm:

invoke recv, sock,addr Buffer,512,0
print str$()


the loop part not really important. may be should of left out.  i just need to know how to get 1 byte and print it
should i take it into a register and than shift it around?


dedndave

unsigned

        mov     edx,offset Buffer
        mov     ecx,512

loop00: movzx   eax,byte ptr [edx]
        push    ecx
        push    edx
        print   ustr$(eax),32
        pop     edx
        inc     edx
        pop     ecx
        dec     ecx
        jnz     loop00

signed

        mov     edx,offset Buffer
        mov     ecx,512

loop00: movsx   eax,byte ptr [edx]
        push    ecx
        push    edx
        print   str$(eax),32
        pop     edx
        inc     edx
        pop     ecx
        dec     ecx
        jnz     loop00

i put a space between the numbers

joemc

Quote from: dedndave on March 01, 2010, 04:21:54 AM
unsigned

        mov     edx,offset Buffer
        mov     ecx,512

loop00: movzx   eax,byte ptr [edx]
        push    ecx
        push    edx
        print   ustr$(eax),32
        pop     edx
        inc     edx
        pop     ecx
        dec     ecx
        jnz     loop00

signed

        mov     edx,offset Buffer
        mov     ecx,512

loop00: movsx   eax,byte ptr [edx]
        push    ecx
        push    edx
        print   str$(eax),32
        pop     edx
        inc     edx
        pop     ecx
        dec     ecx
        jnz     loop00

i put a space between the numbers

awesome thanks