Re: delete "0D"



J.Dorval wrote:
... Hello,
Sorry, but i did not succed with the syntax nasm -f obj file.asm -Ox

Oh, well... if it wuz easy, everybody'd be doing it. I must have missed something (probably several somethings). If you want to continue with that, tell us more about what goes wrong.

Dirk has shown you a nice "sophisticated" program. Shows how to read a filename from the command line, allocate memory for a buffer, open/read/write/close the file... nice specific error messages...

I had in mind something much simpler. This is a "filter". Reads from stdin, filters out the CRs, and writes to stdout. 19 bytes. It has the disadvantage, compared to Dirk's program, that it needs a different file to write to - you can "crlf2lf<infile.txt>tmp"/"move tmp infile.txt" if you want. It has the advantage that it isn't limited to 64k file length, but is slower (calling the OS for every single character is SSSLLLOOOWWW! ... but it probably won't bother you.)

This is so simple it doesn't even need the "org 100h" you'd normally want for a dos .com file! You might want to put that - and "section ..text" in, for consistency, but Nasm doesn't need it...

;------------------------------------
; nasm -f bin crlf2lf.asm -o crlf2lf.com
;
; usage crlf2lf < infile > outfile

mov ah, 6 ; dosio subfunction
input:
mov dl, 0FFh ; Input a byte from stdin
int 21h
jz exit ; if EOF, quit (returns zero flag set)
cmp al, 0Dh
jz input ; if "our" character, don't output
output:
mov dl, al
int 21h
jmp short input
exit:
ret ; return to dos (via int 20h in PSP)
;-------------------------------------

See how that works for ya. Or we can have another go at Dirk's code...

Does exist others tools

Sure, but what fun is that? :)

for delete "alt26" it mean EOF

Yeah... kinda "old school"... I don't think you'll encounter it often. (not used as EOF, anyway) That might be a problem, in that dos might not "read" it at all... in which case it won't write it either. If you've got a file with a 26 (control-z as well as alt-down, 26 on the keypad, alt-up) in it, see what it does.

May be it is possible to modify such tool ?

Dunno. Try it!

Best,
Frank
.