OSWRCH

From BeebWiki
Jump to: navigation, search

Prints a character 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 = ASCII value of character to print preserved

Prints the character whose ASCII value is in A to the currently selected output stream(s), namely the screen, printer, serial port, spool file or any combination of these, or none. The character need not be in the ASCII repertoire of course; it may be part of a VDU sequence, a Teletext graphics character or a printer control code.

A complex process (see diagram, below) filters the characters according to the *FX3, *FX5, *FX6 and *SPOOL settings, the flag returned by VDUCHR, and previous characters submitted to OSWRCH. Each of the terminators (shown in blue) does its own specific processing. The handling is 8 bit clean throughout.

OSBYTE commands affecting OSWRCH
OSBYTE &03 Select output device
OSBYTE &05 Select printer type/output channel
OSBYTE &06 Select character to be ignored by printer
VDU codes affecting flow of control
VDU 1 Send next character to printer only
VDU 2 Enable printer
VDU 3 Disable printer
VDU 6 Enable VDU (screen) driver
VDU 21 Disable VDU (screen) driver

These five VDU commands are handled by VDUCHR. The other function of code 21, to erase the current line of input, is a feature of OSWORD 0.

Character output flowchart

Flowchart of pathways from the OSWRCH entry point to the output devices

 

Calling from BBC BASIC

  • LIST sends output to OSWRCH
  • LISTO sends output to OSWRCH
  • PRINT sends output to OSWRCH
  • VDU sends output to OSWRCH
  • CLS sends VDU 12
  • CLG sends VDU 16
  • COLOUR n sends VDU 17,n
  • GCOL a,n sends VDU 18,a,n
  • GCOL n sends VDU 18,0,n
  • COLOUR l,p sends VDU 19,l,p,0,0,0
  • COLOUR l,r,g,b sends VDU 19,l,16,r,g,b if l>=0
  • COLOUR l,r,g,b sends VDU 19,l,24,r,g,b if l<0
  • MODE n sends VDU 22,n
  • OFF sends VDU 23,1,0,0,0,0,0,0,0,0
  • ON sends VDU 23,1,1,0,0,0,0,0,0,0
  • PLOT k,x,y sends VDU 25,k,x;y;
  • PLOT BY x,y sends PLOT 65,x,y
  • PLOT x,y sends PLOT 69,x,y
  • MOVE BY x,y sends PLOT 0,x,y
  • DRAW BY x,y sends PLOT 1,x,y
  • MOVE x,y sends PLOT 4,x,y
  • DRAW x,y sends PLOT 5,x,y
  • CIRCLE x,y,r sends MOVE x,y:PLOT 145,r,0
  • CIRCLE FILL x,y,r sends MOVE x,y:PLOT 153,r,0
  • ELLIPSE x,y,a,b sends MOVE x,y:MOVE BY a,0:PLOT 193,0,b
  • ELLIPSE FILL sends MOVE x,y:MOVE BY a,0:PLOT 201,0,b
  • FILL x,y sends PLOT 133,x,y
  • FILL BY x,y sends PLOT 129,x,y
  • LINE x1,y1,x2,y2 sends MOVE x1,y1:DRAW x2,y2
  • RECTANGLE x,y,w sends MOVE x,y:PLOT 13,x+w,y:PLOT 13,x+w,y+w:PLOT x,y+w:PLOT 13,x,y
  • RECTANGLE x,y,w,h sends MOVE x,y:PLOT 13,x+w,y:PLOT 13,x+w,y+h:PLOT x,y+h:PLOT 13,x,y
  • RECTANGLE FILL x,y,w sends MOVE x,y:PLOT 101,x+w,y+w
  • RECTANGLE FILL x,y,w,h sends MOVE x,y:PLOT 101,x+w,y+h
  • RECTANGLE x1,y1,w,h TO x2,y2 sends MOVE x1,y1:MOVE x1+w,y1+h:PLOT 190,x2,y2
  • RECTANGLE FILL x1,y1,w,h TO x2,y2 sends MOVE x1,y1:MOVE x1+w,y1+h:PLOT 189,x2,y2
  • RECTANGLE SWAP x1,y1,w,h TO x2,y2 sends MOVE x1,y1:MOVE x1+w,y1+h:PLOT 191,x2,y2
  • ORIGIN x,y sends VDU 29,x;y;
  • PRINT TAB(x,y); sends VDU 31,x,y

Entry points

  • BBC BASIC Entry Address: &FFEE
  • 6502 Entry Address: &FFEE, vectors via &020E
  • Z80 Entry Address: &FFEE, vectors via &FFEF
  • 6809 Entry Address: &FFEE, vectors via &FFEF
  • 80x86 Entry Address: INT &49, vectors via 0000:0124
  • 32000 Entry Address: SVC &01
  • PDP11 Entry Address: EMT 4, vector &04
  • ARM Entry Address: SWI &00 "OS_WriteC", vector &03
  • 68000 Entry Address: MOV #&00,A0:TRAP 12
  • RISC-V Entry Address: ECALL &AC0004

Implementations

Implemented in all MOS versions. Some systems allow BPUT#0 to send output to OSWRCH. The flags are usually corrupted on exit. On 6502 systems the Z flag reflects the contents of A due to the routine ending with a PLA to restore A.

Jgharston 17:03, 6 November 2009 (UTC)