Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

remplace text
Hi every body.
I have a text.... many lines, end of line is OD OA
I want to change the beginig of each line
the first 5 bytes remplaced by   "¿"

Below my code... sorry it is not OK
Who have an idea ?

I use DOS  Operating System    compiler is A86

mov   si,0080h
lodsb
cbw                   ;extend AL to AX
xchg  bx,ax           ;swap size to bx for indexing
mov   byte [bx+si],0  ;null terminate command line
mov   di,inbuff       ;our buffer
; dospc: cmp   byte [si],32   ;any leading spaces ? ; jne nospc ;nooo
inc   si              ;yeahh, dump it ; jmp  dospc ;check next
nospc: mov   cx,1                   ;we're here, so we got one arg
copy1: lodsb                        ;load byte SI to AL
cmp   al,0                  ;0 ?(end of line)
je   done                   ;yeahh
stosb                     ;noo, move AL to DI, incrase DI
jmp short  copy1            ;go on
done:  mov   byte [di],0    ;null terminate END of PARSE
gotfile:
mov   ax,3d12h              ; open file  READ/WRITE/NO SHARE
mov   dx,offset inbuff      ;filename
int   21h

fopok: xchg ax,bx
; ; handle ; mov word [bytes],256 ; buffer size
; ; NOTE BX will not change  I put value 0 into count 1 and 2
; ; xor ax,ax ; mov offset count1,ax ; clear out ; mov offset count2,ax

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               ;nooo, do the work
jmp short  quit         ;yeahh, we're done
main:
mov   [bytes],ax        ;bytes read
mov   cx,ax             ;counter
mov   si,address        ;file buffer

push cx
mov cx,5               ; i want to remplace 5 bytes by ¨
push bx                ; save the handle
xor bx,bx              ; will be used like counter

mloop:
lodsw
inc bx                 ; count
inc bx
cmp ax,0D0Ah            ; is it end of line ?
jz mloop
lodsb
inc bx
cmp al,0Dh
jz mon0a
mov byte si,0A8h         ; new line, then remplace by ¨
lodsb
inc bx
mon0a:
cmp al,0Ah
jz mloop
mov byte si, 0A8h          ; again change with ¨
loop mloop
pop cx
sub cx,bx                  ; resize  file buffer
pop bx                     ; restore handle

mov ax,4200h                     ; s set file position 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]  ;the most significant part
mov  ax,[count2]         ;the 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             ; close file
int   21h
nofile: ret                      ; int   20h

; DATA
bytes        dw   ,100h ; size buffer for file
filesize:    db:   0,0
filehandle   dw    0,0
count1       dw    0,0  ; at the begining, value must be 0
count2       dw    0,0
inbuff:      db:   0,0
address:     db:  ,0,0


Report this thread to moderator Post Follow-up to this message
Old Post
almas
03-29-08 12:00 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

A86 Assembler archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 12:54 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.