weeble / uxn-cheatsheet

25 stars 1 forks source link

Question about the hint on the k. #2

Closed pauladam94 closed 3 months ago

pauladam94 commented 3 months ago

'k' is suppsoed to mean that the read value is not removed. Is it really correct ? For example for the POP instruction, is does not seem to be true. Howver the POP instruction does have the 'k'.

There is also a hint at the of the block explaining the 'k' notation. It is about the '--' notation. Is is explained that whatever is one both sides of the '--' notation is the state of the stack at the end of an Instruction. Is it really reallu correct ? For example in the OVR Instruction that duplicates the second element in the stack. We have this notation "a b -- a b a", meaning "a b" and executing OVR we have the stack status : "a b a". However the stack status is NOT "a b a b a" which is what is implied from the "hint". Or at leat is how i understand it.

Thanks for having done this svg. It is a good work and a useful one. Can you maybe give the source to reproduce it ?

weeble commented 3 months ago

Hi! This diagram is really intended as a cheat-sheet, a reminder of information explained in detail elsewhere. It isn't on its own a replacement for the uxn docs.

"k" is one of the instruction modifiers in uxn. It appears here on instructions to which that modifier can be applied. So it means that there exists a "POPk" opcode which is like POP but it doesn't remove anything from the stack (and therefore doesn't do anything).

The hint in the "k" section is describing how the "k" modifier changes the behaviour of an instruction from the plain version. The "--" notation describes how the plain version of the instruction replaces what is in the top of the stack. So OVR "a b -- a b a" means that if beforehand the stack has "a" second from top and "b" at the top, then afterwards they will be replaced with "a b a". And the hint is telling us that OVRk will instead transform a stack "a b" into "a b a b a". This actually appears as an example in the opcode reference.

As for source for the diagram, it's not procesurally generated. I created it by hand in Inkscape. You should be able to load it in Inkscape and make your own changes if you need to.

pauladam94 commented 3 months ago

Thanks a lot ! I was missing the semantics of the identifier ! I understand now. I close here the issue thanks.