duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit af6538df3b3df97cea64b92912cdeef5cce7e809
parent 0c6e6df3ec2ec310111330cd73b57b6754ce9948
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Fri, 15 Jul 2022 12:50:57 -0400

cc/vm: add the VM_*ARGSFRAME optype

Diffstat:
Mfs/cc/vm.fs | 16+++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/fs/cc/vm.fs b/fs/cc/vm.fs @@ -19,6 +19,7 @@ \ Constant: the value of the constant \ Stack Frame: the offset relative to the SF pointer +\ Arguments Frame: the offset relative to the AF pointer \ Register: the ID of the register \ On those operands, the VM generates code that perform operations on them. @@ -76,11 +77,12 @@ create registers AX c, BX c, CX c, DX c, SI c, DI c, $00 const VM_NONE $01 const VM_CONSTANT \ 42 $02 const VM_STACKFRAME \ ebp+x -$03 const VM_REGISTER \ eax -$04 const VM_CONSTARRAY \ pointer to an array with the 1st elem being length +$04 const VM_REGISTER \ eax +$05 const VM_CONSTARRAY \ pointer to an array with the 1st elem being length $11 const VM_*CONSTANT \ [1234] $12 const VM_*STACKFRAME \ [ebp+x] -$13 const VM_*REGISTER \ [eax] +$13 const VM_*ARGSFRAME \ [ebp+x] +$14 const VM_*REGISTER \ [eax] \ 2 operands, 2 fields each (type, arg), 4b per field create operands 16 allot0 @@ -113,7 +115,7 @@ operands value 'curop : const>op ( n -- ) noop# VM_CONSTANT optype! oparg! ; : constarray>op ( a -- ) noop# VM_CONSTARRAY optype! oparg! ; : sf+>op ( off -- ) noop# VM_*STACKFRAME optype! oparg! ; -: ps+>op locsz + sf+>op ; +: ps+>op ( off -- ) noop# VM_*ARGSFRAME optype! oparg! ; : mem>op ( n -- ) noop# VM_*CONSTANT optype! oparg! ; \ get current operand SF offset, adjusted with callsz @@ -127,6 +129,7 @@ operands value 'curop VM_REGISTER of = oparg r! endof VM_*CONSTANT of = oparg m) endof VM_*STACKFRAME of = bp opsf+ d) endof + VM_*ARGSFRAME of = bp opsf+ locsz + d) endof VM_*REGISTER of = oparg r! 0 d) endof _err endcase ; @@ -142,6 +145,7 @@ operands value 'curop opsf+ if dup r! opsf+ i) add, then ( regid ) oparg! VM_REGISTER optype! endof VM_*STACKFRAME of = _ VM_REGISTER optype! endof + VM_*ARGSFRAME of = _ VM_REGISTER optype! endof _err endcase ; @@ -152,6 +156,7 @@ operands value 'curop VM_STACKFRAME of = op>reg endof VM_*CONSTANT of = op>reg endof VM_*STACKFRAME of = op>reg endof + VM_*ARGSFRAME of = op>reg endof VM_*REGISTER of = oparg r! oparg r! 0 d) mov, VM_REGISTER optype! endof endcase ; @@ -175,6 +180,7 @@ operands value 'curop VM_*CONSTANT of = op>reg *op>op endof VM_STACKFRAME of = VM_*STACKFRAME optype! endof VM_*STACKFRAME of = op>reg *op>op endof + VM_*ARGSFRAME of = op>reg *op>op endof VM_REGISTER of = VM_*REGISTER optype! endof VM_*REGISTER of = opderef VM_*REGISTER optype! endof _err endcase ; @@ -288,7 +294,7 @@ operands value 'curop \ TODO: don't use both ops for this and thus allow post-inc and post-dec to run \ on either on the 2 ops : _ ( 'w -- ) - selop1 optype VM_*STACKFRAME = _assert + selop1 optype VM_*STACKFRAME = optype VM_*ARGSFRAME = or _assert selop2 noop# selop1 optype oparg selop2 oparg! optype! selop1 op>reg selop2 opAsm execute opdeinit selop1 ; : vmop++, ['] inc, _ ;