Re: [cc65] Re: Questions for CBM guys

From: Spiro Trikaliotis <>
Date: 2008-03-04 07:13:26
Hello Jonathan,

* On Tue, Mar 04, 2008 at 01:25:09AM +0000 Jonathan Graham Harston wrote:
> "Oliver Schmidt" wrote:
> > 1. What char code does place the cursor at the beginning of the next
> > line? This seems to be $0D.
> Most screen drivers do not have /a/ code to move to the beginning
> of the next line. 
> 0D CR (Carriage Return) moves to the biginning of the current line
> 0A LF (Line Feed) moves the cursor to the current column of the
> next line.

While this is generally true, this is not true for the C64 nor fór the

On the CBM machines, CR alone performs BOTH steps.

Notice that this might not be true for all kinds of peripheral devices.
For example, printers might need both CR and LF to advance to the next
line. For these, BASIC has to option to automatically insert a LF after
a PRINT returns a CR. This happens when the file number is >= 128 (bit 7
is set). That is, OPEN 128,4:PRINT#128,A$ would insert a LF after the
contents of A$.

Note: If A$ contains a CR (CHR$(13)) itself, the LF will not be added
after this CR; only after the last one!

To output a CR or a CR/LF on the C64, depending on the logical file
number having bit 7 set or not, you have to JSR $AAD7 on the C64. Note
again: This is functionality of BASIC, not of the KERNAL itself. You
also have to set $13 to the logical file number (to be more precise: bit
7 of $13 must be set according to what you want).

Of course, it is trivial to implement this functionality on your own.

> To move the beginning of the next line you need to send both
> codes, LF,CR or CR,LF.
> > 2. What registers are modified? As far as I have seen all registers
> > are preserved.
> Most systems preserve registers that do not return anything.

No. Most systems preserve the registers that are explicitly documented
to be preserved.


Spiro R. Trikaliotis                               
To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Mar 4 07:13:48 2008

This archive was generated by hypermail 2.1.8 : 2008-03-04 07:13:52 CET