Commit | Line | Data |
---|---|---|
1a56830d AT |
1 | #ifndef VVS_STDLIB_DEBUG |
2 | #define VVS_STDLIB_DEBUG | |
3 | ||
4 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | |
bb21580a AT |
5 | @ Name: |
6 | @ dumpheap (111000) | |
1a56830d | 7 | @ Description: |
bb21580a | 8 | @ Dumps the heap from 'startaddr' to 'endaddr'. |
6cb31a3e AT |
9 | @ This subroutine stomps on heap[1] after printing the first heap location. |
10 | @ If you dump starting from heap[0], then heap[1] will print inaccurately. | |
11 | @ Starting the dump from any other location will work without error. | |
12 | @ TODO: Should I use heap[0] and DIE rather than RTS? | |
13 | @ At the moment, the ability to continue is too useful to me. | |
14 | @ If it's useful to me, it's probably useful to other people. | |
15 | @ For now, leave dumpheap as-is. | |
1a56830d AT |
16 | @ Call Stack: |
17 | @ endaddr | |
18 | @ startaddr <-- TOS | |
19 | @ Return Stack: | |
20 | @ <empty> | |
21 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | |
bb21580a | 22 | #include <stdio.pvvs> |
1a56830d AT |
23 | NSSVTTTSSSN | Mark: 111000 (dump heap) |
24 | ||
25 | @ Prepare a numeric address and value on the stack | |
26 | SNS | DUP | |
27 | SNS | DUP | |
28 | TTT | LOAD | |
29 | SNT | SWAP | |
30 | ||
31 | @ Print output line for this memory location | |
ae1f85a1 | 32 | NSTTSSSSTTN | JSR>1000011 (print absolute value of number) |
1a56830d AT |
33 | SSSTTTSTSN | PUSH ASCII ':' |
34 | SSSTSSTN | PUSH ASCII '\t' | |
35 | TNSS | PUTC | |
36 | TNSS | PUTC | |
23d17247 | 37 | NSTTSSTN | JSR>1001 (print number from stack) |
1a56830d AT |
38 | SSSTSTSN | PUSH ASCII '\n' |
39 | TNSS | PUTC | |
40 | ||
41 | @ Figure out if the loop is complete. | |
bb21580a | 42 | SSSTN | PUSH 1 (ptr) |
1a56830d AT |
43 | SNT | SWAP |
44 | TTS | STORE | |
45 | SNS | DUP | |
bb21580a | 46 | SSSTN | PUSH 1 (ptr) |
1a56830d AT |
47 | TTT | LOAD |
48 | TSST | SUBTRACT | |
49 | NTSSSTTTSSSSSSSSSSSN | BRZ > 00111000 00000000 | |
bb21580a | 50 | SSSTN | PUSH 1 (ptr) |
1a56830d AT |
51 | TTT | LOAD |
52 | SSSTN | PUSH 1 | |
53 | TSSS | ADD | |
54 | NSNTTTSSSN | JMP>111000 (dump heap) | |
55 | ||
56 | @ Clean up and return | |
57 | NSSVSSTTTSSSSSSSSSSSN | Mark: 00111000 00000000 | |
58 | SNN | DROP | |
59 | NTN | RTS | |
60 | ||
ae1f85a1 AT |
61 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
62 | @ Name: | |
63 | @ dumpstack (111001) | |
64 | @ Description: | |
65 | @ Dumps 'count' entries from the stack. | |
66 | @ Call Stack: | |
67 | @ count <-- TOS | |
68 | @ Return Stack: | |
69 | @ <empty> | |
70 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | |
71 | #include <stdio.pvvs> | |
72 | NSSVTTTSSTN | Mark: 111001 (dump stack) | |
73 | ||
74 | @ Print output line for the current TOS. | |
75 | SNS | DUP | |
76 | NSTTSSSSTTN | JSR>1000011 (print absolute value of number) | |
77 | SSSTTTSTSN | PUSH ASCII ':' | |
78 | SSSTSSTN | PUSH ASCII '\t' | |
79 | TNSS | PUTC | |
80 | TNSS | PUTC | |
81 | SNT | SWAP | |
23d17247 | 82 | NSTTSSTN | JSR>1001 (print number from stack) |
ae1f85a1 AT |
83 | SSSTSTSN | PUSH ASCII '\n' |
84 | TNSS | PUTC | |
85 | ||
86 | @ Figure out if the loop is complete. | |
87 | SNS | DUP | |
88 | NTSSSTTTSSTSSSSSSSSN | BRZ > 00111001 00000000 | |
89 | SSSTN | PUSH 1 | |
90 | TSST | SUBTRACT | |
91 | NSNTTTSSTN | JMP>111001 (dump stack) | |
92 | ||
93 | @ Clean up and return | |
94 | NSSVSSTTTSSTSSSSSSSSN | Mark: 00111001 00000000 | |
95 | SNN | DROP | |
96 | NTN | RTS | |
97 | ||
1a56830d | 98 | #endif |