refactor ABORT etc.; add GETPID, GETTID, and RAISE
This commit is contained in:
parent
19f12a45b9
commit
35c42fa895
18
jumpforth.S
18
jumpforth.S
|
|
@ -954,13 +954,21 @@ defword EMIT
|
||||||
|
|
||||||
/* ( c-addr u -- ) */
|
/* ( c-addr u -- ) */
|
||||||
defword DOTS,".S"
|
defword DOTS,".S"
|
||||||
0: .int QDUP,ZBRANCH,(1f - .),SWAP,DUP,FETCHBYTE,EMIT
|
0: .int QDUP,ZBRANCH,(1f - .),OVER,FETCHBYTE,EMIT
|
||||||
.int ADD1,SWAP,SUB1,BRANCH,(0b - .)
|
.int SUB1,SWAP,ADD1,SWAP,BRANCH,(0b - .)
|
||||||
1: .int DROP,EXIT
|
1: .int DROP,EXIT
|
||||||
|
|
||||||
|
defword GETPID
|
||||||
|
.int SYS_GETPID,SYSCALL0,EXIT
|
||||||
|
|
||||||
|
defword GETTID
|
||||||
|
.int SYS_GETTID,SYSCALL0,EXIT
|
||||||
|
|
||||||
|
defword RAISE
|
||||||
|
.int GETPID,GETTID,ROT,SYS_TGKILL,SYSCALL3,EXIT
|
||||||
|
|
||||||
defword ABORT
|
defword ABORT
|
||||||
0: .int SYS_GETPID,SYSCALL0,SYS_GETTID,SYSCALL0,SIGABRT,SYS_TGKILL,SYSCALL3,DROP,EXIT
|
0: .int LIT,6,RAISE,DROP,BRANCH,(0b - .)
|
||||||
.int BRANCH,(0b - .)
|
|
||||||
|
|
||||||
defword ALLOT
|
defword ALLOT
|
||||||
.int DUP,LIT,0,LT,ZBRANCH,(0f - .)
|
.int DUP,LIT,0,LT,ZBRANCH,(0f - .)
|
||||||
|
|
@ -1110,7 +1118,7 @@ defword DOT,"."
|
||||||
/* n < pv && pv > 1, so divide pv by 10 */
|
/* n < pv && pv > 1, so divide pv by 10 */
|
||||||
.int LIT,10,DIVMOD,NIP,BRANCH,(2b - .) /* n pv/10 */
|
.int LIT,10,DIVMOD,NIP,BRANCH,(2b - .) /* n pv/10 */
|
||||||
/* emit quotient+'0'; while pv > 1, divide pv by 10 and repeat with n%pv */
|
/* emit quotient+'0'; while pv > 1, divide pv by 10 and repeat with n%pv */
|
||||||
3: .int SWAP,OVER,DIVMOD,LIT,'0',ADD,EMIT,SWAP /* n%pv pv */
|
3: .int TUCK,DIVMOD,LIT,'0',ADD,EMIT,SWAP /* n%pv pv */
|
||||||
.int DUP,LIT,1,LE,ZBRANCH,(4f - .),TWODROP,EXIT
|
.int DUP,LIT,1,LE,ZBRANCH,(4f - .),TWODROP,EXIT
|
||||||
4: .int LIT,10,DIVMOD,NIP,BRANCH,(3b - .) /* n%pv pv/10 */
|
4: .int LIT,10,DIVMOD,NIP,BRANCH,(3b - .) /* n%pv pv/10 */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue