News:

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

Check if signs a crosshatch

Started by ragdog, November 15, 2008, 09:44:57 PM

Previous topic - Next topic

KeepingRealBusy

ragdog,

One question about the validity of the two characters. As displayed, you have AB CD EF ... Does this mean that the characters must be AB CD EF, or just alphabetic, or upper case alphabetic, or just any character? If they can be any character, can they be '#"?

Dave.

ragdog

This AB CD EF is a any character is relativ
I can also make 12 34 56 75...

This problem is only the separator (#) this must be in 3,6,9,12 .......... signs of the string


KeepingRealBusy

If it could be any character, then #b#c#### would also be valid (split into #b# c## and ##, the first and second character any character, the third character '#' or null).

qWord

Quote from: ragdog on November 16, 2008, 01:50:36 PM
This AB CD EF is a any character is relativ
I can also make 12 34 56 75...

This problem is only the separator (#) this must be in 3,6,9,12 .......... signs of the string

so, the last character in string can also be a crosshatch ?

if so, my routine does the job:


; return: TRUE or FALSE
IsCorrectFormat proc uses ebx edi esi lpBuffer:DWORD

    mov edx,lpBuffer
    movzx eax,BYTE ptr [edx]
    cmp eax,023h                ; position 1 not allowed for a crosshatch
    je @False                   ;
    xor ecx,ecx
    xor ebx,ebx
    mov edi,1
    xor esi,esi
   
    jmp @w
    ;align 16
    @@: lea edx,[edx+1]
        movzx eax,BYTE ptr [edx]
        xor ebx,ebx
    @w: test eax,eax
        jz @F
        mov eax,-1
        cmp ecx,2
        cmovl ebx,edi
        cmove ecx,eax
        cmp eax,023h ;'#'
        cmove esi,edi
        lea ebx,[ebx+esi]
        cmp ebx,2
        lea ecx,[ecx+1]
        jne @B
    @False:   
        xor eax,eax
        ret
    @@:
    mov edx,1           ;  if the last char. is a crosshatch or termination-zero -> TRUE
    xor eax,eax         ;  else -> FALSE
    cmp ecx,2           ;
    cmove eax,edx       ;
    cmp ecx,0           ;
    cmove eax,edx       ;

    ret

IsCorrectFormat endp
FPU in a trice: SmplMath
It's that simple!

ragdog

Quoteso, the last character in string can also be a crosshatch ?

No only the 3,6,9,12....... is a # in the string not the last

AB#CD#EF#GH#IJ#KL#NO# ............................
    3    6    9    12  15  18  21  24................................

This AB CD.... is relative Char

qWord

ragdog,

confirm or correct the following assumptions:
- a crosshatch is a separator
- a "separator" separates two expressions
- a expression is two bytes long and can consist of any character except the separator
- if there is only one expression in your string,no separator is needed
- if there are two expressions in your string, only one separator is needed
- if there are N expressions, you need N-1 separators
- so a separator can not be the first or the last character in string
FPU in a trice: SmplMath
It's that simple!

ragdog

 :bg

This is correct

- a crosshatch is a separator
- a "separator" separates two expression
- a expression is two bytes long and can consist of any character except the separator
- so a separator can not be the first or the last character in string

Correct format is:

AB
AB#CD
AB#CD#EF
AB#CD#EF#GH
...
...
.

wrong Format is
#CD
A#BC
...
..

The 3te,6,9,12 .... must be a (#) separator



qWord

ragdog,

AFAIKs, that's exactly what the routine from my first post does  :P

regards qWord

FPU in a trice: SmplMath
It's that simple!

ragdog

No

this is a wrong format AB-CD#EF.  by you routine is correct.

Try from drunk_sinsi  routine this works correct

qWord

your right - sorry

i confused my self with all these conditional mov's  :bg

her is my corrected version (i hope so  :bg)


; return: TRUE or FALSE
IsCorrectFormat proc uses ebx edi esi lpBuffer:DWORD

    mov edx,lpBuffer
    movzx eax,BYTE ptr [edx]
    xor ecx,ecx
    xor ebx,ebx
    mov edi,1
   
    jmp @w
    ;align 16
    @@: lea edx,[edx+1]
        xor ebx,ebx
        movzx eax,BYTE ptr [edx]

    @w: test eax,eax
        jz @F
        mov esi,-1
        cmp ecx,2
        cmove ebx,edi
        cmove ecx,esi
        xor esi,esi
        cmp eax,023h ;"#"
        cmove esi,edi
        lea ebx,[ebx+esi]
        cmp ebx,1
        lea ecx,[ecx+1]
        jne @B
       
        xor eax,eax
        ret
    @@:
    mov edx,1
    xor eax,eax
    cmp ecx,2
    cmove eax,edx

    ret

IsCorrectFormat endp


regards, qWord

EDIT: I've optimize it a bit
FPU in a trice: SmplMath
It's that simple!