; AltoConsts, EmulatorDefs, R-Regs, constants and labels used in Spruce microcode
; (Orbit microcode, trident microcode, and other packages retain their own defs)

#AltoConsts23.mu;
from [*]<Altosource>AltoConsts23.mu

; from [*]<Altosource>BcplRuntimeSources.mu(EmulatorDefs.mu):
; Standard microinstruction addresses in the Rom
; (see Alto Hardware Manual, section 9.1).
; These declarations do not cause space to be allocated in the Ram
; (except TRAP1, which we presumably want to define in the Ram)

; $START
$L4020, 0, 0; placed explicitly in SpruceMc
$RAMCYCX
$L4022, 0, 0;
$BLT
$L4105, 0, 0;
$BLKS
$L4106, 0, 0;
$MUL
$L4120, 0, 0;
$DIV
$L4121, 0, 0;
$BITBLT
$L4124, 0, 0;
$L0
$L4160, 0, 0;

; !37,1, TRAP1; included in larger vector reservation in SpruceMc


; Standard R-registers usable by the emulator task

$AC3
$R0;Accumulators
$AC2
$R1;
$AC1
$R2;
$AC0
$R3;
$NWW
$R4;New wakeups waiting (communication between tasks)
$SAD
$R5;Temporary private to emulator
$PC
$R6;Program Counter for emulated Nova
$XREG
$R7;Temporary private to emulator.
;
Contains instruction LCY 8 upon dispatch to TRAP1.
$XH
$R10;Temporary private to emulator
$MTEMP
$R25;Temporary usable by any task
$DWAX
$R35;Temporary private to emulator
$MASK
$R36;Temporary private to emulator

$LREG
$R40;Another name for the M-register

; In addition to those described in EmulatorDefs, the following is true of R-Registers:
; 11-13
Reserved for standard I/O devices
; 14
Used by T80, could possibly be used during TASK segment
; 15-17
Available for use by RAM applications
; 20-24
Display
; 26-27
Display
; 30-34
Disk
; 35-36
BitBlt temps, in addition to other emulator uses
; 37
Almost doesn’t exist, holds RTC
; 41-51
BitBlt temps

; Then there is Mesa (not relevant in Spruce, but good to know):
; 15-17
Mesa uses
; 41
"
; 44-47
"
; 51-57
"
; 60-67
The Stack!

; Reset Mode Register Update instruction, used in SpruceMc
$RMR
$L20013, 00000, 124000;F1=13, set RMR

; Global R-register definitions, constants used throughout
$LASTL
$R40; another name for M or LREG
$temp
$R17; used as such in several routines
$170000
$170000; used by orbit and showchar
$177026
$177026;
$EvenMask
$177776;

; LOADR, STORER instruction temps -- the instructions cannot list these registers as targets

$instr
$R10;NOVA RamTrap instruction that caused the trap
$low
$R17;low half of RAM instruction during its composition -- hi is in XREG

; RowRotate Registers
$INBUF
$R3; AC0 Address preceding first of next eight words to read
$OUTBUF
$R1; AC2 Address preceding first word to write into
$WPR
$R0; AC3 Displacement of words, beginning with INBUF
$RCNT
$R41; Counts number of columns left to handle(share these with Orbit)
$INADR
$R42; Temp during column fetching
$BITCNT
$R43; Inner loop control
$WDCNT
$R44; Temp during column fetching

$SHR1
$R2; AC1 These hold one word from each of eight rows, are shifted to
$SHR2
$R5; SAD produce output samples
$SHR3
$R7; XREG
$SHR4
$R10; XH
$SHR5
$R35; DWAX
$SHR6
$R36; MASK
$SHR7
$R15; (unused in standard microcode, share with Orbit)
$SHR8
$R16; (unused in standard microcode, share with Orbit)
$HOLD
$R17; Holds output sample as it is developing (share with Orbit)

; TriCon defs needed outside TriConBodyMc
$EXITRAM
$L4000, 0, 0; TriCon’s name for NOVEM

; ShowChar registers, index definitions
; Return codes from ShowChars
;$MUDone $0;
$MUCharRange $1;
$MUCant $1;
$MUOffPage $2;
$MUBufFull $3;

$BERectangleH $1;

; Registers used by ShowChars (and FlushChars -- indented)
; Read-only values supplied at Setup time
$BandTable
$R70;
$CopyTable
$R52;
$WidthPointer
$R67;
$nVisibleBands
$R66;
$onlyOnCopy
$R65;
$ICCUses
$R64;
$ICCOffset
$R63;
$bcM1
$R62;
$ec
$R61;

; Values updated at final return
$CurS0
$R60;
$CurS1
$R57;
$CurB0
$R56;
$CurB1
$R55;
$fspn
$R16;FontSizePageNew increment, R-Reg for clear code, below
$fspo
$R15;FontSizePageOld increment, R-Reg for clear code, below

; Values updated on buffer-full returns
$BandFree
$R54;
$pData$R54; FlushChars() called while ShowChars in effect; so can only use temp regs.
$BandAvail
$R53;
$typeWd $R53;

; Values updated on every return
$c
$R47;
$numData $R47;
$band
$R51;
$outAddr$R51;

; Temporaries used during ShowChars operation
$savedPC
$R50;
$ct
$R46;
$byteIdx
$R45;
$base
$R44;
$data
$R43;
$icc
$R42;
$entryLen
$R42; used in BandEnter, either at end of ShowChars or called directly
$leftCt$R42;
$p
$R41;
$uses
$R41;
$b
$R7;
$lineBand
$R10;

;; DCS, October 20, 1978 12:00 PM, derived from other sources
;; October 23, 1978 6:51 AM, add constants, regs for FlushChars
;;