New installation mechanism
authorceriel <none@none>
Fri, 30 Aug 1991 15:19:38 +0000 (15:19 +0000)
committerceriel <none@none>
Fri, 30 Aug 1991 15:19:38 +0000 (15:19 +0000)
12 files changed:
mach/6500/libem/.distr
mach/6500/libem/LIST
mach/6500/libem/trap.s
mach/6500/libmon/.distr [new file with mode: 0644]
mach/6500/libmon/LIST [new file with mode: 0644]
mach/6500/libmon/head_em.s [new file with mode: 0644]
mach/6500/libmon/mon.s [new file with mode: 0644]
mach/6500/libmon/print.s [new file with mode: 0644]
mach/6500/libmon/printhex.s [new file with mode: 0644]
mach/6500/libmon/printstack.s [new file with mode: 0644]
mach/6500/libmon/read.s [new file with mode: 0644]
mach/6500/libmon/write.s [new file with mode: 0644]

index a98171f..d2b4f28 100644 (file)
@@ -1,5 +1,2 @@
 LIST
-Makefile
-end.s
-head_em.s
 libem_s.a
index 6b9a0de..4964771 100644 (file)
@@ -18,10 +18,6 @@ mli4.s
 mlu.s
 mlu4.s
 mul4.s
-mon.s
-write.s
-printstack.s
-printhex.s
 rmi.s
 rmi4.s
 div4.s
@@ -52,7 +48,6 @@ testFFh.s
 trap.s
 ldi.s
 data.s
-print.s
 zri.s
 locaddr.s
 and.s
@@ -76,7 +71,6 @@ lxa1.s
 lxa2.s
 lxl.s
 pro.s
-read.s
 rol.s
 rol4.s
 ror.s
index 5ce53f9..05ee0fb 100644 (file)
@@ -130,10 +130,6 @@ Mtrap:
        ldx #[EBADGTO].l
        jsr Mprint
 errorend:
-       ldx STACK
-       dex
-       dex
-       txs
-       rts
-
-
+       ldx TRAPVAL
+       jsr Push
+       jsr __exit
diff --git a/mach/6500/libmon/.distr b/mach/6500/libmon/.distr
new file mode 100644 (file)
index 0000000..1edec9f
--- /dev/null
@@ -0,0 +1,3 @@
+LIST
+head_em.s
+libmon_s.a
diff --git a/mach/6500/libmon/LIST b/mach/6500/libmon/LIST
new file mode 100644 (file)
index 0000000..228b5b2
--- /dev/null
@@ -0,0 +1,7 @@
+libmon_s.a
+print.s
+printhex.s
+printstack.s
+mon.s
+read.s
+write.s
diff --git a/mach/6500/libmon/head_em.s b/mach/6500/libmon/head_em.s
new file mode 100644 (file)
index 0000000..5e4a1c2
--- /dev/null
@@ -0,0 +1,233 @@
+.define WRCH, RDCH, Earray, Erange, Eset
+.define Eiovfl, Eidivz, Eiund, Econv
+.define Estack, Eheap, Eillins, Eoddz
+.define Ecase , Ebadmon, OSBYTE, MON
+.define Ebadlin, Ebadgto, BASE, NBYTES
+.define hol0, IGNMASK, ADDR, PROGNAME
+.define LB, LBl, SP, HP, ERRPROC, UNSIGN
+.define Ytmp, EXG, ARTH, RETURN, SIGN
+.define RETSIZE, TRAPVAL, STACK, BRANCH
+.define start, Push, Pop, STACKTh, STACKTl
+.define F_DUM
+.sect .zero
+.sect .text
+.sect .rom
+.sect .data
+.sect .bss
+.sect .text
+
+! DEFINITIONS
+
+       ! The next three definitions are special for the
+       ! BBC microcomputer
+
+WRCH   = 0x0FFEE       ! This subroutine writes the character in
+                       ! register A to the screen
+RDCH   = 0x0FFE0       ! This subroutine returns a character in
+                       ! register A from the current input stream
+OSBYTE = 0x0FFF4       ! This subroutine performs miscelaneous
+                       ! operating system calls
+
+F_DUM  = 0             ! Dummy floating point constant
+
+       ! Here are the error numbers
+
+Earray = 0
+Erange = 1
+Eset   = 2
+Eiovfl = 3
+Eidivz = 6
+Eiund  = 8
+Econv  = 10
+Estack = 16
+Eheap  = 17
+Eillins = 18
+Eoddz  = 19
+Ecase  = 20
+Ebadmon = 25
+Ebadlin = 26
+Ebadgto = 27
+MON = 0x78D0
+
+BASE   = 240           ! This is the offset from the localbase
+                       ! for the second localbase
+
+STACKTh = 0x78         ! This is the top of the stack
+STACKTl = 0x0D0
+
+       ! Some zeropage declarations
+
+.sect .zero
+
+RES: .space 76         ! special for the operating system
+
+hol0:  .space 16       ! the hol0 block
+
+IGNMASK: .space 2      ! can hold the ingnore mask
+
+ADDR: .space 4         ! used for indirect addressing
+
+LB: .space 2           ! the localbase
+
+LBl: .space 2          ! the second localbase (localbase-BASE)
+
+SP: .space 3           ! the stackpointer (real_stack)
+
+HP: .space 2           ! the heap pointer
+
+BRANCH: .space 2       ! used for branch instructions
+
+ERRPROC: .space 2      ! can hold the address of the error handler
+
+Ytmp: .space 1         ! used for intermediate storage in Y
+
+EXG: .space 2          ! used by the exchange subroutine Exg
+
+ARTH: .space 16                ! used for arithmetic
+
+NBYTES: .space 2       ! containes the number of bytes for a block move
+
+
+RETURN: .space 4       ! the return area
+
+RETSIZE: .space 1      ! the size of the object returned
+
+SIGN: .space 1         ! the sign of the calculation
+
+UNSIGN : .space 1      ! is it signed or unsigned arithmetic
+
+TRAPVAL: .space 1      ! intermediate storage of the error number
+
+STACK: .space 1                ! contains the hardware stackpointer on
+                       ! entering _m_a_i_n for a neat return
+
+RESERVED: .space 112    ! used by the operating system
+
+.sect .text
+.base 0x0E02           ! where to start in the BBC micro
+! GENERAL PURPOSE ROUTINES
+
+start:
+       tsx
+       stx STACK       ! save stackpointer for exit and error
+
+       ! The following three operating system calls are only
+       ! for the BBC microcomputer
+
+       lda #2
+       ldx #0
+       ldy #0
+       jsr OSBYTE      ! return control to the keyboard
+       lda #15
+       ldx #0
+       ldy #0
+       jsr OSBYTE      ! clear all internal buffers
+       lda #3
+       ldx #5
+       ldy #0
+       jsr OSBYTE      ! output to screen and RS423
+
+       lda #STACKTl
+       sta LB          ! set localbase (lowbyte)
+       sta SP+2
+       lda #0
+       sta SP          ! set stackpointer (lowbyte)
+       sta ERRPROC     ! set start address for error handler (lowbyte)
+       sta ERRPROC+1   ! set start address for error handler (highbyte)
+       sta hol0        ! set the line number (lowbyte)
+       sta hol0+1      ! set the line number (highbyte)
+       lda #STACKTh
+       sta SP+1        ! set the stacpointer (highbyte)
+       sta LB+1        ! set the localbase (highbyte)
+       lda #[endbss].l
+       sta HP          ! set the heap pointer (lowbyte)
+       lda #[endbss].h
+       sta HP+1        ! set the heap pointer (highbyte)
+       lda #[PROGNAME].l
+       sta hol0+4      ! set fake programname pointer (lowbyte)
+       lda #[PROGNAME].h
+       sta hol0+5      ! set fake programname pointer (highbyte)
+       lda #[beginbss].l
+       sta ADDR        ! start address of bss block (lowbyte)
+       lda #[beginbss].h
+       sta ADDR+1      ! start address of bss block (highbyte)
+       ldy #0
+       lda #0
+    4: ldx #[endbss].h ! clear bss block
+       cpx ADDR+1
+       bcc 1f          ! end of bss block reached
+       bne 2f
+       ldx #[endbss].l
+       cpx ADDR
+       bcc 1f          ! end of bss block reached
+    2: sta (ADDR),y
+       inc ADDR
+       bne 3f
+       inc ADDR+1
+    3: jmp 4b
+    1: lda #0
+       tax
+       jsr Push        ! push fake envelope pointer
+       lda #[PROGNAME].h
+       ldx #[PROGNAME].l
+       jsr Push        ! push argv[0]
+       lda #0
+       ldx #1
+       jsr Push        ! push argc 
+       jsr __m_a_i_n   ! start the real program
+
+       lda #0x0FF
+       jsr WRCH        ! send end of program to R423
+       lda #3
+       ldx #0
+       jsr OSBYTE      ! send output to screen only
+       lda #2
+       ldx #1
+       jsr OSBYTE      ! input only from R423
+       rts
+
+
+! The subroutine Push pushes the registerpair AX onto the stack.
+
+Push:
+       sty Ytmp        ! save Y
+       ldy SP+2
+       bne 1f          ! lowbyte of stackpointer <> 0
+       dec SP+1        ! decrement highbyte of stackpointer
+    1:  dey
+       dey             ! decrement lowbyte of stackpointer
+       sty SP+2        ! save lowbyte of stackpointer
+       pha             ! save A
+       txa
+       sta (SP),y      ! push X onto the stack
+       iny
+       pla             ! get A
+       sta (SP),y      ! push A onto the stack
+       ldy Ytmp        ! restore Y
+       rts
+
+
+! The subroutine Pop pops the registerpair AX from the stack.
+
+Pop:
+       sty Ytmp        ! save Y
+       ldy SP+2
+       lda (SP),y      ! pop X from the stack
+       tax
+       iny
+       lda (SP),y      ! pop A from the stack
+       iny
+       bne 1f          ! lowbyte of stackpointer <> 0
+       inc SP+1        ! increment highbyte of stackpointer
+    1:  sty SP+2       ! store lowbyte of stackpointer
+       pha             ! save A
+       pla             ! get A
+       ldy Ytmp        ! restore Y
+       rts
+
+
+.sect .data
+PROGNAME:              ! for initialising the programname pointer
+.asciz "program"
+.sect .bss
+beginbss:
diff --git a/mach/6500/libmon/mon.s b/mach/6500/libmon/mon.s
new file mode 100644 (file)
index 0000000..1d094c5
--- /dev/null
@@ -0,0 +1,40 @@
+.define Mon
+.sect .text
+.sect .rom
+.sect .data
+.sect .bss
+.sect .text
+
+! This subroutine performs some monitor calls.
+! The exit call just resets the hardware_stackpointer so
+! this routine will return to the operating system.
+! The close call just returns a zero.
+! The ioctl call just pops its arguments and returns a zero.
+! The write routine is a real one.
+
+
+Mon:
+       cpx #1
+       bne 1f          ! exit
+       ldx STACK       ! load stackpointer
+       dex
+       dex             ! adjust stackpointer
+       txs             ! set stackpointer
+       rts
+    1: cpx #4
+       bne 1f
+       jmp Mwrite
+    1: cpx #6          ! facked
+       bne 1f          ! close
+       lda #0
+       tax             ! return zero
+       rts
+    1: cpx #54
+       jsr Pop         ! pop first argument (fildes)
+       jsr Pop         ! pop second argument (request)
+       jsr Pop         ! pop third argument (argp)
+       lda #0
+       tax             ! return zero
+       rts
+
+
diff --git a/mach/6500/libmon/print.s b/mach/6500/libmon/print.s
new file mode 100644 (file)
index 0000000..eea8e73
--- /dev/null
@@ -0,0 +1,27 @@
+.define Mprint
+.sect .text
+.sect .rom
+.sect .data
+.sect .bss
+.sect .text
+
+! This subroutine prints a zero terminated ascii string.
+! The registerpair AX contains the start of the string.
+! The subroutine WRCH is a special routine on the BBC microcomputer
+! which prints the character in A to the screen.
+! The subroutine WRCH is a special one provided by the BBC
+! microcomputer.
+
+
+Mprint:
+       stx ADDR        ! start address of string (lowbyte)
+       sta ADDR+1      ! start address of string (highbyte)
+       ldy #0
+    1: lda (ADDR),y    ! get ascii character
+       beq 2f
+       jsr WRCH        ! put it on the screen
+       iny
+       bne 1b
+    2:  rts
+
+
diff --git a/mach/6500/libmon/printhex.s b/mach/6500/libmon/printhex.s
new file mode 100644 (file)
index 0000000..e1d3e4b
--- /dev/null
@@ -0,0 +1,32 @@
+.define Printhex
+.sect .text
+.sect .rom
+.sect .data
+.sect .bss
+.sect .text
+
+! This subroutine print the contents of register A to the screen
+! in hexadecimal form.
+! The subroutine WRCH is a special one provided by the BBC
+! microcomputer.
+
+
+Printhex:
+       pha             ! save A
+       lsr a
+       lsr a
+       lsr a
+       lsr a           ! get four high bits
+       jsr 1f
+       pla             ! restore A
+       and #0x0F       ! get four low bits
+       jsr 1f
+       rts
+    1: sed             ! print in hex
+       clc
+       adc #0x90
+       adc #0x40
+       cld
+       jmp WRCH
+
+
diff --git a/mach/6500/libmon/printstack.s b/mach/6500/libmon/printstack.s
new file mode 100644 (file)
index 0000000..27f1512
--- /dev/null
@@ -0,0 +1,49 @@
+.define Printstack
+.sect .text
+.sect .rom
+.sect .data
+.sect .bss
+.sect .text
+
+! This a special subroutine which prints some things to the
+! monitorscreen for debugging.
+
+
+Printstack:
+       ldy #0
+    2: lda (hol0+4),y
+       beq 1f
+       jsr WRCH        ! print filename
+       iny
+       jmp 2b
+    1: lda #32
+       jsr WRCH        ! print a space
+       lda hol0+1
+       jsr Printhex    ! print line number (highbyte)
+       lda hol0
+       jsr Printhex    ! print line number (lowbyte)
+       lda #32
+       jsr WRCH        ! print a space
+       lda SP+1
+       jsr Printhex    ! print stackpointer (highbyte)
+       lda SP+2
+       jsr Printhex    ! print stackpointer (lowbyte)
+       lda #32
+       jsr WRCH        ! print a space
+       lda LB+1
+       jsr Printhex    ! print real localbase (highbyte)
+       lda LB
+       jsr Printhex    ! print real localbase (lowbyte)
+       lda #32
+       jsr WRCH        ! print a space
+       lda LBl+1
+       jsr Printhex    ! print second lowerbase (highbyte)
+       lda LBl
+       jsr Printhex    ! print second lowerbase (lowbyte)
+       lda #10
+       jsr WRCH        ! print a newline
+       lda #13
+       jsr WRCH        ! print a carriagereturn
+       rts
+
+
diff --git a/mach/6500/libmon/read.s b/mach/6500/libmon/read.s
new file mode 100644 (file)
index 0000000..12d2c58
--- /dev/null
@@ -0,0 +1,37 @@
+.define Mread
+.sect .text
+.sect .rom
+.sect .data
+.sect .bss
+.sect .text
+
+! This subroutine reads characters from the standard input.
+! It ignores the filedes.
+! It reads atmost 255 characters. So the runtime system must
+! provide a way of dealing with this.
+! The subroutine RDCH is a special one provided by the BBC
+! microcomputer.
+
+
+Mread:
+       jsr Pop         ! ignore filedescriptor
+       jsr Pop         ! bufptr
+       stx ADDR        ! address of character buffer (lowbyte)
+       sta ADDR+1      ! address of character buffer (highbyte)
+       jsr Pop         ! number of characters
+       ldy #0          ! <= 255
+       inx
+    1: jsr RDCH        ! read a character from the current inputstream
+       bcs 8f
+       sta (ADDR),y
+       iny
+       dex
+       bne 1b
+    8: tya
+       tax
+       lda #0
+       jsr Push        ! number of characters red.
+       tax             ! report a succesfull read.
+       rts
+
+
diff --git a/mach/6500/libmon/write.s b/mach/6500/libmon/write.s
new file mode 100644 (file)
index 0000000..7b87cf4
--- /dev/null
@@ -0,0 +1,39 @@
+.define Mwrite
+.sect .text
+.sect .rom
+.sect .data
+.sect .bss
+.sect .text
+
+! This subroutine performs the monitor call write.
+! Writing is always done to standardoutput.
+! A zero is returned on exit.
+! The subroutine WRCH is a special routine of the BBC
+! microcomputer.
+
+
+Mwrite:
+       jsr Pop         ! get fildes
+       jsr Pop         ! get address of characterbuffer
+       stx ADDR        ! bufferaddress (lowbyte)
+       sta ADDR+1      ! bufferaddress (highbyte)
+       jsr Pop         ! number of characters to be writen.
+       ldy #0
+    1: lda (ADDR),y
+       cmp #10
+       bne 2f
+       pha
+       lda #13
+       jsr WRCH
+       pla
+    2: jsr WRCH
+       iny
+       dex
+       bne 1b
+       tya
+       tax
+       lda #0
+       jsr Push
+       tax
+       rts
+