Skip to content
Browse files

Start timer support

  • Loading branch information...
1 parent ea11388 commit 747bd125c78f0444f85f8e3fe676d90569786d20 @ekoeppen committed May 27, 2012
Showing with 19 additions and 7 deletions.
  1. +9 −6 generic/multitasking.ft
  2. +10 −1 lm3s811/precompiled_words.s
View
15 generic/multitasking.ft
@@ -2,7 +2,10 @@ HEX
0 DUP USER FOLLOWER \ points to the follower's STATUS variable
CELL - DUP USER STATUS \ PASS or WAKE - this needs to be one cell before FOLLOWER!
-CELL - USER TOS \ task's top of stack when switching
+CELL - DUP USER TOS \ task's top of stack when switching
+CELL - DUP USER WAKE-AT \ ticks when to wake the task regardless
+CELL - DUP USER WAKE-REASON \ reason for last wake
+NEGATE CONSTANT USER# \ save amount of allocated user variable space
: PAUSE \ suspend task at current execution point and switch to follower
RP@ \ push current rp
@@ -51,11 +54,11 @@ CELL - USER TOS \ task's top of stack when switching
;
: NEWTASK ( u s+r "name" -- ) ( -- tid )
- CREATE SWAP FOLLOWER TOS - + CELL + HERE + \ reserve user space and calculate TID
- DUP , \ save TID to pfa
- OVER + , \ save TOS to TOS field
- HERE PASS , , \ set STATUS to PASS and FOLLOWER to STATUS
- HERE 2 CELLS + , DUP HERE + , ALLOT \ set R0 and S0 and reserve stack space
+ CREATE SWAP USER# + CELL + HERE + \ reserve user space and calculate TID
+ DUP , \ save TID to pfa
+ OVER + , \ save TOS to TOS field
+ HERE PASS , , \ set STATUS to PASS and FOLLOWER to STATUS
+ HERE 2 CELLS + , DUP HERE + , ALLOT \ set R0 and S0 and reserve stack space
DOES> @
;
View
11 lm3s811/precompiled_words.s
@@ -744,6 +744,15 @@
defword "TOS", TOS, 0x0, USER_XT
.word 0xFFFFFFF8
+ defword "WAKE-AT", WAKE_AT, 0x0, USER_XT
+ .word 0xFFFFFFF4
+
+ defword "WAKE-REASON", WAKE_REASON, 0x0, USER_XT
+ .word 0xFFFFFFF0
+
+ defconst "USER#", USERNUM, 0x10
+
+
defword "PAUSE", PAUSE, 0x0
.word RPFETCH, SPFETCH, TOS, STORE, FOLLOWER, FETCH, GTR, EXIT
@@ -781,7 +790,7 @@
.word DUP, SLEEP, DUP, STATUS, TICKS, SWAP, FOLLOWER, TICKS, STORE, EXIT
defword "NEWTASK", NEWTASK, 0x0
- .word CREATE, SWAP, FOLLOWER, TOS, MINUS, PLUS, CELL, PLUS, HERE, PLUS, DUP, COMMA, OVER, PLUS, COMMA, HERE, PASS, COMMA, COMMA, HERE, LIT, 0x2, CELLS, PLUS, COMMA, DUP, HERE, PLUS, COMMA, ALLOT, LPARENDOESGTRPAREN
+ .word CREATE, SWAP, USERNUM, PLUS, CELL, PLUS, HERE, PLUS, DUP, COMMA, OVER, PLUS, COMMA, HERE, PASS, COMMA, COMMA, HERE, LIT, 0x2, CELLS, PLUS, COMMA, DUP, HERE, PLUS, COMMA, ALLOT, LPARENDOESGTRPAREN
.set NEWTASK_XT, .
.word 0x47884900, DODOES + 1, FETCH, EXIT

0 comments on commit 747bd12

Please sign in to comment.
Something went wrong with that request. Please try again.