annotate test/hoge.c @ 928:96c53f76b360

fix
author kono
date Sun, 13 Apr 2014 10:21:40 +0900
parents 5313ed059cee
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
658
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
1 #include <stdio.h>
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
2 // #include "hoge.h"
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
3 // #include "task.h"
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
4
720
6b7372e17970 *** empty log message ***
kono
parents: 658
diff changeset
5 struct task;
6b7372e17970 *** empty log message ***
kono
parents: 658
diff changeset
6
658
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
7 typedef
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
8 struct pkt {
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
9 int val;
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
10 __code (*next)(struct pkt *,struct task *);
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
11 } Pkt, *PktPtr;
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
12
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
13
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
14 typedef
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
15 struct task {
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
16 int val;
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
17 __code (*next)(struct pkt *,struct task *);
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
18 } Task, *TaskPtr;
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
19
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
20 int count = 5;
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
21
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
22 void *env;
725
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
23 __code (*exit0)(int,void*);
658
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
24
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
25 __code scheduler(PktPtr pkt, TaskPtr task)
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
26 {
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
27 if (count-->0)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 748
diff changeset
28 goto pkt->next(pkt,task);
725
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 720
diff changeset
29 goto exit0(0,env);
658
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
30 }
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
31
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
32 __code modulo(PktPtr pkt, TaskPtr current_task);
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
33
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
34 __code increment(PktPtr pkt, TaskPtr current_task)
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
35 {
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
36 pkt->val++;
748
c2c709727221 i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
37 printf("#0036:inc: %d\n", pkt->val);
658
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
38 pkt->next = modulo;
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
39 goto scheduler(pkt, current_task);
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
40 }
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
41
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
42 __code modulo(PktPtr pkt, TaskPtr current_task)
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
43 {
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
44 pkt->val %= 10;
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
45 pkt->val = pkt->val % 10;
748
c2c709727221 i64 continue... basic.s assembled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
46 printf("#0045:mod: %d\n", pkt->val);
658
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
47 pkt->next = increment;
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
48 goto scheduler(pkt, current_task);
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
49 }
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
50
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
51 static Pkt pkt;
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
52 static Task task;
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
53
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
54 int
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
55 main()
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
56 {
720
6b7372e17970 *** empty log message ***
kono
parents: 658
diff changeset
57 exit0 = __return;
6b7372e17970 *** empty log message ***
kono
parents: 658
diff changeset
58 env = __environment;
658
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
59 goto increment(&pkt,&task);
cb3809f4ec97 *** empty log message ***
kono
parents:
diff changeset
60 }