Skip to main content


Could any uxntal-savvy folks help me make sense of this?

```
.Controller/key DEI ( read key )
DUP LIT "1 EQU ( is the key '1'? )
,&color-1 JCN ( jump to color-1 if that's the case )
```

If I press 1, the stack looks like this: `31 01 2F`. I assume 2F was pushed down there by `EQU`? Is that right? Why is it 2F and not 01 for example?

If I press another key (for ex A), the stack looks like this: `61 00 0D`. What is this 0D there?

(I'm using the uxnemu debugger to get these values)

This entry was edited (10 months ago)
in reply to Devine Lu Linvega

Be careful here, in the code you shared, you're leaking the key by duplicating it
in reply to Gosha

Oh, what you're seeing is ghost of what was on the stack. Your program doesn't have anything on the stack after the control vector 😀
This entry was edited (10 months ago)
in reply to Devine Lu Linvega

Have a look at this, the code will not pop the key before breaking(BRK), but will instead print it to the console: https://paste.sr.ht/~rabbits/d38dc642cbdb37ce7c4c854ed845e3b5ba6fb7b2

You can use the <print-byte> routine to pop one byte from the stack and print it in the console

This entry was edited (10 months ago)
in reply to Devine Lu Linvega

@neauoire Thank you Devine! I just soothed my daughter back to sleep for like an hour so my brain is not working very well anymore, so I'm going to look at this tomorrow. The reason I was wondering about the stack is that the Compudanzas tutorial asked: why are we doing all these POP statements? and I thought it was because I was duplicating the keyboard input, and wanted to confirm that in the debugger. I'll try with the <print-byte> routine tomorrow!
in reply to Gosha

yeah that's what the POPs are for, to remove the key on the stack. Let me know if you have questions tomorrow and I'll be happy to help 😀 Good luck with day4!
This entry was edited (10 months ago)
in reply to Gosha

When you add #0008, you have a byte, and a short on the stack, so 3 bytes. Using SWP here brings the high byte of the position on top, not the screen/x port, you wan to use ROT
in reply to Devine Lu Linvega

@neauoire Ooooh, awesome, that is it! Thank you. Also, what tool is this? Looks extremely useful.
Unknown parent

Devine Lu Linvega
np ^^ let me know if you have any issue, you can hop on #uxn on irc.esper.net also if you wanna chat, I'm online if I'm awake.
#uxn
This entry was edited (10 months ago)

Lo, thar be cookies on this site to keep track of your login. By clicking 'okay', you are CONSENTING to this.