💾 Archived View for compudanzas.net › uxn_tutorial_deprecated_appendix_a.gmi captured on 2022-03-01 at 16:00:16. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-01-08)

➡️ Next capture (2022-04-28)

🚧 View Differences

-=-=-=-=-=-=-

uxn tutorial appendix a: the on-screen debugger

once we set the system colors in varvara, as described in uxn tutorial day 2, we can use the on-screen debugger to aid us in figuring out what is happening with the stacks and memory during the runtime of our programs.

uxn tutorial day 2

the debugger

if you tried using the F2 key while running your program before today, you would have found that apparently nothing happened.

that was because the on-screen debugger uses the screen device, and therefore needs the system colors to be set.

now that you have some system colors set, run your program and press the F2 key: you'll see several elements now!

screenshot of the on-screen debugger using the assigned system colors

uxn tutorial day 5

uxn tutorial day 4

remember: you can use the F1 key to switch between different zoom levels.

take a look at the representation of the stack: if you didn't change the values i suggested above, you'll see the following numbers at the top left:

[2c] e5 0c

what are these numbers?

2ce5 is the short we assigned to the blue components of the system colors, and 0c is the i/o address of the short corresponding to .System/b ! (can you calculate and enumerate what are the numerical addresses of each of the color components in the system device?)

those values are the leftovers from the last operation on our program, the DEO2 that set the blue component of the system colors.

we can think of the highlight in the leftmost 2c, as an arrow pointing leftwards to the "top" of the stack. it current position implies that the stack is empty, as there are no more elements to its left.

note that the stack memory is not erased when taking elements out of it, what changes is the value of the address that points to its top.

stack debugging test

let's try appending to our program the example code we discussed above, adding it after setting the system colors:

#0004 #0008 ADD2

run it, open the debugger, and see the contents of the stack.

what does it mean what you see?

if everything went alright, you'll see:

00 0c [00] 08

if we think of the highlight as an arrow pointing left towards the top of the stack, we'll see that its position corresponds with the result that we would have expected!

00 0c <- top

000c is the result of the addition that was performed, that it is now stored in the stack!

the highlighted 00, and the 08 to its right, correspond to the 0008 of our second operand. they were used by the ADD2 instruction already, but they are left unused in the stack memory. they would stay there until overwritten.

in general, if our program is functioning alright, we will see the highlight of the top of the stack always at the top left position.

otherwise, it means that our operations with the stack were left unbalanced: there were more elements added to it than element removed from it.

support

if you found this tutorial to be helpful, consider sharing it and giving it your support :)

support

incoming links

uxn tutorial

updated on 12022-02-10

source file

compudanzas

contact

text, images, and code are shared with the peer production license