|
Prev: Replace bytes
Next: Audio processing via GPU
From: Frank Kotler on 11 Apr 2008 09:04 almas wrote: > Hi every body. > > I try my solution...but it do not works... > Below, you can see my code > > ; i use A86 > > mov cx, byte size_file > mov si, offset come_from ; 1st file > mov di, offset go_to ; the new file > > work: > cmp byte [si], "��" > jz next > mov di,[si] What's this intended to do? Best, Frank
From: almas on 11 Apr 2008 17:04 Hi Franck. Hi everybody. The aim is to replace ASCII characters in a file. Sure, such tool do exist... but i want to built my com file The input file contain Here is� my tex�t The output is with -no "�" so it get Here is my text I will do a mov offset XY, al because i have "nothing" in the place of DI in the first try. An i must do address of XY become XY+1 then XY+2 XY+3.... and so long ! "Frank Kotler" <fbkotler(a)verizon.net> a �crit dans le message de news: 6lJLj.6166$Xy2.3501(a)trndny04... > almas wrote: >> Hi every body. >> >> I try my solution...but it do not works... >> Below, you can see my code >> >> ; i use A86 >> >> mov cx, byte size_file >> mov si, offset come_from ; 1st file >> mov di, offset go_to ; the new file >> >> work: >> cmp byte [si], "��" >> jz next >> mov di,[si] > > What's this intended to do? > > Best, > Frank > > >
From: Frank Kotler on 11 Apr 2008 18:07 almas wrote: > Hi Franck. > Hi everybody. > > The aim is to replace ASCII characters in a file. .... with non-ascii characters. Yes, you've been trying to do it for about five years now... > Sure, such tool do exist... but i want to built my com file Right!!! No point posting to an asm newsgroup, "I used Perl to remove a character from a file"! (although, we see worse :) > The input file contain Here is� my tex�t > The output is with -no "�" so it get > Here is my text > > I will do a mov offset XY, al While we're at it, what's *this* supposed to do??? > because i have "nothing" in the place of DI > in the first try. > An i must do address of XY become XY+1 then XY+2 XY+3.... and so long ! I don't think I made the question clear... -------------------- ; i use A86 mov cx, byte size_file I see you've got "size_file" defined as "db" (a mistake, IMO). Do you intend to move a single byte into cx??? Does A86 magically translate this to "movzx"? What in hell is this supposed to *mean*??? mov si, offset come_from ; 1st file mov di, offset go_to ; the new file This is sensible. work: cmp byte [si], "��" jz next So far, so good... mov di,[si] Now... after having moved "offset go_to" into di, you're replacing it with the first two bytes of your input buffer! It looks like you want to do a memory-to-memory move here - mov [di], [si] - but there's no such instruction! The string instruction "movsb" would do what you want (I think), and increment both si and di... but you'd what to do it if the character *wasn't* the one you want to omit. If it *is* the one you (don't) want, just increment si and jump back to "work". inc word calculate_new_size next: inc si inc di loop work nop Having done the work, you "fall through" and execute whatever number you've got here... calculate_new_size dw: ,0,0,0,0 ; I obtain 0B nop nop nop And if we're still alive, do it again... size_file db: ,0Ch,00 ; mistake, i should read more bytes... .... and this text... come_from db: "ici est ��mon Te��Te" ,40h,40h,40h ; DEBUG can read thooses bytes above. ; but when debug read below.... bytes still have value 0 .... and *this* text... go_to db ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, nop nop nop nop nop nop ; many nop... nop ; the aim read a NOP nop nop nop And if we're *still* alive (unlikely!), exit back to dos. int 20h So let me rephrase the question... "Why you do these crazy things???" Don't take that as an insult - we're all crazy here. As the Cheshire Cat said to Alice, "If you weren't mad, you wouldn't be here!" Have you read the Friendly Manual, in all the years you've been using A86? I think you ought to (re)read chapter 4, on the difference between "foo" and "foo:", and what "offset" means, and what "byte", "word", etc. mean to A86. I think it'd clear up a lot of your confusion. Best, Frank
From: almas on 12 Apr 2008 04:11 Hi Franck. Yes, i remeber, i had problems for remplace just 1 byte in a file. Now, i can open, write and close a file I can also replace all Ascii above 20h, exept 0Dh and 0Ah by ; or othe separator field. in a fils with have for structure ? first_field ? second ? others_informations where ? mean number of bytes in the next field. I can replace a byte by an other one with my tools... Thanks to the clever helpers. But now, i have to destroy a particular byte.. By "INC BYTE calculate_new size ; i mean save the lengh of the new file, then do push cx mov cx, offset calculate_new size ..... int 21h pop cx In first, i wanted to put entry in SI register a put the correct value in DI ( Destination Index ? ) But it do not work. So i will do mov offset out_put , ax then mov offset out_put +1 , ax after mov offset out_put +2 , ax.... Bytes will go a address of offset out_put. Sure i will have to use small size files. about 28 Kb for entry 28Kb or less for out_put Now i have no time to try... next week Regards Almas "Frank Kotler" <fbkotler(a)verizon.net> a �crit dans le message de news: WiRLj.43$mG1.38(a)trndny08... > almas wrote: >> Hi Franck. >> Hi everybody. >> >> The aim is to replace ASCII characters in a file. > > ... with non-ascii characters. Yes, you've been trying to do it for about > five years now... > >> Sure, such tool do exist... but i want to built my com file > > Right!!! No point posting to an asm newsgroup, "I used Perl to remove a > character from a file"! (although, we see worse :) > >> The input file contain Here is� my tex�t >> The output is with -no "�" so it get >> Here is my text >> >> I will do a mov offset XY, al > > While we're at it, what's *this* supposed to do??? > >> because i have "nothing" in the place of DI in the first try. >> An i must do address of XY become XY+1 then XY+2 XY+3.... and so long ! > > I don't think I made the question clear... > > -------------------- > ; i use A86 > > mov cx, byte size_file > > I see you've got "size_file" defined as "db" (a mistake, IMO). Do you > intend to move a single byte into cx??? Does A86 magically translate this > to "movzx"? What in hell is this supposed to *mean*??? > > mov si, offset come_from ; 1st file > mov di, offset go_to ; the new file > > This is sensible. > > work: > cmp byte [si], "��" > jz next > > So far, so good... > > mov di,[si] > > Now... after having moved "offset go_to" into di, you're replacing it with > the first two bytes of your input buffer! It looks like you want to do a > memory-to-memory move here - mov [di], [si] - but there's no such > instruction! The string instruction "movsb" would do what you want (I > think), and increment both si and di... but you'd what to do it if the > character *wasn't* the one you want to omit. If it *is* the one you > (don't) want, just increment si and jump back to "work". > > inc word calculate_new_size > > next: > inc si > inc di > loop work > nop > > Having done the work, you "fall through" and execute whatever number > you've got here... > > calculate_new_size dw: ,0,0,0,0 ; I obtain 0B > nop > nop > nop > > And if we're still alive, do it again... > > size_file db: ,0Ch,00 > ; mistake, i should read more bytes... > > ... and this text... > > come_from db: "ici est ��mon Te��Te" ,40h,40h,40h > > ; DEBUG can read thooses bytes above. > ; but when debug read below.... bytes still have value 0 > > ... and *this* text... > > go_to db ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, > > nop > nop > nop > nop > nop > nop ; many nop... > nop ; the aim read a NOP > nop > nop > nop > > And if we're *still* alive (unlikely!), exit back to dos. > > int 20h > > > So let me rephrase the question... "Why you do these crazy things???" > Don't take that as an insult - we're all crazy here. As the Cheshire Cat > said to Alice, "If you weren't mad, you wouldn't be here!" > > Have you read the Friendly Manual, in all the years you've been using A86? > I think you ought to (re)read chapter 4, on the difference between "foo" > and "foo:", and what "offset" means, and what "byte", "word", etc. mean to > A86. I think it'd clear up a lot of your confusion. > > Best, > Frank
From: Rod Pemberton on 12 Apr 2008 11:41
"almas" <almes(a)naburo.com> wrote in message news:47ff3e79$0$835$ba4acef3(a)news.orange.fr... > Hi every body. > > I try my solution...but it do not works... > Below, you can see my code > > ; i use A86 > > mov cx, byte size_file > mov si, offset come_from ; 1st file > mov di, offset go_to ; the new file > .... > work: > cmp byte [si], "��" > jz next > mov di,[si] > inc word calculate_new_size > next: > inc si > inc di > loop work > nop > calculate_new_size dw: ,0,0,0,0 ; I obtain 0B > nop > nop > nop You probably want something more like this. You'll need to convert to A86 syntax. This code is untest. It also uses string and loop instructions which can be slow, but are convenient. push ds pop es cld mov al,0A8h ; "inverted ?" work: movsb ; copy byte from ds:si to es:di scasb ; check byte at es:di for inverted ? inc word calculate_new_size loopnz work ; repeat if more and not inverted ? dec di ; backup to overwrite inverted ? inc cx ; adjust cx for loop loop work ; repeat if more, exit if not inc di ; adjust dx for exit Rod Pemberton |