News:

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

Need help with a parser

Started by ragdog, November 21, 2009, 05:09:16 PM

Previous topic - Next topic

ragdog

Hi

I need help with my parser.

Input   ab/--/bc/--/--/df   <<< this format is relativ with this alphabet this can contain numbers
output 010110        << set all "--" a on 1 and all alphabet or number a one 0



   pushad
      mov  esi, lpszInput
      mov  edi, lpszOut

   @@:
      mov  al, [esi]
      inc  esi

      cmp  al, '-'   
       je  @Rep
      cmp  al, '/'
       je  @B
      mov  al, '0'
      mov  [edi],al
      inc  esi
      inc  edi
     test  al, al     ; is AL zero
      jnz  @B
      jmp  @Out
@Rep:
      mov  al, '1'
      mov  [edi],al
      inc  edi
      inc  esi

      jmp  @B
@Out:
    popad


I hope you understand this

Greets

RuiLoureiro

Quote from: ragdog on November 21, 2009, 05:09:16 PM
Hi

I need help with my parser.

Input   ab/--/bc/--/--/df   <<< this format is relativ with this alphabet this can contain numbers
output 010110        << set all "--" a on 1 and all alphabet or number a one 0



   pushad
      mov  esi, lpszInput
      mov  edi, lpszOut

   @@:
      mov  al, [esi]
      inc  esi

      cmp  al, '-'   
       je  @Rep
      cmp  al, '/'
       je  @B
      ;mov  al, '0'
      mov  [edi],'0'   ;Al
      inc  esi
      inc  edi
     test  al, al     ; is AL zero  WHAT al ???
      jnz  @B
      jmp  @Out
@Rep:
      mov  al, '1'
      mov  [edi],al
      inc  edi
      inc  esi

      jmp  @B
@Out:
    popad


               i hope this help you 
Rui    

ragdog

I have test it and i have a error with this

A2070: invalid instruction operands

mov  [edi],'0'   ;Al

I think i must put the 0 to al?

dedndave

that instruction has no size
you may need

        mov byte ptr [edi],'0'

so the assembler knows it is a byte instead of a word or dword

RuiLoureiro

Quote from: ragdog on November 21, 2009, 05:59:21 PM
I have test it and i have a error with this

A2070: invalid instruction operands

mov  [edi],'0'   ;Al

I think i must put the 0 to al?
No, you can do       mov    ah, '0'   and   mov [edi], ah

ragdog

yes use i this mov [edi], '0' become i this error by compile

hmm

And use i

mov  al, '0'
mov [edi], al

Have i a program crash here

0040115F    8A06            MOV AL,BYTE PTR DS:[ESI]

DS:[00BD1000]=???
AL=30 ('0')



ragdog

Hey dedndave


Thanks this works fine :U

Slugsnack

Quote from: RuiLoureiro on November 21, 2009, 06:04:08 PM
Quote from: ragdog on November 21, 2009, 05:59:21 PM
I have test it and i have a error with this

A2070: invalid instruction operands

mov  [edi],'0'   ;Al

I think i must put the 0 to al?
                 No, you can do       mov    ah, '0'   and   mov [edi], ah
In both of those examples the size is implicitly expressed. A character is 1 byte, ah is also 1 byte

hutch--

The difference between ADDRESS and CONTENT is always worth understanding.

When you copy CONTENT you "mov" a given SIZE of data into a register or memory location of the SAME SIZE. That is in fact how the hardware works.

When you use the ADDRESS of a piece of data the data can be ANY SIZE because the ADDRESS in 32 bit is always a 32 bit integer (DWORD).

Now Dave has given the correct notation but there are a few things worth knowing.

BYTE  mov al, "x"  ; 1 ANSI character fits into a BYTE sized register.

The ADDRESS of a BYTE or WORD or DWORD or QWORD or OWORD all use the same notation as the ADDRESS in 32 bit is always 32 bits in size.

mov eax, BYTE PTR [edx+ecx*4+32]  ; address of a BYTE of data
mov eax, QWORD PTR [esi]   ; address of a 64 bit integer

etc .....

Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php