5 ms·
You should definitely look at: https://github.com/akkartik/mu/blob/main/subx.md https://github.com/akkartik/mu/blob/main/subx.md
by eterps 2y ago
You should definitely look at: https://github.com/akkartik/mu/blob/main/subx.md https://github.com/akkartik/mu/blob/main/subx.md
- eterps 2y agoAlso, running machine code directly can be done like this: https://github.com/eterps/loader/blob/master/syscall.nim https://github.com/eterps/loader/blob/master/syscall.nim
- alok-g 2y agoThis is cool! This is how I used to do also by embedding hand-written machine code within a BASIC program and calling it to run natively.
- eterps 2y ago> This is how I used to do also by embedding hand-written machine code within a BASIC program and calling it to run natively Me too; that's also the reason why I wanted that possibility back.
- alok-g 2y agoSubX seems like an assembly language itself following a subset of x86 32-bit instructions. Would looking into this help me understand how to translate from assembly to machine code manually? Thanks.
- akkartik 2y agoSubX is a weird thing (I built it) that is somewhere between machine code and Assembly language. You have to type in the opcodes directly, which people typically associate with machine code. But it smooths some aspects of programming in machine code. You'll get nice errors if you accidentally write invalid machine code, it won't just go off and run data as code or something like that. I'd be happy to support you if you choose to try it out! Ask as many questions as you like. Even if you choose not to, you might like the cheatsheet in the repo (from https://net.cs.uni-bonn.de/fileadmin/user_upload/plohmann/x86_opcode_structure_and_instruction_overview.pdf https://net.cs.uni-bonn.de/fileadmin/user_upload/plohmann/x8...)
- alok-g 2y agoThanks! I understand better now. And that cheat sheet PDF is cool, exactly what I was looking for. Any chance you are aware of something similar for x64? Thanks.
- akkartik 2y agoNo, sorry. Honestly I spent a long time going to the source of the 3-volume Intel manual. (There's link to them as well in my Readme.) I think that's really what you need to do for machine code, if you're not using Assembly or Assembly-ish that has done that work for you. But then any Assembly language will have its own manual you need to bone up on.. That's mostly why I built SubX: the manual is like 10 pages, and I distilled down the parts of the Intel manual you need to know. But yeah, only for 32-bit. I always found x64 very hacky with the register bits split up between bytes and whatnot. 32-bit is a legitimately nice ergonomic machine.
- alok-g 2y agoThanks for your efforts creating SubX. Now I understand the motivations behind that better.