commit 3ac5393ec8c289a4dc580770836856e1758f9037
parent 46585f551858e4c5316d51ea8f86679d625a9e35
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Wed, 5 Apr 2023 19:57:54 -0400
hal: avoid name clashes with assembler mnemonics
will save us some troubles down the road...
Diffstat:
8 files changed, 58 insertions(+), 55 deletions(-)
diff --git a/fs/comp/c/egen.fs b/fs/comp/c/egen.fs
@@ -27,8 +27,8 @@ alias noop parseFactor ( tok -- res ) \ forward declaration
over Result :isconst? if
CELLSZ + @ over Result arg swap execute over to Result arg
else @ over Result :?>W execute then ( res ) ;
-unaryop _neg, neg, neg
-: _ -1 i) xor, ;
+unaryop _neg, negate, neg
+: _ -1 i) ^, ;
unaryop _not, _ ^
: _ W=0>Z, Z) C>W, ;
unaryop _!, _ not
@@ -51,9 +51,9 @@ UOPSCNT wordtbl uoptbl ( res -- res )
\ ops that can freely swap their operands
: _prep ( left right -- left halop )
dup Result :hasW? if swap then over Result :?>W Result :hal$ ;
-: _*, _prep *, ; : _&, _prep and, ; : _^, _prep xor, ; : _|, _prep or, ;
+: _*, _prep *, ; : _&, _prep &, ; : _^, _prep ^, ; : _|, _prep |, ;
: _&&, _prep W=0>Z, 0 Z) branchC, swap @, W=0>Z, [compile] then NZ) C>W, ;
-: _||, _prep or, W=0>Z, NZ) C>W, ;
+: _||, _prep |, W=0>Z, NZ) C>W, ;
: _arimul ( left right -- left right*n )
over Result :*arisz over Result :*arisz <> if
@@ -80,7 +80,7 @@ UOPSCNT wordtbl uoptbl ( res -- res )
Result :?freeCurrentW Result :?>W$ dup Result :hal# <>) ;
: _=, _prep @, ; : _-=, _prep -, ;
: _*=, _prep *, ; : _/=, _prep /, ; : _%=, _prep %, ;
-: _&=, _prep and, ; : _^=, _prep xor, ; : _|=, _prep or, ;
+: _&=, _prep &, ; : _^=, _prep ^, ; : _|=, _prep |, ;
: _<<=, _prep <<, ; : _>>=, _prep >>, ;
: _+=,
@@ -93,7 +93,7 @@ UOPSCNT wordtbl uoptbl ( res -- res )
: cmpop doer 4 for ' execute , next does> ( left right 'conds )
over Result :unsigned? not if CELLSZ << + then
over Result :isW? if CELLSZ + @ >r swap else @ >r then ( left right )
- Result :?freeCurrentW over Result :?>W Result :hal$ cmp, r> C>W, ;
+ Result :?freeCurrentW over Result :?>W Result :hal$ compare, r> C>W, ;
cmpop _==, Z) Z) Z) Z) cmpop _!=, NZ) NZ) NZ) NZ)
cmpop _<, <) >=) s<) s>=) cmpop _<=, <=) >) s<=) s>)
cmpop _>, >) <=) s>) s<=) cmpop _>=, >=) <) s>=) s<)
diff --git a/fs/comp/c/expr.fs b/fs/comp/c/expr.fs
@@ -111,7 +111,7 @@ struct[ Result
: :typecast ( cdecl self -- )
dup :hasW? if
over typesize over cdecl typesize < if
- over typesize 1- CELLSZ * _masks + @ i) and, then
+ over typesize 1- CELLSZ * _masks + @ i) &, then
else over typesize over cdecl typesize > if dup :?>W then then
over swap to@! cdecl swap ( old new )
over CDecl storage over to CDecl storage
diff --git a/fs/comp/c/fgen.fs b/fs/comp/c/fgen.fs
@@ -79,10 +79,10 @@ alias noop parseStatement ( tok -- ) \ forward declaration
code _lookup ( nref lookup -- )
W>A, A) @,
-8 rs+, RSP) 4 +) !, 0 LIT>W, RSP) !, begin \ RS+0=i RS+4=totcnt
- RSP) @, RSP) 4 +) cmp, 0 NZ) branchC, \ not found
+ RSP) @, RSP) 4 +) compare, 0 NZ) branchC, \ not found
8 rs+, nip, exit, then
1 RSP) [+n], CELLSZ A+n, A) @,
- PSP) cmp, NZ) branchC, drop \ Z=match
+ PSP) compare, NZ) branchC, drop \ Z=match
\ we have a match, add totcnt*CELLSZ to A, dereference. that's our target.
RSP) 4 +) @, 2 <<n, RSP) !, W<>A, RSP) +, W) @, \ W=target
12 rs+, W>A, nip, branchA,
diff --git a/fs/doc/hal.txt b/fs/doc/hal.txt
@@ -194,26 +194,26 @@ branchA, --
Instructions:
-@, op -- Read source into W
-!, op -- Write W to source
-@!, op -- Swap W and source
-+, op -- *Z* Add source to W
-[@], op -- Read indirect source into W
-[!], op -- Write indirect source into W
-cmp, op -- Compare source to W
-[+n], n op -- *Z* Add n to indirect source without affecting W
-
-ps+, n -- Add n to PSP
-rs+, n -- Add n to RSP
-W+n, n -- *Z* Add n to W
-A+n, n -- *Z* Add n to W
-W>A, -- Copy W to A
-A>W, -- Copy A to W
-W<>A, -- Swap W and A
-lea, op -- Store the effective address of the operand in W
-neg, -- W = -W
-<<n, n -- Shift W left by n
->>n, n -- Shift W right by n
+@, op -- Read source into dest
+!, op -- Write dest to source
+@!, op -- Swap dest and source
++, op -- *Z* Add source to dest
+[@], op -- Read indirect source into dest
+[!], op -- Write indirect source into dest
+compare, op -- Compare source to dest
+[+n], n op -- *Z* Add n to indirect source without affecting dest
+&, op -- Store the effective address of the operand in dest
+
+ps+, n -- Add n to PSP
+rs+, n -- Add n to RSP
+W+n, n -- *Z* Add n to W
+A+n, n -- *Z* Add n to A
+W>A, -- Copy W to A
+A>W, -- Copy A to W
+W<>A, -- Swap W and A
+negate, -- dest = -dest
+<<n, n -- Shift dest left by n
+>>n, n -- Shift dest right by n
## High HAL
@@ -239,9 +239,12 @@ s>=)
Instructions:
--, op -- W - operand
-*, op -- W * operand
-/, op -- W / operand
-%, op -- W modulo operand
-<<, op -- W lshift operand
->>, op -- W rshift operand
+-, op -- dest - operand
+*, op -- dest * operand
+/, op -- dest / operand
+%, op -- dest modulo operand
+<<, op -- dest lshift operand
+>>, op -- dest rshift operand
+&, op -- dest and operand
+|, op -- dest or operand
+^, op -- dest xor operand
diff --git a/fs/tests/asm/hal.fs b/fs/tests/asm/hal.fs
@@ -44,7 +44,7 @@ test4 8 #eq
code test5 ( -- n )
dup, -8 rs+,
42 LIT>W, RSP) !,
- RSP) lea,
+ RSP) addr,
RSP) 4 +) !, \ reference to RS+0 in RS+4
\ Now, let's dereference
RSP) 4 +) [@],
@@ -54,7 +54,7 @@ test5 42 #eq
\ assign and dereference
code test6
dup, -8 rs+,
- RSP) lea,
+ RSP) addr,
RSP) 4 +) !, \ reference to RS+0 in RS+4
\ Now, let's assign-dereference
54 LIT>W,
@@ -80,7 +80,7 @@ test8 43 #eq
\ Jumps
code test9 ( n -- n ) \ returns 42 if arg >= 10, 54 otherwise
- 10 i) cmp,
+ 10 i) compare,
0 <) branchC,
42 LIT>W, exit,
then
@@ -123,7 +123,7 @@ test12 85 #eq
code test13 ( -- n )
dup, -8 rs+,
42 LIT>W, RSP) !,
- RSP) lea, RSP) 4 +) !,
+ RSP) addr, RSP) 4 +) !,
54 LIT>W,
RSP) 4 +) [!],
RSP) @,
diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs
@@ -55,7 +55,7 @@ code16b W>A, drop, A) 16b) [!], 2 A) [+n], drop, exit,
code8b W>A, drop, A) 8b) [!], 1 A) [+n], drop, exit,
code + PSP) +, nip, exit,
-code - neg, PSP) +, nip, exit,
+code - negate, PSP) +, nip, exit,
: -^ swap - ;
: e>w 5 + ;
: w>e 5 - ;
@@ -108,7 +108,7 @@ code ?dup W=0>Z, 0 Z) branchC, dup, then exit,
: min ?swap drop ; : max ?swap nip ;
: max0 ( n -- n ) dup 0< if drop 0 then ;
: =><= ( n l h -- f ) over - rot> ( h n l ) - >= ;
-code neg neg, exit,
+code neg negate, exit,
: ^ -1 xor ;
: and? bool swap bool and ;
: or? or bool ;
@@ -120,8 +120,8 @@ code neg neg, exit,
: r@ dup, RSP) @, ; immediate
: r> [compile] r@ [compile] rdrop ; immediate
: >r -4 rs+, RSP) !, drop, ; immediate
-code scnt dup, PSP) lea, ] PSTOP -^ >> >> 1- ;
-code rcnt dup, RSP) lea, ] RSTOP -^ >> >> ;
+code scnt dup, PSP) addr, ] PSTOP -^ >> >> 1- ;
+code rcnt dup, RSP) addr, ] RSTOP -^ >> >> ;
: while [compile] if swap ; immediate
: repeat [compile] again [compile] then ; immediate
@@ -171,8 +171,8 @@ _to to@+ @@+ _@@+,
:16b dup 16b) [!], 2 swap [+n], drop, ;
:8b dup 8b) [!], 1 swap [+n], drop, ;
_to to!+ @!+ _@!+,
-: _lea, dup, lea, ; :16b dup, lea, ; :8b dup, lea, ;
-_to to' noop _lea,
+: _addr, dup, addr, ; :16b dup, addr, ; :8b dup, addr, ;
+_to to' noop _addr,
: _toexec ( a -- ) compiling if m) then toptr@ execute ;
: value doer , immediate does> _toexec ;
: here HERE _toexec ; immediate
@@ -267,7 +267,7 @@ code (s) r@ W>A, W) 8b) @, 1 W+n, RSP) +, rdrop W<>A, branchA,
code []= ( a1 a2 u -- f )
W=0>Z, 0 Z) branchC, PSP) @!, W>A, begin \ P+4=a1 P+0=u A=a2
- PSP) 4 +) 8b) [@], A) 8b) cmp, 0 Z) branchC,
+ PSP) 4 +) 8b) [@], A) 8b) compare, 0 Z) branchC,
8 ps+, 0 LIT>W, exit, then
1 A+n, 1 PSP) 4 +) [+n], -1 PSP) [+n], NZ) branchC, drop then
8 ps+, 1 LIT>W, exit,
diff --git a/fs/xcomp/i386/kernel.fs b/fs/xcomp/i386/kernel.fs
@@ -252,10 +252,10 @@ xcode @!, ( operand -- ) \ operand ax xchg,
xcode +, ( operand -- ) \ ax operand add,
ax $0200 i) or, L1 absjmp,
-xcode cmp, ( operand -- ) \ ax operand cmp,
+xcode compare, ( operand -- ) \ ax operand cmp,
ax $3a00 i) or, L1 absjmp,
-xcode lea, ( operand -- ) \ ax operand lea,
+xcode addr, ( operand -- ) \ ax operand lea,
ax $8d00 i) or, L1 absjmp,
xcode [@], ( operand -- ) \ ax 32b) operand mov, ax Xb) ax 0 d) mov,
@@ -304,7 +304,7 @@ xcode exit,
$c3 ( ret ) i) cwrite,
ret,
-xcode neg, ( -- ) \ ax neg,
+xcode negate, ( -- ) \ ax neg,
$d8f7 i) wwrite, ret,
xcode W=0>Z, $c085 i) wwrite, ret, \ ax ax test,
diff --git a/posix/vm.c b/posix/vm.c
@@ -982,7 +982,7 @@ static void buildsysdict() {
entry("@!,"); compopwr(0x12); retwr();
// ( n ?disp operand -- )
entry("[+n],"); compopwr(0x13); writewr(); retwr();
- entry("cmp,"); compopwr(0x14); retwr();
+ entry("compare,"); compopwr(0x14); retwr();
entry("[@],"); compopwr(0x15); retwr();
entry("[!],"); compopwr(0x16); retwr();
entry("+,"); compbinopwr(0x00); retwr();
@@ -992,11 +992,11 @@ static void buildsysdict() {
entry("%,"); compbinopwr(0x04); retwr();
entry("<<,"); compbinopwr(0x05); retwr();
entry(">>,"); compbinopwr(0x06); retwr();
- entry("and,"); compbinopwr(0x08); retwr();
- entry("or,"); compbinopwr(0x09); retwr();
- entry("xor,"); compbinopwr(0x0a); retwr();
- entry("lea,"); compopwr(0x17); retwr();
- entry("neg,"); compileop(0x4e); retwr();
+ entry("&,"); compbinopwr(0x08); retwr();
+ entry("|,"); compbinopwr(0x09); retwr();
+ entry("^,"); compbinopwr(0x0a); retwr();
+ entry("addr,"); compopwr(0x17); retwr();
+ entry("negate,"); compileop(0x4e); retwr();
entry("W=0>Z,"); compileop(0x5d); retwr();
entry("C>W,"); compileop(0x5e); cwritewr(); retwr();
entry("A=0>Z,"); compileop(0x5f); retwr();