duskos

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

commit cc6857bc99a6f7c04137559ac3bb2dff3501f535
parent 7163e7b1fd80b1f4a40759c5cd2b51439b5b7d55
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Wed, 30 Nov 2022 16:48:39 -0500

comp/c/vm/i386: fix integer promotion bug with << >> * /

This created a bug in ar/puff in dynamic blocks.

Diffstat:
Mfs/comp/c/vm/i386.fs | 4++--
Mfs/tests/comp/c/cc.fs | 1+
Mfs/tests/comp/c/test.c | 4++++
3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/comp/c/vm/i386.fs b/fs/comp/c/vm/i386.fs @@ -212,10 +212,10 @@ ASSIGNOPCNT wordtbl _tbl cx dx mov, vmop arg DX = if CX to vmop arg then else CL regfree then ; : ariop, ( opid -- ) - vmop :>res + vmop :>res harmonizeops dup _mulop? if _mulop exit then dup _shcl? if _shcl exit then - harmonizeops vmop :compilesz vmop^ :compile + vmop :compilesz vmop^ :compile _tbl swap wexec vmop^ :init ; : _movarray diff --git a/fs/tests/comp/c/cc.fs b/fs/tests/comp/c/cc.fs @@ -96,6 +96,7 @@ opwidth3 $129 #eq opwidth4 14 #eq opwidth5 42 #eq opwidth6 1 #eq +$ff 1 opwidth7 $1fe #eq 42 50 ptrari3 46 #eq 41 value myval to' myval ptrari4 not # diff --git a/fs/tests/comp/c/test.c b/fs/tests/comp/c/test.c @@ -437,6 +437,10 @@ short opwidth6() { short y = 0; if (y) return 0; else return 1; } +// The i386 VM didn't properly promote "a" to int +int opwidth7(char a, int b) { + return a << b; +} // when subtracting 2 pointers, the result is considered a scalar for the // remainder of the expression. int* ptrari3(int *lo, int *hi) {