|
Prev: delete bytes
Next: Skybuck presents Faster Div 7
From: Wolfgang Kern on 23 Apr 2008 05:19 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 ... :)
From: Terence on 23 Apr 2008 19:09 Without wanting to destroy your interest in assemblers, the series of problems you are attacking would have solved in a very few lines of Fortran code. So ASM is not the best tool for THIS problem.
From: Chuck Crayne on 24 Apr 2008 00:03 On Wed, 23 Apr 2008 16:09:37 -0700 (PDT) Terence <tbwright(a)cantv.net> wrote: > So ASM is not the best tool for THIS problem. Neither is Fortran. However, in this forum, that is not the point. Telling someone that they should not use ASM is not useful to a person who is interested in learning ASM. We are supposed to be here to help. -- Chuck http://www.pacificsites.com/~ccrayne/charles.html
From: almas on 24 Apr 2008 01:21 Hi everybody. Here, i learn how open, modify, save a file. I can add bytes a the end of a file. Now, i want to increace, reduce the size of a file. I know srep, change, and others tools. But iwould do it witha particular tool. Sure it is painfull for me to make a good file. Regards Almas "Chuck Crayne" <ccrayne(a)crayne.org> a �crit dans le message de news: 20080423210358.08cd6e1e(a)thor.crayne.org... > On Wed, 23 Apr 2008 16:09:37 -0700 (PDT) > Terence <tbwright(a)cantv.net> wrote: > >> So ASM is not the best tool for THIS problem. > > Neither is Fortran. However, in this forum, that is not the point. > Telling someone that they should not use ASM is not useful to a person > who is interested in learning ASM. We are supposed to be here to help. > > -- > Chuck > http://www.pacificsites.com/~ccrayne/charles.html > >
From: Wolfgang Kern on 24 Apr 2008 03:40
Terence replied to almas: > Without wanting to destroy your interest in assemblers, the series of > problems you are attacking would have solved in a very few lines of > Fortran code. So ASM is not the best tool for THIS problem. I'm fully with Chuck here, we shouldn't scare away the few who are really interested in ASM, regardless if a better solution for a given quest can be found in any LIBs or the OS-API already. OTOH, we oldies may learn a lot from newbie's questions ..., perhaps our burned in 'knowledge&experience' would never have asked to see a problem from another aspect. __ wolfgang |