native: fix example exit((1,2)->(a,b)return a+b) (#12154)

pull/12162/head
pancake 2021-10-12 17:51:28 +02:00 committed by GitHub
parent 347ebe5fd3
commit 1d2b56d71d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 2 deletions

View File

@ -234,7 +234,7 @@ fn (mut g Gen) mov64(reg Register, val i64) {
fn (mut g Gen) mov_reg_to_var(var_offset int, reg Register) {
// 89 7d fc mov DWORD PTR [rbp-0x4],edi
match reg {
.rax, .rsi {
.rax {
g.write8(0x48)
}
else {}
@ -642,7 +642,7 @@ fn (mut g Gen) mov(reg Register, val int) {
g.write8(0xba)
}
.rsi {
g.write8(0x48)
// g.write8(0x48) // its 32bit!
g.write8(0xbe)
}
.r12 {

View File

@ -0,0 +1,19 @@
fn sumcall(a int, b int) int {
r := a + b
return r
}
fn sumcall2(a int, b int) int {
return a + b
}
fn main() {
r := sumcall (1,2)
assert r == 3
/*
// XXX not yet working
s := sumcall2 (1,2)
assert r == 3
*/
exit(0)
}