*** Assembly to implement Cs fprintf(fp,"\n") ***
Dear all,
Do anyone know how to implement LF+CR within file processing ?
That is, in C we can use fprintf(fp,"\n") in file. But how to do it in assembly language ?
* In assembly I can create/write/close file.
Thanks in advance ! :)
[263 byte] By [
jimmyliao] at [2007-11-20 9:12:25]

# 1 Re: *** Assembly to implement Cs fprintf(fp,"\n") ***
The LF+CR is basically 0A0D (characters 10 and 13). Simply write this word value to the file.
PS: in C, you would actually have: fprintf(fp,"\r\n");
# 2 Re: *** Assembly to implement Cs fprintf(fp,"\n") ***
Thanks ! I tried it and it works !
* But why "0A0Dh" can be used in BOTH text-display and file processing :confused: I think these 2 are different things, right ?
# 3 Re: *** Assembly to implement Cs fprintf(fp,"\n") ***
Thanks ! I tried it and it works !
* But why "0A0Dh" can be used in BOTH text-display and file processing :confused: I think these 2 are different things, right ?
Sorry... didn't understand what you mean by "text-display", but if you meant console window, it is also handled as a stream output. I think the line-feed (LF) character was used for printers, and return (CR) character was used by displays. At one point in time, in order to support both in the same way, was decided that newer "documents" should contain both (but only as LF+CR, not CR+LF) and be translated further as one ENTER. Thus, backward compatibility is maintained. Never documents are displayed in the same way as older documents (both printable or displayable ones). Don't know much more about the history of it, but I can live with this simple explaination. ;)
Best regards,