annotate 3rdparty/packages/basic09/syscall.asm @ 3229:7ee7d0c31787

Added more detailed comments for syscall.asm to aid programmers submitted on behalf of L. Curtis Boyle
author David Ladd <drencor-xeen@users.sourceforge.net>
date Wed, 31 Jan 2018 23:13:05 -0600
parents 57f23da9790a
children d1c60028af6e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
482
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
1 ********************************************************************
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
2 * SysCall - system call subroutine module
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
3 *
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
4 * $Id$
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
5 *
1326
57f23da9790a Changed headers
boisy
parents: 659
diff changeset
6 * Edt/Rev YYYY/MM/DD Modified by
57f23da9790a Changed headers
boisy
parents: 659
diff changeset
7 * Comment
482
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
8 * ------------------------------------------------------------------
1326
57f23da9790a Changed headers
boisy
parents: 659
diff changeset
9 * 2 ????/??/??
3229
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
10 * 2018/01/19 L. Curtis Boyle
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
11 * Added more detailed comments to aid programmers
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
12 *
1326
57f23da9790a Changed headers
boisy
parents: 659
diff changeset
13 * From OS-9 Level Two Vr. 2.00.01 Basic09 disk.
482
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
14
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
15 nam SysCall
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
16 ttl system call subroutine module
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
17
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
18 * Disassembled 02/07/06 13:11:18 by Disasm v1.6 (C) 1988 by RML
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
19
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
20 ifp1
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
21 use defsfile
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
22 endc
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
23
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
24 tylg set Sbrtn+Objct
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
25 atrv set ReEnt+rev
1326
57f23da9790a Changed headers
boisy
parents: 659
diff changeset
26 rev set $00
482
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
27 edition set 2
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
28
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
29 mod eom,name,tylg,atrv,start,size
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
30
3229
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
31 * Usage: RUN Syscall(call #,ptr to register data block)
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
32
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
33 * stack params for all RUNB/BASIC09 subroutine calls with RUN. The first 2 params are
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
34 * fixed (return address, and # of params passed). This is followed by pairs of:
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
35 * 1) Ptr to the data passed, and 2) the size of the parameter data,
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
36 * for each parameter passed.
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
37 * Since, as a subroutine module, we don't get our own data area, we either have to be
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
38 * passed a ptr to a "Safe zone" to manipulate, or use the stack. SYSCALL exclusively
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
39 * uses the stack, since it it doesn't need a lot of data memory.
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
40 org 0
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
41 Return rmb 2 0:Return address of caller
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
42 PCount rmb 2 2:# of params following
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
43 PrmPtr1 rmb 2 4:Ptr to 1st param data
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
44 PrmLen1 rmb 2 6:size of 1st param
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
45 PrmPtr2 rmb 2 8:Ptr to 2nd param data
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
46 PrmLen2 rmb 2 $A:size of 2nd param
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
47 PrmSize equ *
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
48
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
49 org 0
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
50 u0000 rmb 0 There is no data area for subroutine module
482
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
51 size equ .
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
52
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
53 name fcs /SysCall/
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
54 fcb edition
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
55
3229
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
56 start ldd PCount,s get number of parameters
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
57 cmpd #$0002 two? (system call #, ptr to register data being passed)
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
58 bne L005C if not, return with error
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
59 ldd PrmLen2,s get size of second parameter
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
60 cmpd #$0A Is the register packet the proper size (6809: CC,A,B,DP,X,Y,U=10 bytes)
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
61 bne L005C No, return with error
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
62 ldd [<PrmPtr1,s] Get System call # into D
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
63 ldx PrmLen1,s get size of first parameter
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
64 leax -$01,x 1 byte (BYTE type)?
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
65 beq L0034 Yes, continue
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
66 leax -$01,x 2 byte (INTEGER type)?
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
67 bne L005C No, and that's the only 2 we can handle for the system call #, so exit with error
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
68 tfr b,a It was a 2 byte INTEGER, but OS9 system calls only need 1, so move it A
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
69 L0034 ldb #$39 RTS instuction
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
70 pshs b,a put it and os9 system call # on stack
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
71 ldd #$103F get SWI2 instruction ('os9')
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
72 pshs b,a put on stack (so stack is now 'os9 x$nam' & 'rts')
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
73 ldu PrmPtr2+4,s get pointer to caller's registers on stack (+4 is because we just put SWI2 and RTS on stack)
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
74 ldd R$D,u R$D Get copies of registers from caller (no system calls have CC as input, or PC as input)
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
75 ldx R$X,u R$X
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
76 ldy R$Y,u R$Y
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
77 ldu R$U,u R$U
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
78 jsr ,s Call our little 4 byte routine on stack (os9 x$nam / rts) with register values passed to us
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
79 pshs u,cc Save U and CC
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
80 ldu PrmPtr2+7,s Get ptr to caller's registers on stack again (+7 now from our 4 byte routine, plus saving U&CC)
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
81 leau R$U,u Offset to caller's U register on stack (push works up, so we are leaving U alone at this point)
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
82 pshu y,x,dp,b,a Put 4 of the registers returned from system call into appropriate spots over callers original ones
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
83 puls x,a Get our saved copies of U and CC we got back from system call
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
84 sta ,-u Save CC overtop callers original CC (for error flag)
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
85 stx R$U,u Save U return back from system call overtop caller's original U
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
86 leas $04,s Eat the 4 byte instruction sequence we made
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
87 clrb Return to caller with no error (it's up to them to read their copies of CC and B to determine if an error happened)
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
88 rts
482
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
89
3229
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
90 L005C comb Return to caller with Parameter error (wrong quantity or wrong type)
482
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
91 ldb #E$ParmEr
3229
7ee7d0c31787 Added more detailed comments for syscall.asm to aid programmers
David Ladd <drencor-xeen@users.sourceforge.net>
parents: 1326
diff changeset
92 rts
482
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
93
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
94 emod
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
95 eom equ *
e4b03c2a7bec Removing D64 files to consolidate
boisy
parents:
diff changeset
96 end