annotate level2/modules/kernel/fcpymem.asm @ 1631:ec6fb5543b22

Robert Gault's modifications for correcting timing errors
author boisy
date Mon, 12 Jul 2004 01:38:08 +0000
parents 1da8ab9ba433
children 039ddb7c8ad7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1345
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
1 **************************************************
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
2 * System Call: F$CpyMem
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
3 *
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
4 * Function: Copy external memory
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
5 *
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
6 * Input: D = Starting memory block number
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
7 * X = Offset in block to begin copy
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
8 * Y = Byte count
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
9 * U = Caller's destination buffer
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
10 *
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
11 * Output: None
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
12 *
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
13 * Error: CC = C bit set; B = error code
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
14 *
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
15 IFNE H6309
1345
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
16 * F$CpyMem for NitrOS-9 Level Two
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
17 * Notes:
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
18 * We currently check to see if the end of the buffer we are
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
19 * copying to will overflow past $FFFF, and exit if it does.
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
20 * Should this be changed to check if it overflows past the
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
21 * data area of a process, or at least into Vector page RAM
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
22 * and I/O ($FE00-$FFFF)???
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
23 *
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
24 FCpyMem ldd R$Y,u get byte count
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
25 beq L0A01 nothing there so nothing to move, return
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
26 addd R$U,u add it caller's buffer start ptr.
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
27 cmpa #$FE Is it going to overwrite Vector or I/O pages?
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
28 bhs L0A01 Yes, exit without error
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
29 leas -$10,s make a buffer for DAT image
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
30 leay ,s point to it
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
31 pshs y,u Preserve stack buffer ptr & register stack pointer
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
32 ldx <D.Proc Get caller's task #
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
33 ldf P$Task,x get task # of caller
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
34 leay P$DATImg,x Point to DAT image in callers's process dsc.
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
35 ldx R$D,u get caller's DAT image pointer
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
36 lde #$08 counter (for double byte moves)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
37 ldu ,s get temp. stack buffer pointer
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
38
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
39 * This loop copies the DAT image from the caller's process descriptor into
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
40 * a temporary buffer on the stack
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
41 L09C7 equ *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
42 clrd Clear offset to 0
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
43 bsr L0B02 Short cut OS9 F$LDDDXY
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
44 std ,u++ save it to buffer
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
45 leax 2,x Bump ptr
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
46 dece Decrement loop counter
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
47 bne L09C7 Keep doing until 16 bytes is done
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
48
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
49 ldu 2,s Get back register stack pointer
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
50 lbsr L0CA6 Short cut OS9 F$ResTsk
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
51 bcs L09FB If error, deallocate our stack & exit with error
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
52 tfr b,e New temp task # into E
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
53 lslb Multiply by 2 for 2 byte entries
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
54 ldx <D.TskIPt Get ptr to task image table
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
55 * Make new temporary task use the memory blocks from the requested DAT image
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
56 * from the caller, to help do a 1 shot F$Move command, because in general
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
57 * the temporary DAT image is not associated with a task.
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
58 ldu ,s Get pointer to DAT image we just copied
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
59 stu b,x Point new task image table to our DAT image copy
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
60 ldu 2,s Get back data area pointer
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
61 tfr w,d Move temp & caller's task #'s into proper regs.
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
62 pshs a Save new task #
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
63 bsr L0B25 F$Move the memory into the caller's requested area
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
64 * BAD Bug! Well, maybe not. F$Move NEVER returns an error code
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
65 * but if it did, we'd skip the $RelTsk, and have an orphan task
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
66 * left over.
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
67 * bcs L09FB If error, purge stack & return with error code
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
68 puls b Get back new task #
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
69 lbsr L0CC3 Short cut OS9 F$RelTsk
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
70 L09FB leas <$14,s Purge our stack buffer & return
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
71 rts
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
72
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
73 L0A01 clrb No error & exit
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
74 rts
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
75
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
76
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
77 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
78
1345
1da8ab9ba433 Added consistent comments to each system call
boisy
parents: 1145
diff changeset
79 * F$CpyMem for OS-9 Level Two
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
80 FCpyMem ldd R$Y,u byte count
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
81 beq L0A01 ..skip if none
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
82 addd R$U,u plus dest buff
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
83 bcs L0A01
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
84 leas -$10,s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
85 leay ,s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
86 pshs a,b,y save buff end,img ptr
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
87 ldx <D.Proc
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
88 ldb P$Task,X
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
89 pshs b save caller task#
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
90 leay P$DATImg,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
91 ldx R$D,u X=caller DAT img ptr
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
92 ldb #8
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
93 pshs b,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
94 ldu P$Task,s U=tempdat ptr
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
95
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
96 L09C7 clra D=0000
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
97 clrb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
98 os9 F$LDDDXY move user DAT image
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
99 std ,u++ to sys tempDAT img
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
100 leax 2,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
101 dec ,s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
102 bne L09C7 ..loop
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
103
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
104 puls b,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
105 ldx R$X,u X=offset
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
106 ldu R$U,u U=dest buffer
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
107 ldy 3,s Y=tmpDAT
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
108
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
109 puls b
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
110 bra L09E7
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
111
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
112 N09D6 leax $E000,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
113 leay 2,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
114
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
115 *------------------------------------------------*
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
116 * Copy Loop:
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
117
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
118 L09E7 cmpx #$2000
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
119 bcc N09D6
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
120
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
121 L09EC os9 F$LDAXY get byte
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
122 leax 1,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
123 exg x,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
124
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
125 os9 F$STABX store byte
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
126 leax 1,x plus one
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
127 cmpx ,s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
128 exg x,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
129 bcs L09E7
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
130 leas $14,s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
131
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
132 L0A01 clrb ok
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
133 rts end.
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
134
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
135 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
136