Fix several bugs

This commit is contained in:
PleegWat
2026-09-05 16:37:51 +02:00
parent 2f09320fa5
commit 4c0cd79fdd
+10 -11
View File
@@ -334,11 +334,11 @@ li %r(register), %a:S33(immediate | label)
; assert(%a <= 0xffffffff, "%a is too high") ; assert(%a <= 0xffffffff, "%a is too high")
%s = trailing_zeros(%a) %s = trailing_zeros(%a)
%sa = %a >> %s %sa = %a >> %s
%nota = ~%a %nota = %a ^ 0xffffffff ; Needs xor; ~ operator does not generate leading high bits
when 0x0000 <= %a && %a <= 0xffff: 00110001 rrrr0000 %a[15:0] ; First 64k when %a <=u 0xffff : 00110001 %r[3:0]0000 %a[15:0] ; First 64k
when %nota <= 0xffff : 00110001 rrrr0000 %nota[15:0] 00100011 rrrr0000 0000rrrr 00000000 ; Last 64k when %nota <= 0xffff: 00110001 %r[3:0]0000 %nota[15:0] 00100011 %r[3:0]0000 0000%r[3:0] 00000000 ; Last 64k
when %sa < 0xffff : 00110001 rrrr0000 %sa[15:0] 00100011 rrrrrrrr 00000000 %s[7:0] ; Aligned when %sa <= 0xffff : 00110001 %r[3:0]0000 %sa[15:0] 00110111 %r[3:0]%r[3:0] 00000000 %s[7:0] ; Aligned
00110001 rrrr0000 %a[31:16] 00100111 rrrrrrrr 00000000 00010000 00110001 rrrrrrrr %a[15:0] ; Any 32-bit 00110001 %r[3:0]0000 %a[31:16] 00110111 %r[3:0]%r[3:0] 00000000 00010000 00110001 %r[3:0]%r[3:0] %a[15:0] ; Any 32-bit
# Load 32-bit immediate %a into %r # Load 32-bit immediate %a into %r
qcall %a:U32(label) qcall %a:U32(label)
@@ -348,14 +348,13 @@ qcall %a:U32(label)
%f = 15 %f = 15
%s = trailing_zeros(%a) %s = trailing_zeros(%a)
%sa = %a >> %s %sa = %a >> %s
%nota = ~%a %nota = %a ^ 0xffffffff ; Needs xor; ~ operator does not generate leading high bits
when 0x0000 <= %a && %a <= 0xffff: 01011000 rrrrffff %a[15:0] ; First 64k when %a <=u 0xffff : 01011000 %r[3:0]ffff %a[15:0] ; First 64k
when %nota <= 0xffff : 00110001 rrrr0000 %nota[15:0] 00100011 rrrr0000 0000rrrr 00000000 01001000 rrrrffff 0000rrrr 00000000 ; Last 64k when %nota <= 0xffff: 00110001 %r[3:0]0000 %nota[15:0] 00100011 %r[3:0]0000 0000%r[3:0] 00000000 01001000 %r[3:0]ffff 0000%r[3:0] 00000000 ; Last 64k
when %sa < 0xffff : 00110001 rrrr0000 %sa[15:0] 00100011 rrrrrrrr 00000000 %s[7:0] 01001000 rrrrffff 0000rrrr 00000000 ; Aligned when %sa <= 0xffff : 00110001 %r[3:0]0000 %sa[15:0] 00110111 %r[3:0]%r[3:0] 00000000 %s[7:0] 01001000 %r[3:0]ffff 0000%r[3:0] 00000000 ; Aligned
00110001 rrrr0000 %a[31:16] 00100111 rrrrrrrr 00000000 00010000 00110001 rrrrrrrr %a[15:0] 01001000 rrrrffff 0000rrrr 00000000 ; Any 32-bit 00110001 %r[3:0]0000 %a[31:16] 00110111 %r[3:0]%r[3:0] 00000000 00010000 00110001 %r[3:0]%r[3:0] %a[15:0] 01001000 %r[3:0]ffff 0000%r[3:0] 00000000 ; Any 32-bit
# Jump and link to 32-bit label # Jump and link to 32-bit label
halt%c(condition) halt%c(condition)
1000cccc 00001111 00000000 00000000 1000cccc 00001111 00000000 00000000
# Halt on condition %c # Halt on condition %c