duskos

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

commit 42f38fc09b312c97c826d7706efceb4fae41263a
parent e12386d710b006bed11b9d221a3d21eb45a765f9
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Tue,  6 Dec 2022 20:21:24 -0500

asm/i386: fix mis-assembling of some imm8 ops

Diffstat:
Mfs/asm/i386.fs | 5++++-
Mfs/tests/asm/i386.fs | 7+++++++
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/fs/asm/i386.fs b/fs/asm/i386.fs @@ -81,7 +81,10 @@ : opimm, ( opcode opreg -- ) \ write the operation in "immediate" mode opreg! op8b not if - 1 or imm isbyte? if ( sign-extended imm8 ) 8b! 2 or then then + \ TODO: for now, we stay on the safe side for the 8b optimization because + \ some ops have a sign-extended imm8 and some ops don't, but we could do + \ better. + 1 or imm $80 < if ( sign-extended imm8 ) 8b! 2 or then then op, msd, imm, asm$ ; \ Setting arguments diff --git a/fs/tests/asm/i386.fs b/fs/tests/asm/i386.fs @@ -105,4 +105,11 @@ code foo9 ( n -- n ) 12 foo9 12 #eq 42 foo9 43 #eq 54 foo9 55 #eq + +\ the assembler used to mis-assemble ops with imm > $80 but < $100. +code foo10 ( n -- n ) + bp 0 d) $80 i) add, + ret, + +1 foo10 $81 #eq testend