changing uint to be the default

This commit is contained in:
Jakub Doka 2024-10-25 14:51:33 +02:00
parent 64e228450f
commit 6988d8893f
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143
14 changed files with 357 additions and 233 deletions

View file

@ -40,29 +40,29 @@ Following examples incrementally introduce language features and syntax.
#### main_fn #### main_fn
```hb ```hb
main := fn(): int { main := fn(): uint {
return 1 return 1
} }
``` ```
#### arithmetic #### arithmetic
```hb ```hb
main := fn(): int { main := fn(): uint {
return 10 - 20 / 2 + 4 * (2 + 2) - 4 * 4 + (1 << 0) + -1 return 10 - 20 / 2 + 4 * (2 + 2) - 4 * 4 + (1 << 0) + -1
} }
``` ```
#### functions #### functions
```hb ```hb
main := fn(): int { main := fn(): uint {
return add_one(10) + add_two(20) return add_one(10) + add_two(20)
} }
add_two := fn(x: int): int { add_two := fn(x: uint): uint {
return x + 2 return x + 2
} }
add_one := fn(x: int): int { add_one := fn(x: uint): uint {
return x + 1 return x + 1
} }
``` ```
@ -70,7 +70,7 @@ add_one := fn(x: int): int {
#### comments #### comments
```hb ```hb
// commant is an item // commant is an item
main := fn(): int { main := fn(): uint {
// comment is a statement // comment is a statement
foo(/* comment is an exprression /* if you are crazy */ */) foo(/* comment is an exprression /* if you are crazy */ */)
@ -84,11 +84,11 @@ foo := fn(comment: void): void return /* comment evaluates to void */
#### if_statements #### if_statements
```hb ```hb
main := fn(): int { main := fn(): uint {
return fib(10) return fib(10)
} }
fib := fn(x: int): int { fib := fn(x: uint): uint {
if x <= 2 { if x <= 2 {
return 1 return 1
} else { } else {
@ -99,7 +99,7 @@ fib := fn(x: int): int {
#### variables #### variables
```hb ```hb
main := fn(): int { main := fn(): uint {
ඞ := 1 ඞ := 1
b := 2 b := 2
ඞ += 1 ඞ += 1
@ -109,11 +109,11 @@ main := fn(): int {
#### loops #### loops
```hb ```hb
main := fn(): int { main := fn(): uint {
return fib(10) return fib(10)
} }
fib := fn(n: int): int { fib := fn(n: uint): uint {
a := 0 a := 0
b := 1 b := 1
loop if n == 0 break else { loop if n == 0 break else {
@ -128,7 +128,7 @@ fib := fn(n: int): int {
#### pointers #### pointers
```hb ```hb
main := fn(): int { main := fn(): uint {
a := 1 a := 1
b := &a b := &a
@ -142,12 +142,12 @@ main := fn(): int {
return *b - 2 return *b - 2
} }
modify := fn(a: ^int): void { modify := fn(a: ^uint): void {
*a = 2 *a = 2
return return
} }
drop := fn(a: int): void { drop := fn(a: uint): void {
return return
} }
``` ```
@ -157,17 +157,17 @@ drop := fn(a: int): void {
Ty := struct { Ty := struct {
// comment // comment
a: int, a: uint,
} }
Ty2 := struct { Ty2 := struct {
ty: Ty, ty: Ty,
c: int, c: uint,
} }
useless := struct {} useless := struct {}
main := fn(): int { main := fn(): uint {
// `packed` structs have no padding (all fields are alighred to 1) // `packed` structs have no padding (all fields are alighred to 1)
if @sizeof(packed struct {a: u8, b: u16}) != 3 { if @sizeof(packed struct {a: u8, b: u16}) != 3 {
return 9001 return 9001
@ -181,7 +181,7 @@ main := fn(): int {
return 0 return 0
} }
pass := fn(t: ^Ty): int { pass := fn(t: ^Ty): uint {
return t.a return t.a
} }
@ -192,7 +192,7 @@ odher_pass := fn(t: Ty2): Ty2 {
#### hex_octal_binary_literals #### hex_octal_binary_literals
```hb ```hb
main := fn(): int { main := fn(): uint {
hex := 0xFF hex := 0xFF
decimal := 255 decimal := 255
octal := 0o377 octal := 0o377
@ -208,8 +208,8 @@ main := fn(): int {
#### struct_operators #### struct_operators
```hb ```hb
Point := struct { Point := struct {
x: int, x: uint,
y: int, y: uint,
} }
Rect := struct { Rect := struct {
@ -219,7 +219,7 @@ Rect := struct {
Color := packed struct {b: u8, g: u8, r: u8, a: u8} Color := packed struct {b: u8, g: u8, r: u8, a: u8}
main := fn(): int { main := fn(): uint {
i := Color.(0, 0, 0, 0) i := Color.(0, 0, 0, 0)
i += .(1, 1, 1, 1) i += .(1, 1, 1, 1)
if i.r + i.g + i.b + i.a != 4 { if i.r + i.g + i.b + i.a != 4 {
@ -245,14 +245,14 @@ global_var := 10
complex_global_var := fib(global_var) - 5 complex_global_var := fib(global_var) - 5
fib := fn(n: int): int { fib := fn(n: uint): uint {
if 2 > n { if 2 > n {
return n return n
} }
return fib(n - 1) + fib(n - 2) return fib(n - 1) + fib(n - 2)
} }
main := fn(): int { main := fn(): uint {
complex_global_var += 5 complex_global_var += 5
return complex_global_var return complex_global_var
} }
@ -263,7 +263,7 @@ note: values of global variables are evaluated at compile time
```hb ```hb
foo := @use("foo.hb") foo := @use("foo.hb")
main := fn(): int { main := fn(): uint {
byte := @as(u8, 10) byte := @as(u8, 10)
same_type_as_byte := @as(@TypeOf(byte), 30) same_type_as_byte := @as(@TypeOf(byte), 30)
wide_uint := @as(u32, 40) wide_uint := @as(u32, 40)
@ -271,7 +271,7 @@ main := fn(): int {
size_of_Type_in_bytes := @sizeof(foo.Type) size_of_Type_in_bytes := @sizeof(foo.Type)
align_of_Type_in_bytes := @alignof(foo.Type) align_of_Type_in_bytes := @alignof(foo.Type)
hardcoded_pointer := @as(^u8, @bitcast(10)) hardcoded_pointer := @as(^u8, @bitcast(10))
ecall_that_returns_int := @as(int, @eca(1, foo.Type.(10, 20), 5, 6)) ecall_that_returns_uint := @as(uint, @eca(1, foo.Type.(10, 20), 5, 6))
embedded_array := @as([u8; 15], @embed("text.txt")) embedded_array := @as([u8; 15], @embed("text.txt"))
return @inline(foo.foo) return @inline(foo.foo)
} }
@ -279,11 +279,11 @@ main := fn(): int {
// in module: foo.hb // in module: foo.hb
Type := struct { Type := struct {
brah: int, brah: uint,
blah: int, blah: uint,
} }
foo := fn(): int return 0 foo := fn(): uint return 0
// in module: text.txt // in module: text.txt
arbitrary text arbitrary text
@ -292,7 +292,7 @@ arbitrary text
- `@use(<string>)`: imports a module based of string, the string is passed to a loader that can be customized, default loader uses following syntax: - `@use(<string>)`: imports a module based of string, the string is passed to a loader that can be customized, default loader uses following syntax:
- `((rel:|)(<path>)|git:<git-addr>:<path>)`: `rel:` and `''` prefixes both mean module is located at `path` relavive to the current file, `git:` takes a git url without `https://` passed as `git-addr`, `path` then refers to file within the repository - `((rel:|)(<path>)|git:<git-addr>:<path>)`: `rel:` and `''` prefixes both mean module is located at `path` relavive to the current file, `git:` takes a git url without `https://` passed as `git-addr`, `path` then refers to file within the repository
- `@TypeOf(<expr>)`: results into literal type of whatever the type of `<expr>` is, `<expr>` is not included in final binary - `@TypeOf(<expr>)`: results into literal type of whatever the type of `<expr>` is, `<expr>` is not included in final binary
- `@as(<ty>, <expr>)`: hint to the compiler that `@TypeOf(<expr>) == <ty>` - `@as(<ty>, <expr>)`: huint to the compiler that `@TypeOf(<expr>) == <ty>`
- `@intcast(<expr>)`: needs to be used when conversion of `@TypeOf(<expr>)` would loose precision (widening of integers is implicit) - `@intcast(<expr>)`: needs to be used when conversion of `@TypeOf(<expr>)` would loose precision (widening of integers is implicit)
- `@sizeof(<ty>), @alignof(<ty>)`: I think explaining this would insult your intelligence - `@sizeof(<ty>), @alignof(<ty>)`: I think explaining this would insult your intelligence
- `@bitcast(<expr>)`: tell compiler to assume `@TypeOf(<expr>)` is whatever is inferred, so long as size and alignment did not change - `@bitcast(<expr>)`: tell compiler to assume `@TypeOf(<expr>)` is whatever is inferred, so long as size and alignment did not change
@ -301,7 +301,7 @@ arbitrary text
#### c_strings #### c_strings
```hb ```hb
str_len := fn(str: ^u8): int { str_len := fn(str: ^u8): uint {
len := 0 len := 0
loop if *str == 0 break else { loop if *str == 0 break else {
len += 1 len += 1
@ -310,7 +310,7 @@ str_len := fn(str: ^u8): int {
return len return len
} }
main := fn(): int { main := fn(): uint {
// when string ends with '\0' its a C string and thus type is '^u8' // when string ends with '\0' its a C string and thus type is '^u8'
some_str := "abඞ\n\r\t\{35}\{36373839}\0" some_str := "abඞ\n\r\t\{35}\{36373839}\0"
len := str_len(some_str) len := str_len(some_str)
@ -324,7 +324,7 @@ main := fn(): int {
```hb ```hb
.{fib, fib_iter, Fiber} := @use("fibs.hb") .{fib, fib_iter, Fiber} := @use("fibs.hb")
main := fn(): int { main := fn(): uint {
.{a, b} := Fiber.{a: 10, b: 10} .{a, b} := Fiber.{a: 10, b: 10}
return fib(a) - fib_iter(b) return fib(a) - fib_iter(b)
} }
@ -333,13 +333,13 @@ main := fn(): int {
Fiber := struct {a: u8, b: u8} Fiber := struct {a: u8, b: u8}
fib := fn(n: int): int if n < 2 { fib := fn(n: uint): uint if n < 2 {
return n return n
} else { } else {
return fib(n - 1) + fib(n - 2) return fib(n - 1) + fib(n - 2)
} }
fib_iter := fn(n: int): int { fib_iter := fn(n: uint): uint {
a := 0 a := 0
b := 1 b := 1
loop if n == 0 break else { loop if n == 0 break else {
@ -354,29 +354,29 @@ fib_iter := fn(n: int): int {
#### arrays #### arrays
```hb ```hb
main := fn(): int { main := fn(): uint {
addr := @as(u16, 0x1FF) addr := @as(u16, 0x1FF)
msg := [u8].(0, 0, @intcast(addr), @intcast(addr >> 8)) msg := [u8].(0, 0, @intcast(addr), @intcast(addr >> 8))
_force_stack := &msg _force_stack := &msg
arr := [int].(1, 2, 4) arr := [uint].(1, 2, 4)
return pass(&arr) + msg[3] return pass(&arr) + msg[3]
} }
pass := fn(arr: ^[int; 3]): int { pass := fn(arr: ^[uint; 3]): uint {
return arr[0] + arr[1] + arr[arr[1]] return arr[0] + arr[1] + arr[arr[1]]
} }
``` ```
#### inline #### inline
```hb ```hb
main := fn(): int { main := fn(): uint {
return @inline(foo, 1, 2, 3) - 6 return @inline(foo, 1, 2, 3) - 6
} }
gb := 0 gb := 0
foo := fn(a: int, b: int, c: int): int { foo := fn(a: uint, b: uint, c: uint): uint {
if false | gb != 0 return 1 if false | gb != 0 return 1
return a + b + c return a + b + c
} }
@ -384,9 +384,9 @@ foo := fn(a: int, b: int, c: int): int {
#### idk #### idk
```hb ```hb
_edge_case := @as(int, idk) _edge_case := @as(uint, idk)
main := fn(): int { main := fn(): uint {
big_array := @as([u8; 128], idk) big_array := @as([u8; 128], idk)
i := 0 i := 0
loop if i >= 128 break else { loop if i >= 128 break else {
@ -401,8 +401,8 @@ main := fn(): int {
```hb ```hb
add := fn($T: type, a: T, b: T): T return a + b add := fn($T: type, a: T, b: T): T return a + b
main := fn(): int { main := fn(): uint {
return add(u32, 2, 2) - add(int, 1, 3) return add(u32, 2, 2) - add(uint, 1, 3)
} }
``` ```
@ -410,13 +410,13 @@ main := fn(): int {
#### comptime_pointers #### comptime_pointers
```hb ```hb
main := fn(): int { main := fn(): uint {
$integer := 7 $integer := 7
modify(&integer) modify(&integer)
return integer return integer
} }
modify := fn($num: ^int): void { modify := fn($num: ^uint): void {
$: *num = 0 $: *num = 0
} }
``` ```
@ -426,14 +426,14 @@ modify := fn($num: ^int): void {
MALLOC_SYS_CALL := 69 MALLOC_SYS_CALL := 69
FREE_SYS_CALL := 96 FREE_SYS_CALL := 96
malloc := fn(size: int, align: int): ^void return @eca(MALLOC_SYS_CALL, size, align) malloc := fn(size: uint, align: uint): ^void return @eca(MALLOC_SYS_CALL, size, align)
free := fn(ptr: ^void, size: int, align: int): void return @eca(FREE_SYS_CALL, ptr, size, align) free := fn(ptr: ^void, size: uint, align: uint): void return @eca(FREE_SYS_CALL, ptr, size, align)
Vec := fn($Elem: type): type { Vec := fn($Elem: type): type {
return struct { return struct {
data: ^Elem, data: ^Elem,
len: int, len: uint,
cap: int, cap: uint,
} }
} }
@ -478,29 +478,29 @@ push := fn($Elem: type, vec: ^Vec(Elem), value: Elem): ^Elem {
return slot return slot
} }
main := fn(): int { main := fn(): uint {
vec := new(int) vec := new(uint)
_f := push(int, &vec, 69) _f := push(uint, &vec, 69)
res := *vec.data res := *vec.data
deinit(int, &vec) deinit(uint, &vec)
return res return res
} }
``` ```
#### fb_driver #### fb_driver
```hb ```hb
arm_fb_ptr := fn(): int return 100 arm_fb_ptr := fn(): uint return 100
x86_fb_ptr := fn(): int return 100 x86_fb_ptr := fn(): uint return 100
check_platform := fn(): int { check_platform := fn(): uint {
return x86_fb_ptr() return x86_fb_ptr()
} }
set_pixel := fn(x: int, y: int, width: int): int { set_pixel := fn(x: uint, y: uint, width: uint): uint {
return y * width + x return y * width + x
} }
main := fn(): int { main := fn(): uint {
fb_ptr := check_platform() fb_ptr := check_platform()
width := 100 width := 100
height := 30 height := 30
@ -534,9 +534,9 @@ white := Color.(255, 255, 255, 255)
random_color := fn(): Color { random_color := fn(): Color {
return white return white
} }
main := fn(): int { main := fn(): uint {
val := random_color() val := random_color()
return @as(int, val.r) + val.g + val.b + val.a return @as(uint, val.r) + val.g + val.b + val.a
} }
``` ```
@ -546,7 +546,7 @@ Color := struct {r: u8, g: u8, b: u8, a: u8}
white := Color.(255, 255, 255, 255) white := Color.(255, 255, 255, 255)
u32_to_color := fn(v: u32): Color return @as(Color, @bitcast(u32_to_u32(@bitcast(v)))) u32_to_color := fn(v: u32): Color return @as(Color, @bitcast(u32_to_u32(@bitcast(v))))
u32_to_u32 := fn(v: u32): u32 return v u32_to_u32 := fn(v: u32): u32 return v
main := fn(): int { main := fn(): uint {
return u32_to_color(@bitcast(white)).r return u32_to_color(@bitcast(white)).r
} }
``` ```
@ -556,7 +556,7 @@ main := fn(): int {
Color := struct {r: u8, g: u8, b: u8, a: u8} Color := struct {r: u8, g: u8, b: u8, a: u8}
white := Color.(255, 255, 255, 255) white := Color.(255, 255, 255, 255)
black := Color.(0, 0, 0, 0) black := Color.(0, 0, 0, 0)
main := fn(): int { main := fn(): uint {
f := black f := black
f = white f = white
return f.a return f.a
@ -571,15 +571,15 @@ set := fn($Expr: type, src: ^Expr, dest: ^Expr, count: uint): u32 {
return l.count return l.count
} }
main := fn(): int { main := fn(): uint {
return set(int, &0, &0, 1024) return set(uint, &0, &0, 1024)
} }
``` ```
#### string_flip #### string_flip
```hb ```hb
U := struct {u: int} U := struct {u: uint}
main := fn(): int { main := fn(): uint {
arr := @as([U; 2 * 2], idk) arr := @as([U; 2 * 2], idk)
i := 0 i := 0
@ -622,13 +622,13 @@ small_struct := fn(): Stru {
return .{a: 0, b: 0} return .{a: 0, b: 0}
} }
maina := fn(major: int, minor: int): OemIdent { maina := fn(major: uint, minor: uint): OemIdent {
_f := small_struct() _f := small_struct()
ver := [u8].(0, 0, 0, 3, 1, 0, 0, 0) ver := [u8].(0, 0, 0, 3, 1, 0, 0, 0)
return OemIdent.(ver, ver) return OemIdent.(ver, ver)
} }
main := fn(): int { main := fn(): uint {
m := maina(0, 0) m := maina(0, 0)
return m.dos_version[3] - m.dos_version_name[4] return m.dos_version[3] - m.dos_version_name[4]
} }
@ -638,15 +638,15 @@ main := fn(): int {
```hb ```hb
a := @use("math.hb").min(100, 50) a := @use("math.hb").min(100, 50)
main := fn(): int { main := fn(): uint {
return a return a
} }
// in module: math.hb // in module: math.hb
SIZEOF_INT := 32 SIZEOF_uint := 32
SHIFT := SIZEOF_INT - 1 SHIFT := SIZEOF_uint - 1
min := fn(a: int, b: int): int { min := fn(a: uint, b: uint): uint {
c := a - b c := a - b
return b + (c & c >> SHIFT) return b + (c & c >> SHIFT)
} }
@ -668,10 +668,10 @@ Point := struct {
Pixel := struct { Pixel := struct {
color: Color, color: Color,
point: Point, pouint: Point,
} }
main := fn(): int { main := fn(): uint {
pixel := Pixel.{ pixel := Pixel.{
color: Color.{ color: Color.{
r: 255, r: 255,
@ -679,22 +679,22 @@ main := fn(): int {
b: 0, b: 0,
a: 255, a: 255,
}, },
point: Point.{ pouint: Point.{
x: 0, x: 0,
y: 2, y: 2,
}, },
} }
soupan := 1 soupan := 1
if *(&pixel.point.x + soupan) != 2 { if *(&pixel.pouint.x + soupan) != 2 {
return 0 return 0
} }
if *(&pixel.point.y - 1) != 0 { if *(&pixel.pouint.y - 1) != 0 {
return 64 return 64
} }
return pixel.point.x + pixel.point.y + pixel.color.r return pixel.pouint.x + pixel.pouint.y + pixel.color.r
+ pixel.color.g + pixel.color.b + pixel.color.a + pixel.color.g + pixel.color.b + pixel.color.a
} }
``` ```
@ -703,7 +703,7 @@ main := fn(): int {
```hb ```hb
bar := @use("bar.hb") bar := @use("bar.hb")
main := fn(): int { main := fn(): uint {
return 7 - bar.foo().x - bar.foo().y - bar.foo().z return 7 - bar.foo().x - bar.foo().y - bar.foo().z
} }
@ -714,16 +714,16 @@ foo := fn(): Foo {
return .{x: 3, y: 2, z: 2} return .{x: 3, y: 2, z: 2}
} }
Foo := struct {x: int, y: u32, z: u32} Foo := struct {x: uint, y: u32, z: u32}
``` ```
#### sort_something_viredly #### sort_something_viredly
```hb ```hb
main := fn(): int { main := fn(): uint {
return sqrt(100) return sqrt(100)
} }
sqrt := fn(x: int): int { sqrt := fn(x: uint): uint {
temp := 0 temp := 0
g := 0 g := 0
b := 32768 b := 32768
@ -747,7 +747,7 @@ sqrt := fn(x: int): int {
ColorBGRA := struct {b: u8, g: u8, r: u8, a: u8} ColorBGRA := struct {b: u8, g: u8, r: u8, a: u8}
MAGENTA := ColorBGRA.{b: 205, g: 0, r: 205, a: 255} MAGENTA := ColorBGRA.{b: 205, g: 0, r: 205, a: 255}
main := fn(): int { main := fn(): uint {
color := MAGENTA color := MAGENTA
return color.r return color.r
} }
@ -761,7 +761,7 @@ CONST_A := 100
CONST_B := 50 CONST_B := 50
a := stn.math.min(CONST_A, CONST_B) a := stn.math.min(CONST_A, CONST_B)
main := fn(): int { main := fn(): uint {
return a return a
} }
@ -769,9 +769,9 @@ main := fn(): int {
math := @use("math.hb") math := @use("math.hb")
// in module: math.hb // in module: math.hb
SIZEOF_INT := 32 SIZEOF_uint := 32
SHIFT := SIZEOF_INT - 1 SHIFT := SIZEOF_uint - 1
min := fn(a: int, b: int): int { min := fn(a: uint, b: uint): uint {
c := a - b c := a - b
return b + (c & c >> SHIFT) return b + (c & c >> SHIFT)
} }
@ -779,24 +779,24 @@ min := fn(a: int, b: int): int {
#### inline_test #### inline_test
```hb ```hb
fna := fn(a: int, b: int, c: int): int return a + b + c fna := fn(a: uint, b: uint, c: uint): uint return a + b + c
scalar_values := fn(): int { scalar_values := fn(): uint {
return @inline(fna, 1, @inline(fna, 2, 3, 4), -10) return @inline(fna, 1, @inline(fna, 2, 3, 4), -10)
} }
A := struct {a: int} A := struct {a: uint}
AB := struct {a: A, b: int} AB := struct {a: A, b: uint}
mangle := fn(a: A, ab: AB): int { mangle := fn(a: A, ab: AB): uint {
return a.a + ab.a.a - ab.b return a.a + ab.a.a - ab.b
} }
structs := fn(): int { structs := fn(): uint {
return @inline(mangle, .(0), .(.(@inline(mangle, .(20), .(.(5), 5))), 20)) return @inline(mangle, .(0), .(.(@inline(mangle, .(20), .(.(5), 5))), 20))
} }
main := fn(): int { main := fn(): uint {
if scalar_values() != 0 return 1 if scalar_values() != 0 return 1
if structs() != 0 return structs() if structs() != 0 return structs()
@ -811,8 +811,8 @@ abs := fn($Expr: type, x: Expr): Expr {
return (x ^ mask) - mask return (x ^ mask) - mask
} }
main := fn(): int { main := fn(): uint {
return @inline(abs, int, -10) return @inline(abs, uint, -10)
} }
``` ```
@ -837,7 +837,7 @@ main := fn(): void {
} }
// in module: random.hb // in module: random.hb
integer_range := fn(min: uint, max: int): uint { integer_range := fn(min: uint, max: uint): uint {
return @eca(3, 4) % (@bitcast(max) - min + 1) + min return @eca(3, 4) % (@bitcast(max) - min + 1) + min
} }
``` ```
@ -896,7 +896,7 @@ main := fn(): void {
#### tests_ptr_to_ptr_copy #### tests_ptr_to_ptr_copy
```hb ```hb
main := fn(): int { main := fn(): uint {
back_buffer := @as([u8; 1024 * 10], idk) back_buffer := @as([u8; 1024 * 10], idk)
n := 0 n := 0
@ -917,7 +917,7 @@ main := fn(): int {
#### const_folding_with_arg #### const_folding_with_arg
```hb ```hb
main := fn(arg: int): int { main := fn(arg: uint): uint {
// reduces to 0 // reduces to 0
return arg + 0 - arg * 1 + arg + 1 + arg + 2 + arg + 3 - arg * 3 - 6 return arg + 0 - arg * 1 + arg + 1 + arg + 2 + arg + 3 - arg * 3 - 6
} }
@ -925,7 +925,7 @@ main := fn(arg: int): int {
#### branch_assignments #### branch_assignments
```hb ```hb
main := fn(arg: int): int { main := fn(arg: uint): uint {
if arg == 1 { if arg == 1 {
arg = 1 arg = 1
} else if arg == 0 { } else if arg == 0 {
@ -939,7 +939,7 @@ main := fn(arg: int): int {
#### exhaustive_loop_testing #### exhaustive_loop_testing
```hb ```hb
main := fn(): int { main := fn(): uint {
loop break loop break
x := 0 x := 0
@ -984,7 +984,7 @@ main := fn(): int {
} }
} }
multiple_breaks := fn(arg: int): int { multiple_breaks := fn(arg: uint): uint {
loop if arg < 10 { loop if arg < 10 {
arg += 1 arg += 1
if arg == 3 break if arg == 3 break
@ -992,7 +992,7 @@ multiple_breaks := fn(arg: int): int {
return arg return arg
} }
state_change_in_break := fn(arg: int): int { state_change_in_break := fn(arg: uint): uint {
loop if arg < 10 { loop if arg < 10 {
if arg == 3 { if arg == 3 {
arg = 0 arg = 0
@ -1003,7 +1003,7 @@ state_change_in_break := fn(arg: int): int {
return arg return arg
} }
continue_and_state_change := fn(arg: int): int { continue_and_state_change := fn(arg: uint): uint {
loop if arg < 10 { loop if arg < 10 {
if arg == 2 { if arg == 2 {
arg = 4 arg = 4
@ -1021,7 +1021,7 @@ continue_and_state_change := fn(arg: int): int {
#### pointer_opts #### pointer_opts
```hb ```hb
main := fn(): int { main := fn(): uint {
mem := &0; mem := &0;
*mem = 1; *mem = 1;
*mem = 2 *mem = 2
@ -1033,7 +1033,7 @@ main := fn(): int {
return b return b
} }
clobber := fn(cb: ^int): void { clobber := fn(cb: ^uint): void {
*cb = 4 *cb = 4
return return
} }
@ -1041,7 +1041,7 @@ clobber := fn(cb: ^int): void {
#### conditional_stores #### conditional_stores
```hb ```hb
main := fn(): int { main := fn(): uint {
cnd := cond() cnd := cond()
mem := &1 mem := &1
@ -1054,12 +1054,12 @@ main := fn(): int {
return *mem return *mem
} }
cond := fn(): int return 0 cond := fn(): uint return 0
``` ```
#### loop_stores #### loop_stores
```hb ```hb
main := fn(): int { main := fn(): uint {
mem := &10 mem := &10
loop if *mem == 0 break else { loop if *mem == 0 break else {

View file

@ -395,6 +395,8 @@ mod ty {
} }
impl Id { impl Id {
pub const DEFAULT_INT: Self = Self::UINT;
pub fn is_signed(self) -> bool { pub fn is_signed(self) -> bool {
(I8..=INT).contains(&self.repr()) (I8..=INT).contains(&self.repr())
} }

View file

@ -9,7 +9,7 @@ use {
parser::{ parser::{
self, self,
idfl::{self}, idfl::{self},
CtorField, Expr, ExprRef, FileId, Pos, CtorField, Expr, FileId, Pos,
}, },
reg, task, reg, task,
ty::{self, Arg, ArrayLen, Loc, Tuple}, ty::{self, Arg, ArrayLen, Loc, Tuple},
@ -20,12 +20,10 @@ use {
alloc::{borrow::ToOwned, string::String, vec::Vec}, alloc::{borrow::ToOwned, string::String, vec::Vec},
core::{ core::{
assert_matches::debug_assert_matches, assert_matches::debug_assert_matches,
borrow::Borrow,
cell::RefCell, cell::RefCell,
fmt::{self, Debug, Display, Write}, fmt::{self, Debug, Display, Write},
format_args as fa, mem, format_args as fa, mem,
ops::{self}, ops::{self},
usize,
}, },
hashbrown::hash_map, hashbrown::hash_map,
hbbytecode::DisasmError, hbbytecode::DisasmError,
@ -2077,7 +2075,7 @@ impl<'a> Codegen<'a> {
[VOID], [VOID],
)), )),
Expr::Number { value, .. } => Some(self.ci.nodes.new_node_lit( Expr::Number { value, .. } => Some(self.ci.nodes.new_node_lit(
ctx.ty.filter(|ty| ty.is_integer()).unwrap_or(ty::Id::INT), ctx.ty.filter(|ty| ty.is_integer()).unwrap_or(ty::Id::DEFAULT_INT),
Kind::CInt { value }, Kind::CInt { value },
[VOID], [VOID],
)), )),
@ -2381,7 +2379,7 @@ impl<'a> Codegen<'a> {
Expr::Directive { name: "sizeof", args: [ty], .. } => { Expr::Directive { name: "sizeof", args: [ty], .. } => {
let ty = self.ty(ty); let ty = self.ty(ty);
Some(self.ci.nodes.new_node_lit( Some(self.ci.nodes.new_node_lit(
ty::Id::UINT, ctx.ty.filter(|ty| ty.is_integer()).unwrap_or(ty::Id::DEFAULT_INT),
Kind::CInt { value: self.tys.size_of(ty) as _ }, Kind::CInt { value: self.tys.size_of(ty) as _ },
[VOID], [VOID],
)) ))
@ -2389,7 +2387,7 @@ impl<'a> Codegen<'a> {
Expr::Directive { name: "alignof", args: [ty], .. } => { Expr::Directive { name: "alignof", args: [ty], .. } => {
let ty = self.ty(ty); let ty = self.ty(ty);
Some(self.ci.nodes.new_node_lit( Some(self.ci.nodes.new_node_lit(
ty::Id::UINT, ctx.ty.filter(|ty| ty.is_integer()).unwrap_or(ty::Id::DEFAULT_INT),
Kind::CInt { value: self.tys.align_of(ty) as _ }, Kind::CInt { value: self.tys.align_of(ty) as _ },
[VOID], [VOID],
)) ))
@ -2435,7 +2433,7 @@ impl<'a> Codegen<'a> {
Some(val) Some(val)
} }
Expr::Directive { name: "intcast", args: [expr], pos } => { Expr::Directive { name: "intcast", args: [expr], pos } => {
let val = self.expr(expr)?; let mut val = self.expr(expr)?;
if !val.ty.is_integer() { if !val.ty.is_integer() {
self.report( self.report(
@ -2457,7 +2455,18 @@ impl<'a> Codegen<'a> {
return Value::NEVER; return Value::NEVER;
}; };
if !ty.is_integer() {
self.report(
expr.pos(),
fa!(
"intcast is inferred to output '{}', which is not an integer",
self.ty_display(val.ty)
),
);
}
if self.tys.size_of(val.ty) <= self.tys.size_of(ty) { if self.tys.size_of(val.ty) <= self.tys.size_of(ty) {
val.ty = ty;
return Some(val); return Some(val);
} }
@ -4356,7 +4365,7 @@ mod tests {
fn generate(ident: &'static str, input: &'static str, output: &mut String) { fn generate(ident: &'static str, input: &'static str, output: &mut String) {
_ = log::set_logger(&crate::fs::Logger); _ = log::set_logger(&crate::fs::Logger);
log::set_max_level(log::LevelFilter::Info); // log::set_max_level(log::LevelFilter::Info);
// log::set_max_level(log::LevelFilter::Trace); // log::set_max_level(log::LevelFilter::Trace);
let (ref files, embeds) = crate::test_parse_files(ident, input); let (ref files, embeds) = crate::test_parse_files(ident, input);

View file

@ -2,19 +2,19 @@ main:
ADDI64 r254, r254, -36d ADDI64 r254, r254, -36d
ST r31, r254, 28a, 8h ST r31, r254, 28a, 8h
LI64 r7, 4d LI64 r7, 4d
LI64 r8, 2d
LI64 r9, 1d
LI64 r6, 1d LI64 r6, 1d
LI64 r5, 2d LI64 r10, 255d
LI64 r9, 255d LI64 r11, 0d
LI64 r8, 1d
LI64 r10, 0d
ADDI64 r12, r254, 0d ADDI64 r12, r254, 0d
ST r10, r254, 0a, 1h ST r11, r254, 0a, 1h
ST r10, r254, 1a, 1h ST r11, r254, 1a, 1h
ST r9, r254, 2a, 1h ST r10, r254, 2a, 1h
ST r6, r254, 3a, 1h ST r6, r254, 3a, 1h
ADDI64 r2, r254, 4d ADDI64 r2, r254, 4d
ST r8, r254, 4a, 8h ST r9, r254, 4a, 8h
ST r5, r254, 12a, 8h ST r8, r254, 12a, 8h
ST r7, r254, 20a, 8h ST r7, r254, 20a, 8h
JAL r31, r0, :pass JAL r31, r0, :pass
LD r2, r254, 3a, 1h LD r2, r254, 3a, 1h

View file

@ -3,7 +3,7 @@ continue_and_state_change:
LI64 r8, 4d LI64 r8, 4d
LI64 r9, 2d LI64 r9, 2d
LI64 r10, 10d LI64 r10, 10d
6: JLTS r2, r10, :0 6: JLTU r2, r10, :0
CP r1, r2 CP r1, r2
JMP :1 JMP :1
0: JNE r2, r9, :2 0: JNE r2, r9, :2
@ -70,7 +70,7 @@ main:
multiple_breaks: multiple_breaks:
LI64 r6, 3d LI64 r6, 3d
LI64 r5, 10d LI64 r5, 10d
4: JLTS r2, r5, :0 4: JLTU r2, r5, :0
CP r1, r2 CP r1, r2
JMP :1 JMP :1
0: ADDI64 r1, r2, 1d 0: ADDI64 r1, r2, 1d
@ -82,7 +82,7 @@ multiple_breaks:
state_change_in_break: state_change_in_break:
LI64 r5, 3d LI64 r5, 3d
LI64 r6, 10d LI64 r6, 10d
4: JLTS r2, r6, :0 4: JLTU r2, r6, :0
CP r1, r2 CP r1, r2
JMP :1 JMP :1
0: JNE r2, r5, :2 0: JNE r2, r5, :2

View file

@ -15,7 +15,7 @@ main:
CP r10, r32 CP r10, r32
CP r35, r32 CP r35, r32
CP r36, r32 CP r36, r32
5: JLTS r10, r33, :0 5: JLTU r10, r33, :0
ADDI64 r35, r35, 1d ADDI64 r35, r35, 1d
CP r2, r32 CP r2, r32
CP r3, r35 CP r3, r35

View file

@ -1,18 +1,131 @@
test.hb:19:27: 'int * uint' is not supported deinit:
free(@bitcast(vec.data), vec.cap * @sizeof(Elem), @alignof(Elem)); ADDI64 r254, r254, -48d
^ ST r31, r254, 24a, 24h
test.hb:19:52: expected argument align to be of type int, got uint LI64 r4, 8d
free(@bitcast(vec.data), vec.cap * @sizeof(Elem), @alignof(Elem)); LD r5, r2, 16a, 8h
^ CP r32, r2
test.hb:32:43: 'int * uint' is not supported MUL64 r3, r5, r4
new_alloc := @as(^Elem, @bitcast(malloc(vec.cap * @sizeof(Elem), @alignof(Elem)))) CP r5, r32
^ LD r2, r5, 0a, 8h
test.hb:32:68: expected argument align to be of type int, got uint JAL r31, r0, :free
new_alloc := @as(^Elem, @bitcast(malloc(vec.cap * @sizeof(Elem), @alignof(Elem)))) ADDI64 r33, r254, 0d
^ CP r1, r33
test.hb:46:29: 'int * uint' is not supported JAL r31, r0, :new
free(@bitcast(vec.data), vec.len * @sizeof(Elem), @alignof(Elem)) CP r2, r32
^ BMC r33, r2, 24h
test.hb:46:54: expected argument align to be of type int, got uint LD r31, r254, 24a, 24h
free(@bitcast(vec.data), vec.len * @sizeof(Elem), @alignof(Elem)) ADDI64 r254, r254, 48d
^ JALA r0, r31, 0a
free:
CP r10, r2
LRA r7, r0, :FREE_SYS_CALL
LD r2, r7, 0a, 8h
CP r5, r4
CP r4, r3
CP r3, r10
ECA
JALA r0, r31, 0a
main:
ADDI64 r254, r254, -80d
ST r31, r254, 48a, 32h
ADDI64 r32, r254, 24d
CP r1, r32
JAL r31, r0, :new
LI64 r3, 69d
ADDI64 r33, r254, 0d
BMC r32, r33, 24h
CP r2, r33
JAL r31, r0, :push
LD r12, r254, 0a, 8h
LD r34, r12, 0a, 8h
CP r2, r33
JAL r31, r0, :deinit
CP r1, r34
LD r31, r254, 48a, 32h
ADDI64 r254, r254, 80d
JALA r0, r31, 0a
malloc:
CP r9, r2
LRA r5, r0, :MALLOC_SYS_CALL
LD r2, r5, 0a, 8h
CP r4, r3
CP r3, r9
ECA
JALA r0, r31, 0a
new:
ADDI64 r254, r254, -24d
LI64 r4, 0d
ADDI64 r5, r254, 0d
ST r4, r254, 0a, 8h
ST r4, r254, 8a, 8h
ST r4, r254, 16a, 8h
BMC r5, r1, 24h
ADDI64 r254, r254, 24d
JALA r0, r31, 0a
push:
ADDI64 r254, r254, -72d
ST r31, r254, 0a, 72h
CP r32, r3
LI64 r33, 1d
LD r7, r2, 16a, 8h
LD r8, r2, 8a, 8h
CP r34, r2
JNE r7, r8, :0
LI64 r35, 0d
JNE r7, r35, :1
CP r36, r33
JMP :2
1: MULI64 r36, r7, 2d
2: LI64 r37, 8d
MUL64 r2, r36, r37
CP r3, r37
JAL r31, r0, :malloc
CP r38, r34
ST r36, r38, 16a, 8h
JNE r1, r35, :3
CP r1, r35
JMP :4
3: CP r39, r1
CP r1, r35
LD r6, r38, 8a, 8h
MULI64 r8, r6, 8d
LD r12, r38, 0a, 8h
ADD64 r11, r12, r8
CP r8, r39
9: JNE r11, r12, :5
LD r5, r38, 8a, 8h
JEQ r5, r1, :6
LD r2, r38, 0a, 8h
CP r4, r37
MUL64 r3, r5, r4
JAL r31, r0, :free
CP r5, r39
JMP :7
6: CP r5, r39
7: ST r5, r38, 0a, 8h
JMP :8
5: CP r4, r37
CP r5, r39
ADDI64 r6, r8, 8d
ADDI64 r7, r12, 8d
LD r9, r12, 0a, 8h
ST r9, r8, 0a, 8h
CP r8, r6
CP r12, r7
JMP :9
0: CP r38, r34
8: LD r3, r38, 8a, 8h
MULI64 r5, r3, 8d
LD r4, r38, 0a, 8h
ADD64 r1, r4, r5
CP r3, r32
ST r3, r1, 0a, 8h
LD r11, r38, 8a, 8h
ADD64 r2, r11, r33
ST r2, r38, 8a, 8h
4: LD r31, r254, 0a, 72h
ADDI64 r254, r254, 72d
JALA r0, r31, 0a
code size: 980
ret: 69
status: Ok(())

View file

@ -4,7 +4,7 @@ main:
LI64 r5, 128d LI64 r5, 128d
LI64 r7, 0d LI64 r7, 0d
ADDI64 r4, r254, 0d ADDI64 r4, r254, 0d
2: JLTS r7, r5, :0 2: JLTU r7, r5, :0
LD r2, r254, 42a, 1h LD r2, r254, 42a, 1h
ANDI r1, r2, 255d ANDI r1, r2, 255d
JMP :1 JMP :1

View file

@ -3,7 +3,7 @@ fib:
ST r31, r254, 0a, 32h ST r31, r254, 0a, 32h
LI64 r1, 1d LI64 r1, 1d
LI64 r32, 2d LI64 r32, 2d
JGTS r2, r32, :0 JGTU r2, r32, :0
JMP :1 JMP :1
0: CP r6, r2 0: CP r6, r2
SUB64 r2, r6, r1 SUB64 r2, r6, r1

View file

@ -3,7 +3,7 @@ main:
LRA r4, r0, :gb LRA r4, r0, :gb
LI64 r10, 6d LI64 r10, 6d
LD r7, r4, 0a, 8h LD r7, r4, 0a, 8h
CMPS r11, r7, r5 CMPU r11, r7, r5
CMPUI r11, r11, 0d CMPUI r11, r11, 0d
ORI r12, r11, 0d ORI r12, r11, 0d
ANDI r12, r12, 255d ANDI r12, r12, 255d

View file

@ -17,7 +17,7 @@ sqrt:
ADDI64 r7, r7, -1d ADDI64 r7, r7, -1d
ADD64 r9, r4, r8 ADD64 r9, r4, r8
SLU64 r9, r9, r7 SLU64 r9, r9, r7
JLTS r2, r9, :2 JLTU r2, r9, :2
ADD64 r1, r8, r1 ADD64 r1, r8, r1
SUB64 r2, r2, r9 SUB64 r2, r2, r9
JMP :2 JMP :2
@ -25,5 +25,5 @@ sqrt:
JMP :3 JMP :3
1: JALA r0, r31, 0a 1: JALA r0, r31, 0a
code size: 188 code size: 188
ret: 15 ret: 14
status: Ok(()) status: Ok(())

View file

@ -1,69 +1,69 @@
main: main:
ADDI64 r254, r254, -168d ADDI64 r254, r254, -168d
LI64 r2, 4d LI64 r11, 4d
LI64 r9, 1d LI64 r5, 1d
LI64 r6, 3d LI64 r3, 0d
LI64 r7, 2d ADDI64 r6, r254, 144d
LI64 r8, 1d ADDI64 r6, r254, 148d
LI64 r10, 0d ST r3, r254, 148a, 1h
ADDI64 r12, r254, 144d ST r3, r254, 149a, 1h
ADDI64 r12, r254, 148d ST r3, r254, 150a, 1h
ST r3, r254, 151a, 1h
ST r5, r254, 144a, 1h
ST r5, r254, 145a, 1h
ST r5, r254, 146a, 1h
ST r5, r254, 147a, 1h
LD r7, r254, 144a, 1h
LD r8, r254, 148a, 1h
ADD8 r10, r7, r8
ST r10, r254, 148a, 1h ST r10, r254, 148a, 1h
ST r10, r254, 149a, 1h LD r2, r254, 145a, 1h
ST r10, r254, 150a, 1h LD r3, r254, 149a, 1h
ST r10, r254, 151a, 1h ADD8 r5, r3, r2
ST r9, r254, 144a, 1h ST r5, r254, 149a, 1h
ST r9, r254, 145a, 1h LD r9, r254, 146a, 1h
ST r9, r254, 146a, 1h LD r10, r254, 150a, 1h
ST r9, r254, 147a, 1h ADD8 r12, r10, r9
LD r1, r254, 144a, 1h ST r12, r254, 150a, 1h
LD r4, r254, 147a, 1h
LD r5, r254, 151a, 1h
ADD8 r7, r5, r4
ST r7, r254, 151a, 1h
LD r2, r254, 151a, 1h
LD r12, r254, 150a, 1h
LD r3, r254, 148a, 1h LD r3, r254, 148a, 1h
ADD8 r4, r1, r3 LD r4, r254, 149a, 1h
ST r4, r254, 148a, 1h ADD8 r4, r12, r4
LD r9, r254, 145a, 1h ADD8 r8, r3, r4
LD r10, r254, 149a, 1h ADD8 r12, r2, r8
ADD8 r11, r10, r9 ANDI r12, r12, 255d
ST r11, r254, 149a, 1h ANDI r11, r11, 255d
LD r3, r254, 146a, 1h JEQ r12, r11, :0
LD r4, r254, 150a, 1h
ADD8 r9, r4, r3
ST r9, r254, 150a, 1h
LD r10, r254, 147a, 1h
LD r11, r254, 151a, 1h
ADD8 r1, r11, r10
ST r1, r254, 151a, 1h
LD r9, r254, 151a, 1h
LD r5, r254, 150a, 1h
LD r10, r254, 148a, 1h
LD r11, r254, 149a, 1h
ADD8 r11, r5, r11
ADD8 r3, r10, r11
ADD8 r5, r9, r3
ANDI r5, r5, 255d
ANDI r2, r2, 255d
JEQ r5, r2, :0
LI64 r1, 1008d LI64 r1, 1008d
JMP :1 JMP :1
0: LI64 r4, 0d 0: LI64 r1, 0d
LI64 r1, 4d LI64 r10, 4d
ADDI64 r9, r254, 0d LI64 r2, 3d
ADDI64 r5, r254, 32d LI64 r9, 2d
ADDI64 r5, r254, 48d LI64 r3, 1d
ADDI64 r12, r5, 16d ADDI64 r5, r254, 0d
ADDI64 r5, r254, 80d ADDI64 r4, r254, 32d
ADDI64 r2, r254, 96d ADDI64 r4, r254, 48d
ADDI64 r12, r4, 16d
ADDI64 r4, r254, 80d
ADDI64 r6, r254, 96d
ADDI64 r11, r254, 112d ADDI64 r11, r254, 112d
ST r8, r254, 80a, 8h ST r3, r254, 80a, 8h
ST r7, r254, 88a, 8h ST r9, r254, 88a, 8h
ST r6, r254, 32a, 8h ST r2, r254, 32a, 8h
ST r1, r254, 40a, 8h ST r10, r254, 40a, 8h
LD r6, r254, 80a, 8h LD r6, r254, 80a, 8h
LD r7, r254, 32a, 8h LD r7, r254, 32a, 8h
ADD64 r8, r7, r6 ADD64 r8, r7, r6
ST r8, r254, 0a, 8h ST r8, r254, 0a, 8h
LD r1, r254, 40a, 8h LD r2, r254, 40a, 8h
LD r2, r254, 88a, 8h LD r3, r254, 88a, 8h
ADD64 r3, r1, r2 ADD64 r3, r2, r3
ST r3, r254, 8a, 8h ST r3, r254, 8a, 8h
LD r6, r254, 32a, 8h LD r6, r254, 32a, 8h
LD r8, r254, 80a, 8h LD r8, r254, 80a, 8h
@ -73,18 +73,18 @@ main:
LD r3, r254, 40a, 8h LD r3, r254, 40a, 8h
SUB64 r6, r3, r2 SUB64 r6, r3, r2
ST r6, r254, 24a, 8h ST r6, r254, 24a, 8h
BMC r9, r11, 32h BMC r5, r11, 32h
ST r4, r254, 96a, 8h ST r1, r254, 96a, 8h
ST r4, r254, 104a, 8h ST r1, r254, 104a, 8h
LD r2, r254, 96a, 8h LD r2, r254, 96a, 8h
LD r4, r254, 32a, 8h LD r5, r254, 32a, 8h
SUB64 r6, r2, r4 SUB64 r6, r2, r5
ST r6, r254, 48a, 8h ST r6, r254, 48a, 8h
LD r10, r254, 40a, 8h LD r10, r254, 40a, 8h
LD r11, r254, 104a, 8h LD r11, r254, 104a, 8h
SUB64 r1, r11, r10 SUB64 r1, r11, r10
ST r1, r254, 56a, 8h ST r1, r254, 56a, 8h
BMC r5, r12, 16h BMC r4, r12, 16h
LD r6, r254, 48a, 8h LD r6, r254, 48a, 8h
LD r8, r254, 112a, 8h LD r8, r254, 112a, 8h
ADD64 r10, r6, r8 ADD64 r10, r6, r8

View file

@ -3,7 +3,7 @@ fib:
ST r31, r254, 0a, 32h ST r31, r254, 0a, 32h
CP r32, r2 CP r32, r2
LI64 r33, 2d LI64 r33, 2d
JLTS r2, r33, :0 JLTU r2, r33, :0
CP r6, r32 CP r6, r32
ADDI64 r2, r6, -1d ADDI64 r2, r6, -1d
JAL r31, r0, :fib JAL r31, r0, :fib

View file

@ -1,30 +1,30 @@
main: main:
ADDI64 r254, r254, -10240d ADDI64 r254, r254, -10240d
LI64 r7, 64d LI64 r6, 64d
LI64 r5, 1024d LI64 r7, 1024d
LI64 r9, 1d LI64 r9, 1d
LI64 r8, 0d LI64 r8, 0d
ADDI64 r6, r254, 0d ADDI64 r5, r254, 0d
4: JLTS r8, r5, :0 4: JLTU r8, r7, :0
LI64 r7, 10d LI64 r6, 10d
CP r8, r9 CP r7, r9
3: JLTS r8, r7, :1 3: JLTU r7, r6, :1
LD r9, r254, 2048a, 1h LD r12, r254, 2048a, 1h
ANDI r1, r9, 255d ANDI r1, r12, 255d
JMP :2 JMP :2
1: ADD64 r3, r8, r9 1: ADD64 r2, r7, r9
MUL64 r2, r8, r5 MULI64 r1, r7, 1024d
ADD64 r4, r2, r6 ADD64 r3, r1, r5
BMC r6, r4, 1024h BMC r5, r3, 1024h
CP r8, r3 CP r7, r2
JMP :3 JMP :3
0: ADD64 r2, r8, r9 0: ADD64 r2, r8, r9
ADD64 r12, r8, r6 ADD64 r12, r8, r5
ST r7, r12, 0a, 1h ST r6, r12, 0a, 1h
CP r8, r2 CP r8, r2
JMP :4 JMP :4
2: ADDI64 r254, r254, 10240d 2: ADDI64 r254, r254, 10240d
JALA r0, r31, 0a JALA r0, r31, 0a
code size: 198 code size: 205
ret: 64 ret: 64
status: Ok(()) status: Ok(())