flat assembler
Message board for the users of flat assembler.

Index > Main > bytes in an array

Author
Thread Post new topic Reply to topic
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost 24 May 2005, 15:17
if szMessage was 'abc'
and i wanted to push a certain character from that string
how would i go about that?

in c it would be szMessage[0], if i wanted the 'a'
Post 24 May 2005, 15:17
View user's profile Send private message AIM Address MSN Messenger Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: US
coconut 24 May 2005, 16:02
not sure but try something like

cmp byte [szMessage+1] ,'a'
Post 24 May 2005, 16:02
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 24 May 2005, 16:30
Or you can do something like this:
Code:
    mov   ecx, 0; or any character wanted.
    mov   al, [szMessage + ecx] ;get first character, position 0.
    ;this method allows you to loop though the characters.    


You did say push, so:
Code:
    mov   ecx, 2; or any character wanted
    mov   al, [szMessage + ecx] ;get third character, position 2.
    push  eax  ;ALWAYS, push a DWORD sized value on the stack.
    pop   eax ;restores char in AL. and also preserves AH
    ;this method also allows you to loop though the characters    
Post 24 May 2005, 16:30
View user's profile Send private message Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost 24 May 2005, 18:22
coconut wrote:
not sure but try something like

cmp byte [szMessage+1] ,'a'


yeah you can compare or replace them that way

madmatt wrote:
Or you can do something like this:
Code:
    mov   ecx, 0; or any character wanted.
    mov   al, [szMessage + ecx] ;get first character, position 0.
    ;this method allows you to loop though the characters.    


You did say push, so:
Code:
    mov   ecx, 2; or any character wanted
    mov   al, [szMessage + ecx] ;get third character, position 2.
    push  eax  ;ALWAYS, push a DWORD sized value on the stack.
    pop   eax ;restores char in AL. and also preserves AH
    ;this method also allows you to loop though the characters    



thanks alot, and yeah thats exactly what i was trying to do (loop thru em)
Post 24 May 2005, 18:22
View user's profile Send private message AIM Address MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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 cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.