duskos

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

commit dc1e74ade172d1925a664a433663f4d32a305ff6
parent 0708fcc1b5925de17523e7c691689a22f6f79a43
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sat,  4 Jun 2022 07:59:32 -0400

cc: add +

Diffstat:
Mfs/asm.fs | 12++++++------
Mfs/cc/ops.fs | 2+-
Mfs/test.c | 4++--
Mtests/testcc.fs | 2+-
4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/fs/asm.fs b/fs/asm.fs @@ -53,14 +53,14 @@ : modrm1, ( reg op -- ) \ modrm op with 1 argument prefix, c, ( reg ) 3 lshift tgtid tgt mod or or ( modrm ) c, disp? if disp c, then asm$ ; -: modrm2, ( imm? op -- ) \ modrm op with 2 arguments - prefix, c, tgtid tgt mod or ( modrm ) - isimm? if $28 or ( 5 in reg ) c, , else src 3 lshift or c, then - disp? if disp c, then asm$ ; +: modrm2, ( imm? reg op -- ) \ modrm op with 2 arguments + prefix, c, 3 lshift tgtid or tgt mod or ( modrm ) c, + isimm? if , then disp? if disp c, then asm$ ; \ operations -: mov, isimm? if prefix, $b8 tgtid or c, , asm$ else $89 modrm2, then ; +: add, isimm? if 0 $81 else src $01 then modrm2, ; +: mov, isimm? if prefix, $b8 tgtid or c, , asm$ else src $89 modrm2, then ; : neg, 3 $f7 modrm1, ; : not, 2 $f7 modrm1, ; -: sub, isimm? if $81 else $29 then modrm2, ; +: sub, isimm? if 5 $81 else src $29 then modrm2, ; : ret, $c3 inh, ; diff --git a/fs/cc/ops.fs b/fs/cc/ops.fs @@ -38,7 +38,7 @@ create bopssyms ," +-*/?" : bopchar ( opid -- c ) BOPSCNT max bopssyms + c@ ; BOPSCNT wordtbl opgentbl ( -- ) -:w ( + ) abort" TODO" ; +:w ( + ) reg>> add, ; :w ( - ) reg>> sub, ; :w ( * ) abort" TODO" ; :w ( / ) abort" TODO" ; diff --git a/fs/test.c b/fs/test.c @@ -5,6 +5,6 @@ int neg() {return -42;} int bwnot() { return ~42; } -int subconsts () { - return 42 - 4; +int exprbinops() { + return 42 - 4 + 2; } diff --git a/tests/testcc.fs b/tests/testcc.fs @@ -14,4 +14,4 @@ cc1, retconst 42 #eq neg -42 #eq bwnot $ffffffd5 #eq -subconsts 38 #eq +exprbinops 40 #eq