aboutsummaryrefslogtreecommitdiff
path: root/putstr.lang
blob: 7485d8fdcc3ec40da0c178a792f097467f684046 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
func putstr(char[] str) {
	int i := 0;
	while (str[i] != '\0') {
		putc(str[i]);
		i = i + 1;
	}
}

func int main() {
	char[] str := new char[100];
	str[0] = 'k';
	str[1] = 'a';
	str[2] = str[1];
	str[3] = 's';
	str[4] = '\n';
	str[5] = '\0';
	putstr(str);
	return 0;
}



/*
irfunc putstr(char[] str)
  {{{(0)
    mov t5Q <- 0Q
    jmp 7
  }}}
  {{{(7)
    add t17Q <- t5Q, 8Q
    add t18Q <- astrQ, t17Q
    load t19B <- *t18Q
    neq t22Q <- t19B, 0B
    jne t22Q, 0Q -> 9 | 6
  }}}
  {{{(9)
    add t30Q <- t5Q, 8Q
    add t31Q <- astrQ, t30Q
    load t32B <- *t31Q
    call putc (t32B)
    add t39Q <- t5Q, 1Q
    mov t5Q <- t39Q
    jmp 7
  }}}
  {{{(6)
    ret
  }}}
*/