Added printf and stackrotate functions to VVS stdlib.
[vvhitespace] / stdlib / debug.pvvs
CommitLineData
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'.
1a56830d
AT
9@ Call Stack:
10@ endaddr
11@ startaddr <-- TOS
12@ Return Stack:
13@ <empty>
14@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
bb21580a 15#include <stdio.pvvs>
1a56830d
AT
16NSSVTTTSSSN | Mark: 111000 (dump heap)
17
18@ Prepare a numeric address and value on the stack
19SNS | DUP
20SNS | DUP
21TTT | LOAD
22SNT | SWAP
23
24@ Print output line for this memory location
ae1f85a1 25NSTTSSSSTTN | JSR>1000011 (print absolute value of number)
1a56830d
AT
26SSSTTTSTSN | PUSH ASCII ':'
27SSSTSSTN | PUSH ASCII '\t'
28TNSS | PUTC
29TNSS | PUTC
23d17247 30NSTTSSTN | JSR>1001 (print number from stack)
1a56830d
AT
31SSSTSTSN | PUSH ASCII '\n'
32TNSS | PUTC
33
34@ Figure out if the loop is complete.
bb21580a 35SSSTN | PUSH 1 (ptr)
1a56830d
AT
36SNT | SWAP
37TTS | STORE
38SNS | DUP
bb21580a 39SSSTN | PUSH 1 (ptr)
1a56830d
AT
40TTT | LOAD
41TSST | SUBTRACT
42NTSSSTTTSSSSSSSSSSSN | BRZ > 00111000 00000000
bb21580a 43SSSTN | PUSH 1 (ptr)
1a56830d
AT
44TTT | LOAD
45SSSTN | PUSH 1
46TSSS | ADD
47NSNTTTSSSN | JMP>111000 (dump heap)
48
49@ Clean up and return
50NSSVSSTTTSSSSSSSSSSSN | Mark: 00111000 00000000
51SNN | DROP
52NTN | RTS
53
ae1f85a1
AT
54@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
55@ Name:
56@ dumpstack (111001)
57@ Description:
58@ Dumps 'count' entries from the stack.
59@ Call Stack:
60@ count <-- TOS
61@ Return Stack:
62@ <empty>
63@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
64#include <stdio.pvvs>
65NSSVTTTSSTN | Mark: 111001 (dump stack)
66
67@ Print output line for the current TOS.
68SNS | DUP
69NSTTSSSSTTN | JSR>1000011 (print absolute value of number)
70SSSTTTSTSN | PUSH ASCII ':'
71SSSTSSTN | PUSH ASCII '\t'
72TNSS | PUTC
73TNSS | PUTC
74SNT | SWAP
23d17247 75NSTTSSTN | JSR>1001 (print number from stack)
ae1f85a1
AT
76SSSTSTSN | PUSH ASCII '\n'
77TNSS | PUTC
78
79@ Figure out if the loop is complete.
80SNS | DUP
81NTSSSTTTSSTSSSSSSSSN | BRZ > 00111001 00000000
82SSSTN | PUSH 1
83TSST | SUBTRACT
84NSNTTTSSTN | JMP>111001 (dump stack)
85
86@ Clean up and return
87NSSVSSTTTSSTSSSSSSSSN | Mark: 00111001 00000000
88SNN | DROP
89NTN | RTS
90
1a56830d 91#endif