OSNEWL

From BeebWiki
Jump to: navigation, search

Prints a newline sequence to the currently selected output stream(s).

Specification

6502 Z80 6809 PDP11 80x86 32016 ARM 68000 RISC-V On entry: On exit:
A A A R0 AL R1 R0 D0 A0   = &0D

Prints an ASCII line feed (LF) followed by a carriage return (CR) via OSWRCH to the currently selected output stream(s).

Calling from BBC BASIC

  • PRINT ' calls OSNEWL

Entry points

  • BBC BASIC Entry Address: &FFE7
  • 6502 Entry Address: &FFE7
  • Z80 Entry Address: &FFE7
  • 6809 Entry Address: &FFE7
  • 80x86 Entry Address: INT &48, vectors via 0000:0120
  • 32000 Entry Address: SVC &04
  • PDP11 Entry Address: EMT 5, vector &05
  • ARM Entry Address: SWI &03 "OS_NewLine"
  • 68000 Entry Address: MOV #&03,A0:TRAP 12
  • RISC-V Entry Address: ECALL &AC0005

Implementations

This routine has helped establish a standard newline sequence in the BBC series. Bear in mind that text files on 8-bit BBC Micros use only carriage returns (CR), whereas RISC OS text files use only line feeds (LF).

The order is significant because of page mode, and the ability to prevent scrolling with Ctrl-Shift. Outputting LF before CR ensures that while waiting for a scroll, the text cursor is still to the right of the last character printed.

The Arthur/RISC OS C Library for a long time translated C's \n to CR followed by LF, contrary to this convention. This was finally fixed in 32-bit versions.

Jgharston 17:01, 6 November 2009 (UTC)