3 ms·
akkartik, I see the following 3 syntaxes for 'MOV ESP, EBP': 89/<- ebp 4/r32/esp # copy esp to ebp 89/<- 5/r
by eterps 7y ago
akkartik, I see the following 3 syntaxes for 'MOV ESP, EBP':
89/<- ebp 4/r32/esp # copy esp to ebp
89/<- 5/rm32/ebp 4/r32/esp # copy esp to ebp
89/<- 3/mod/direct 5/rm32/ebp 4/r32/esp # copy esp to ebp
Only the last one contains all information needed to encode the instruction. And the first one is used in the factorial example. Can you explain why all the 3 syntaxes are in use?
- akkartik 7y agoYeah, the last one is the 'ground truth' that both translators understand. sigils.subx adds some syntax sugar so you can say 89/<- %ebp 4/r32/esp By my self-imposed rules I can't use this sugar until I build it, so there's little code that uses it at the moment. But any future Subx code will use it, such as the implementation of Level 2. You can also see it used in calls.subx, which is another later layer of syntax sugar. Could you point me at where you see your first two versions?
- eterps 7y agoIn http://akkartik.name/post/mu-2019-1 http://akkartik.name/post/mu-2019-1 if you search for the pattern '/89' you'll find the first two versions. The 3rd one is here: https://github.com/akkartik/mu/blob/master/apps/factorial.subx#L23 https://github.com/akkartik/mu/blob/master/apps/factorial.su... Can you explain in a sentence what rules are used to complete the encoding for the variant: > 89/<- %ebp 4/r32/esp
- akkartik 7y agoAh, I see. Yes, I mentioned in the post that I was dropping some magic numbers. Mu is intended to be read in a text editor, and I didn't want to scare people too much while reading the post in a browser. Slightly evil, I know. The concrete rules are illustrated at https://github.com/akkartik/mu/blob/469a1a9ace9b290658beb9d0799b58ce3bc2a4b4/apps/sigils.subx#L9 https://github.com/akkartik/mu/blob/469a1a9ace9b290658beb9d0.... In this case `%<reg>` always translates to `3/mod <reg-code>/rm32`.