From 35c42fa89590f697fd6316c6a411fe919204b535 Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Mon, 21 Sep 2020 15:21:04 -0500 Subject: [PATCH] refactor ABORT etc.; add GETPID, GETTID, and RAISE --- jumpforth.S | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/jumpforth.S b/jumpforth.S index 8fd43d1..2df5c21 100644 --- a/jumpforth.S +++ b/jumpforth.S @@ -954,13 +954,21 @@ defword EMIT /* ( c-addr u -- ) */ defword DOTS,".S" -0: .int QDUP,ZBRANCH,(1f - .),SWAP,DUP,FETCHBYTE,EMIT - .int ADD1,SWAP,SUB1,BRANCH,(0b - .) +0: .int QDUP,ZBRANCH,(1f - .),OVER,FETCHBYTE,EMIT + .int SUB1,SWAP,ADD1,SWAP,BRANCH,(0b - .) 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 -0: .int SYS_GETPID,SYSCALL0,SYS_GETTID,SYSCALL0,SIGABRT,SYS_TGKILL,SYSCALL3,DROP,EXIT - .int BRANCH,(0b - .) +0: .int LIT,6,RAISE,DROP,BRANCH,(0b - .) defword ALLOT .int DUP,LIT,0,LT,ZBRANCH,(0f - .) @@ -1110,7 +1118,7 @@ defword DOT,"." /* n < pv && pv > 1, so divide pv by 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 */ -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 4: .int LIT,10,DIVMOD,NIP,BRANCH,(3b - .) /* n%pv pv/10 */