Re: delete bytes




almas wrote:
Hi everybody.

Now, my aim is to kill bytes 21h to 2Fh.
I found a solution : un first i change them into ~
Next step destroy thooses bytes.

Note : if i just have ONE ascii in range 21h-2Fh ; i keep it
If i find after such ascii an other one, i just keep one.
It can be first or the last, i do not care.

Wolfgang gave a part of code,
but i did not understood.

I may have expressed myself too complicated, so you stumbled
into one of the many newbie traps ... :)
Your problem is that you try it with a single pointer,
but in fact you need two pointers. Watch this example:

0123456789abcdef.... ;character offset in buffer
Hello Shitheads! ;containing some text

Now I remove(kill) all 'h':

MOV CX,BufferSize ;have 16 in here yet
MOV SI,start_of _buffer
MOV DI,SI ;as well
L0:
MOV AL,[SI] ; AL="H" in first iteration
;CMP... ; filter + branch ...
;CMP AL,[SI+1] ; this is what you may want
;JZ remove ;
;jmp short keep ;
CMP AL,"h"
JZ remove
Keep:
MOV [DI],AL
INC DI
Remove: ;'remove' just dont write it back nor INC DI
INC SI
LOOP L0
MOV CX,BufferSize ;calc new size
ADD CX,DI
SUB CX,SI ;CX holds now the new size (14 now)

and after this the buffer changed:
0123456789abcdef.... ;character offset in buffer
Hello Siteads!s! ;containing shorter text yet
^^- still in there but ignored now

My solution can work on file above 64Kb
...but sometimes, i have to run again the program to sure all is OK.

In that case I'd use a circular buffer, but lets take one step
after the other yet ...

__
wolfgang
For those who see "not at all optimised" code here
take my apology, it's just an attempt to explain ... :)


.


Quantcast