BACI
0 1 6
0 1 6 LOAD_ADDR, push &i Pouziti: badis [optional_flags] pcode_filename Optional flags: -h ukaze tento help -s nevypisuje zdrojovy kod
(incr.cm
z posledni kapitoly o BACI C-- prekladaci) 1 const int m = 5; 2 int n; 3 4 void incr(char id) 5 { 6 int i; 7 8 for(i = 1; i <= m; i = i + 1)
lc f x y PCODE 0 0 1 6 LOAD_ADDR, push &i 1 24 0 1 PUSH_LIT 1 2 38 0 0 STORE, s[s[t-1]] = s[t], pop(2) 3 1 1 6 LOAD_VALUE, push i 4 24 0 5 PUSH_LIT 5 5 48 0 0 TEST_LE,pop(1),s[t] = (s[oldt-1] <= s[oldt]) 6 15 0 32 JZER s[t] to 32, pop(1) 7 14 0 14 JUMP to 14 8 0 1 6 LOAD_ADDR, push &i 9 1 1 6 LOAD_VALUE, push i 10 24 0 1 PUSH_LIT 1 11 52 0 0 DO_ADD, pop(1), s[t] = (s[oldt-1] + s[oldt]) 12 38 0 0 STORE, s[s[t-1]] = s[t], pop(2) 13 14 0 3 JUMP to 3
9 { 10 n = n + 1;
14 0 0 0 LOAD_ADDR, push &n 15 1 0 0 LOAD_VALUE, push n 16 24 0 1 PUSH_LIT 1 17 52 0 0 DO_ADD, pop(1), s[t] = (s[oldt-1] + s[oldt]) 18 38 0 0 STORE, s[s[t-1]] = s[t], pop(2)
11 cout << id << " n =" << n << " i =";
19 1 1 5 LOAD_VALUE, push id 20 29 0 3 WRITE (char) s[t] to stdout, pop(1) 21 28 0 0 WRITE_RAWSTRING stab[0] to stdout 22 1 0 0 LOAD_VALUE, push n 23 29 0 1 WRITE (int) s[t] to stdout, pop(1) 24 28 0 6 WRITE_RAWSTRING stab[6] to stdout
12 cout << i << " " << id << endl;
25 1 1 6 LOAD_VALUE, push i 26 29 0 1 WRITE (int) s[t] to stdout, pop(1) 27 28 0 12 WRITE_RAWSTRING stab[12] to stdout 28 1 1 5 LOAD_VALUE, push id 29 29 0 3 WRITE (char) s[t] to stdout, pop(1) 30 63 0 0 WRITELN
13 } 31 14 0 8 JUMP to 8
14 }
32 32 0 0 EXIT_PROC
15 16 main()
33 80 0 56 SHORTCALL to 56, shortcall_reg = pc, pc = 56
17 { 18 n = 0;
34 0 0 0 LOAD_ADDR, push &n 35 24 0 0 PUSH_LIT 0 36 38 0 0 STORE, s[s[t-1]] = s[t], pop(2)
19 cobegin
37 4 0 0 COBEGIN
20 { 21 incr( 'A'); incr( 'B' ); incr('C');
38 18 0 4 MARKSTACK incr 39 24 0 65 PUSH_LIT 65 40 19 0 5 CALL, psize-1 = 5 41 3 0 1 UPDATE_DISPLAY from level 1 out to level 0 42 18 0 4 MARKSTACK incr 43 24 0 66 PUSH_LIT 66 44 19 0 5 CALL, psize-1 = 5 45 3 0 1 UPDATE_DISPLAY from level 1 out to level 0 46 18 0 4 MARKSTACK incr 47 24 0 67 PUSH_LIT 67 48 19 0 5 CALL, psize-1 = 5 49 3 0 1 UPDATE_DISPLAY from level 1 out to level 0
22 }
50 5 0 0 COEND
23 cout << "The sum is " << n << endl;
51 28 0 14 WRITE_RAWSTRING stab[14] to stdout 52 1 0 0 LOAD_VALUE, push n 53 29 0 1 WRITE (int) s[t] to stdout, pop(1) 54 63 0 0 WRITELN
24 }
55 31 0 0 HALT
++-outer-++: 56 81 0 0 SHORTRET, pc = shortcall_reg
14 0 0 0 LOAD_ADDR, push &n 15 1 0 0 LOAD_VALUE, push n 16 24 0 1 PUSH_LIT 1 17 52 0 0 DO_ADD,pop(1),s[t] =(s[oldt-1] + s[oldt]) 18 38 0 0 STORE, s[s[t-1]] = s[t], pop(2)
Pouziti vypisu disassembleru pro ladeni
nasleduje komunikace s interpretem (akce uzivatele jsou zvyrazneny) ... Executing PCODE ... 33 80 0 56 SHORTCALL to 56,shortcall_reg=pc,pc = 56 (h = help)> h Debugger Commands: b lc -- set a break at location 'lc' c -- continue to the next breakpoint d -- dump the stack of the current process d t -- dump 10 stack words from s[t] down to s[t-10] d t b -- dump stack words from s[t] down to s[b] h -- show this help i -- show current breakpoints p -- show process table q -- terminate execution s -- execute one PCODE instruction RETURN -- repeat singlestep or continue u i -- unset breakpoint[i] w -- show where current execution is x -- disassemble the next 10 instructions x loc --dissassemble 10instructions starting at 'loc' (h = help)> b 16 (h = help)> b 18
(h = help)> c Breakpoint 0 Process #3: incr 16 24 0 1 PUSH_LIT 1 (h = help)> d Stack for Process #3: incr from 2809 down to 2801 0 0 1 67 4 1 0 0 0 (h = help)> c Breakpoint 1 Process #3: incr 18 38 0 0 STORE, s[s[t-1]] = s[t], pop(2) (h = help)> d Stack for Process #3: incr from 2809 down to 2801 1 0 1 67 4 1 0 0 0 (h = help)> s 19 1 1 5 LOAD_VALUE, push id (h = help)> p Process Table Process Active Suspend PC xpc atomic 0 main 0 -1 51 6 0 1 incr 1 -1 1 5 0 2 incr 1 -1 1 5 0 3 incr 1 -1 19 18 0 Global Variables type name level adr value int n 0 0 1 Mainproc Variables Monitor Variables Process Variables Process #1 incr int i 1 6 0 char id 1 5 A Process #2 incr int i 1 6 0 char id 1 5 B Process #3 incr int i 1 6 1 char id 1 5 C
(h = help)> c C n =1 i =1 CBreakpoint 0 Process #2: incr 16 24 0 1 PUSH_LIT 1 (h = help)> d Stack for Process #2: incr from 2609 down to 2601 1 0 1 66 4 1 0 0 0 (h = help)> c Breakpoint 1 Process #2: incr 18 38 0 0 STORE, s[s[t-1]] = s[t], pop(2) (h = help)> d Stack for Process #2: incr from 2609 down to 2601 2 0 1 66 4 1 0 0 0
(h = help)> c
Breakpoint 0 Process #1: incr 16 24 0 1 PUSH_LIT 1 (h = help)> d Stack for Process #1: incr from 2409 down to 2401 2 0 1 65 4 1 0 0 0 (h = help)> c Breakpoint 0 Process #3: incr 16 24 0 1 PUSH_LIT 1 (h = help)> d Stack for Process #3: incr from 2809 down to 2801 2 0 2 67 4 1 0 0 0 (h = help)> c Breakpoint 1 Process #3: incr 18 38 0 0 STORE, s[s[t-1]] = s[t], pop(2) (h = help)> d Stack for Process #3: incr from 2809 down to 2801 3 0 2 67 4 1 0 0 0 (h = help)> c Breakpoint 1 Process #1: incr 18 38 0 0 STORE, s[s[t-1]] = s[t], pop(2) (h = help)> d Stack for Process #1: incr from 2409 down to 2401 3 0 1 65 4 1 0 0 0 (h = help)> p Process Table Process Active Suspend PC xpc atomic 0 main 0 -1 51 6 0 1 incr 1 -1 18 16 0 2 incr 1 -1 20 18 0 3 incr 1 -1 20 48 0 Global Variables type name level adr value int n 0 0 3 Mainproc Variables Monitor Variables Process Variables Process #1 incr int i 1 6 1 char id 1 5 A Process #2 incr int i 1 6 1 char id 1 5 B Process #3 incr int i 1 6 2 char id 1 5 C
Pri pouziti option -p pri spusteni intepretu byl vytvoren soubor s priponou .xpc, ve kterem je exaktne zapsano prokladani PCODE instrukci, pr.:
(h = help)> u 0 (h = help)> u 1 (h = help)> c A n =3 i =1 B n =3C n =3 i =A 2 i =C1 B A n =4 i =2 A C n =5B i =3 n =A n =7 i =2 B7 i = 3 A C A n =8 i =4 A C n =9 i =4 C A n =10B n =10 i = i =5 3 A B C n =11 i =5 C B n =12 i =4 B B n =13 i =5 B The sum is 13 PCODE execution trace stored in incremen.xpc
| ||||||||||||||||||||||||||||||||||||
Stranka BACI | Stranka ZOS | Posledni uprava : 16.11. 2000 |