Re: All is right !
- From: "Wolfgang Kern" <nowhere@xxxxxxxx>
- Date: Tue, 22 Apr 2008 12:08:32 +0200
almas wrote:
Hello.
My aim : i want remove 2 bytes if they are equal.
So, it will reduce the size of the file.
If this way is easy, OK
____________________
For a single buffer:
If you like to reduce filesize then you need to adjust 'filesize',
calculate the trail-size and 'move' all trailing bytes to the now
free/unused position.
you then can use:
CLD
REP MOVSB ; es:[di]<-ds:[si] cx-times
or with discrete instructions ie:
....
xor bx,bx
L0: ;for single bytes
MOV al,[bx+si+1]
MOV [bx+si],al
INC bx
CMP bx, remaining
jbe L0
______
L0: ;if always two bytes were removed
MOV al,[bx+si+2]
MOV [bx+si],al
ADD bx,2
CMP bx, remaining
jbe L0
______
But I see you work with two buffers, so here it should be
lesser work:
You use SI as source-ptr, CX as counter and output_buf(ptr)
for destination, but there are more options available for
double base+index jobs ie:
[bx+di] ;uses DS:
[bp+si] ;uses SS: should be equal in a .COM
** I'm not sure if your tool got something silly with BP **
If the size you check on is more than one byte and variable too,
then LODSB may not be the best solution.
I'd use CX as the 'match'-count here then.
Your selfmodifying A3.... line is a smart attempt and may be
sometimes very useful, but perhaps just not right now :)
MOV DI,0192h ;(somewhere on top) may do quite well what you want.
You then can replace the 'CALL mycall' with a single byte STOSB
or perhaps with a more preferable (also just three bytes):
MOV [BX+DI],AL
INC BX
because this keeps DI at start and hold copied byte count in BX.
Then filter off all unwanted stuff and copy 'only' what shall
be in the destination buffer without altering the source.
__
wolfgang
If if the file have two bytes similars... and replace each byte by ~ , oran
other particular value : OK0'''0---"
Just the ascii to remove or replace have value from 22H to 2Fh
But, i discovered that i have also to remove bytes if i can find them 3
times or more.
So for 3 or more, it ca be letters.
The final aim is to have a file, and just keep the "Text-Ascii"
So by example : %% becomes ~ or ~ ~ or nothing !
%%% : do the same 1, 2, or 3 ~ or nothing
But now i identify if i have eee or sss or kkk remove into ~
Sure that in a french word, il will never find 3 sames letters.
I accept the risk of a " www.my_web.com "
Below, you can find the try. ( it is not usefull )
I built others versions... with out correct work.
mov ah,9
mov dx,offset tester ; display original characters
int 21h
mov cx,3Eh
mov si, offset tester
myloop:
lodsb
nop
nop
cmp al,22h
jb next ; scan ascii from 22h to 2Fh
cmp al,2Fh
ja next
cmp cx,1 ; take care about CX and the loop
jbe next
mov ah,al
lodsb
dec cx ; ajust SI and CX
cmp al,ah
jnz next
mov al,126
mov [si],al
call mycall
dec si
inc cx ; ajust SI and CX
xchg ah,al ; il will have the value "7E7Eh" in AX
next:
mov [si],al
call mycall
inc si
loop myloop
nop
nop
mov dx,offset tester
mov ah,9
int 21h
mov dx, offset here
int 21h
int 20h
mycall:
db: 0A3 ; will do mov [here],ax
out_put_buffer db: ,92h,01 ; will do A3 92 01
inc byte out_put_buffer
ret
tester db: "!0!!0###! 0##0%%0(((*()0**0))0++-+0--0>>0==0<<>=0<??¨?
db: ,10,13,36"
here db: "
db: ,10,13,360'''0---"
-------------- other version -------------
myloop:
lodsb
nop
cmp al,22h
jb next ; scan ascii from 22h to 2Fh
cmp al,2Fh
ja next
cmp ah,al
jnz next
mov al,126
mov [si],al
call mycall
dec si
inc cx
next:
mov [si],al
mov ah,al
call mycall
inc si
loop myloop
nop
mov dx,offset tester
mov ah,9
int 21h
mov dx, offset here
int 21h
int 20h
mycall:
db: 0A2h ; will do mov [here],al
out_put_buffer db: ,87h,01 ; will do A2 87 01 mov [here+?],al
inc byte out_put_buffer
ret
tester db: "!0!!0###! 0##0%%0(((*()0**0))0++-+0--0>>0==0<<>=0<??¨?
db: ,10,13,36"
here db: "
db: ,10,13,36
------- same result : do some thing, but.... not right ---
.
- References:
- All is right !
- From: almas
- Re: All is right !
- From: almas
- Re: All is right !
- From: Wolfgang Kern
- Re: All is right !
- From: almas
- Re: All is right !
- From: Wolfgang Kern
- Re: All is right !
- From: almas
- Re: All is right !
- From: Wolfgang Kern
- Re: All is right !
- From: Wolfgang Kern
- Re: All is right !
- From: almas
- Re: All is right !
- From: almas
- Re: All is right !
- From: Wolfgang Kern
- Re: All is right !
- From: almas
- Re: All is right !
- From: Wolfgang Kern
- Re: All is right !
- From: almas
- All is right !
- Prev by Date: Merit of callee-saved register
- Next by Date: Re: Merit of callee-saved register
- Previous by thread: Re: All is right !
- Next by thread: [OT] there is no assembly without good food and drink :))
- Index(es):
Relevant Pages
|