delete bytes



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.
My solution can work on file above 64Kb
....but sometimes, i have to run again the program to sure all is OK.


If somebody have a good idea, i will appreciate.
Regards
Almas


; suppose that i pu the file name at address si=82h
; and put it at offset inbuff

gotfile:
mov ax,3d12h ; open file R/W/NO SHARE
mov dx,offset inbuff ;filename
int 21h
fopok: xchg ax,bx ; handle ; it just cost 1 byte :-)
mov word [bytes],256 ; buffer size
; i just read buffers of 256 bytes
; and repeat, and repeat again...

readlop:
mov ah,3fh ; read file ; mov bx,[filehandle]
mov cx,[bytes] ; read buffer full
mov dx,offset address ; buffer
int 21h
cmp ax,0 ;nothing read ? (end of file)
ja main
jmp quit

main:
mov [bytes],ax ;bytes read, usefull if AX < [bytes]
mov cx,ax ;counter
mov si,address ;file buffer

mloop:
mov al,[si]
do_again:
; ; here i change many values
; ; example É becomes e
; ; or [ ' ] becomes [ 27h ]
cmp al,0Dh
jz lettre ; i do not remote it
cmp al,0Dh
jz lettre

cmp al,1Fh
ja suivre

met126:
mov al,126 ; i put ~
jmp short lettre

suivre:
cmp al,7Fh ; i keep low cases
jb lettre
jmp short met126


lettre:
jmp short let_trer
apostrophe: mov al,27h ; example i had ['] it becomes (27h)

boukl:
mov [si],al
inc si
end_loop:
loop mloop ; test 256 bytes, it could be 16 Kb
jmp short encore


; ---------------- the part i add

let_trer: ; detect particular ascii
cmp al,21h
jb boukl
cmp al,2Fh
ja boukl

mov [si],al ; save value
cmp cx,1
jz end_loop ; be sure the loop will be correct
dec cx

inc si
mov al,[si] ; have i again a particular ascii ?
cmp al,21h
jb do_again0

cmp al,2Fh
ja do_again0

dec si
inc cx
mov byte [si],126 ; kill value of byte before

inc si
dec cx

mov al,[si]

do_again0:
jmp do_again

; ----------------------- end of the part i add

encore:
mov ax,4200h ; seek set file position ;offset beginning
mov cx,[count1] ; most significant part of offset
mov dx,[offset count2] ; least significant part of offset
int 21h

mov cx,[bytes] ;get offset size
mov dx,[offset count1] ; most significant part
mov ax,[count2] ; least significant part
add ax,cx ;add offset to least sig part
adc dx,0 ;add with carry
mov [offset count1],dx ;save them back for next loop
mov [count2],ax

mov ah,40h ; write to file mov bx,[filehandle]
mov dx,offset address ; buffer
int 21h
cmp word [bytes],256 ; less than 256 bytes left ?
jb quit ; yeahh, must be last read
jmp short readlop ; noo, go on reading

quit: ; cmp word [filehandle],0 ;any filehandle
mov ah,3eh ; closef
int 21h


nofile:
int 20h

bytes dw ,100h ; size buffer 100h or more ...
filesize: db: 0,0
filehandle dw 0,0
count1 dw 0,0
count2 dw 0,0
inbuff: db: 0,0,0,0 ,0,0,0,0 ,0,0,0,0 ,0 ; file name
address: db: 0,0


.



Relevant Pages