## News:

Message to All Guests
NB: Posting URL's See here: Posted URL Change

## Recent posts

#1
##### The Laboratory / Re: Trimming spaces and tabs i...
Last post by NoCforMe - June 19, 2024, 07:01:08 AM
Thanks! Great explanation.
#2
##### The Laboratory / Re: Trimming spaces and tabs i...
Last post by Vortex - June 19, 2024, 06:36:19 AM
Hi NoCforMe,

`    xor    al,32 ; XORing al with 32 has two results : zero or another value    mov    ah,al ; copy al to ah    xor    al,41 ; To get back the original value of al, we can do again xor al,32. This would be followed by                    xor al,9. Combined XOR operations removes the extra second xor al,32  : 32 xor 9 = 41                   xor ( xor al,32 ) , 9 = xor al,41                   XORing al with 41 has two results : zero or another value    and    ah,al ; This and operation will reduce the number of results ( ah and al ) to one :                   The possible combinations :                   ah=0 , al=non-zero , and ah,al -> 0                   ah=non-zero , al=0 , and ah,al -> 0                   ah=non-zero , al=non-zero , and ah,al -> non-zero    add    ah,0FFh ; if (and ah,al) = 0 => 0+255 = 255 = > the carry flag is zero.                      if (and ah,al) = non-zero => <non-zero value> + 255 will cause an overflow setting the                      carry flag to 1    adc    edx,0   ; Carry flag = 0 => the original value of al was 32 or 9 and they should be bypassed with                      the condition carry flag=0 : edx + 0 + carry flag 0 = edx                   ; Carry flag = 1 => the original value of al was not 32 or 9 and this character should be                      preserved in the buffer pointed by edx : edx + 0 + carry flag 1 = edx+1    cmp    al,9    ; After the previous operations xor al,32 and xor al,41, the NULL terminator is converted to                     ASCII 9    jne    @b      ; If al!=9 the go to return back to the beginning of the loop.`
#3
##### The Laboratory / Re: Trimming spaces and tabs i...
Last post by NoCforMe - June 19, 2024, 06:02:51 AM
So can you explain to us how this works?
`    xor    al,32    mov    ah,al    xor    al,41    and    ah,al    add    ah,0FFh    adc    edx,0    cmp    al,9    jne    @b`It may be obvious to you, but it sure isn't to me.
#4
##### The Laboratory / Re: Trimming spaces and tabs i...
Last post by Vortex - June 19, 2024, 04:51:36 AM
Another version :

- Removed conditional setnz instructions.
- No need of ebx.

`include     RemoveSpaces.inc.datamystr       db '    This    Is   A       Test String.',0msg         db '%s',13,10,'Lenght of string = %u',0.data?buffer      db 256 dup(?)buffer2     db 32 dup(?).codeRemoveSpaces PROC str1:DWORD,buff:DWORD    mov     ecx,str1    mov     edx,buff@@:    movzx   eax,BYTE PTR [ecx]    mov     BYTE PTR [edx],al    add     ecx,1    xor     al,32    mov     ah,al    xor     al,41    and     ah,al    add     ah,0FFh    adc     edx,0    cmp     al,9    jne     @bfinish:    mov     eax,edx    sub     eax,buff    retRemoveSpaces ENDPstart:    invoke  RemoveSpaces,ADDR mystr,ADDR buffer    invoke  wsprintf,ADDR buffer2,\            ADDR msg,ADDR buffer,eax    invoke  StdOut,ADDR buffer2    invoke  ExitProcess,0END start`
#5
##### The Laboratory / Re: Trimming spaces and tabs i...
Last post by sudoku - June 18, 2024, 09:51:55 PM
Quote from: TimoVJL on June 18, 2024, 09:06:29 PMAlso is an as a linux as or windows as.exe ?
You do have a sense of humor.
No, not using "as" as assembler here.    therefore I am not assembling said clam.
#6
##### The Laboratory / Re: Trimming spaces and tabs i...
Last post by TimoVJL - June 18, 2024, 09:06:29 PM
Quote from: sudoku on June 18, 2024, 09:10:58 AM
Quote from: NoCforMe on June 18, 2024, 09:07:37 AMHappy?
As a clam.
is clam clam.s or clam.asm ?
Also is an as a linux as or windows as.exe ?
#7
##### The Laboratory / Re: Trimming spaces and tabs i...
Last post by sudoku - June 18, 2024, 09:10:58 AM
#8
##### The Laboratory / Re: Trimming spaces and tabs i...
Last post by NoCforMe - June 18, 2024, 09:07:37 AM
Nope, I missed that.
Modified my code above to return the trimmed length.
Happy?
#9
##### The Laboratory / Re: Trimming spaces and tabs i...
Last post by sudoku - June 18, 2024, 09:04:06 AM
Quote from: NoCforMe on June 18, 2024, 09:01:26 AMSez who? I don't remember seeing that as one of the requirements for this function.
I guess that you didn't really look too hard at Vortex's code.

From example 1
`finish:    mov     eax,edi    sub     eax,1    sub     eax,buff ; <---- here    ret`

from example 2
`finish:    mov    eax,edx    sub    eax,1    sub    eax,buff ; <---- here    ret`
#10
##### The Laboratory / Re: Trimming spaces and tabs i...
Last post by NoCforMe - June 18, 2024, 09:01:26 AM
Quote from: sudoku on June 18, 2024, 07:42:16 AMNoCforMe and jj2007, what is the value in eax when your code finishes?
It's AL = last character seen, the rest "undefined".
QuoteIt should contain the length of the string after processing (sans spaces and/or tabs).
Sez who? I don't remember seeing that as one of the requirements for this function.