[HN Gopher] SubX: A minimalist assembly language for a subset of...
       ___________________________________________________________________
        
       SubX: A minimalist assembly language for a subset of the x86 ISA
        
       Author : peter_d_sherman
       Score  : 50 points
       Date   : 2021-03-20 19:14 UTC (3 hours ago)
        
 (HTM) web link (www.mdeditor.tw)
 (TXT) w3m dump (www.mdeditor.tw)
        
       | akkartik wrote:
       | Not sure what's going on with this website, but I'm happy to see
       | interest in my project:
       | 
       | https://github.com/akkartik/mu#readme
       | 
       | OP is an old version of the Readme from a year ago. Here's the
       | current page on SubX:
       | https://github.com/akkartik/mu/blob/main/subx.md
        
         | jiofih wrote:
         | Thanks for that. This article is nearly impossible to read on
         | mobile due to word wrapping and riddled with ads.
         | 
         | My first thought was "can this lead to easier implementation of
         | a higher level language" and it seems Mu is exactly that?
         | What's performance like?
        
           | ant6n wrote:
           | I'm having the same problem reading the website (wordbreaks,
           | ads). I wonder:
           | 
           | * is there a list of instructions that are included?
           | 
           | * is it possible to target this x86 subset with some C
           | compiler?
        
             | akkartik wrote:
             | List of supported instructions:
             | https://github.com/akkartik/mu/blob/main/subx_opcodes
             | 
             | I haven't tried to implement C, but can't immediately think
             | of a reason why not. Forks strongly encouraged; if you
             | decide to try to implement one, I'd love to contribute.
        
           | akkartik wrote:
           | Yeah! Most statements translate to a single instruction, and
           | you have to pick registers, so even though performance hasn't
           | been a priority I think it'll tend to be pretty good. It does
           | have some simplifications for safety and clarity rather than
           | optimization. For example, setting a register to zero
           | generates a copy with a 32-bit immediate rather than the xor
           | trick most Assembly programmers would use.
        
       | userbinator wrote:
       | With the description of "minimalist" I was expecting something
       | more like http://www.terse.com/ but this turns out to be even
       | more verbose than regular Asm, more like writing pure machine
       | code. Also, I'm puzzled at the author calling opcode cd syscall
       | --- that's "int imm8", and the real syscall instruction resides
       | on the second page (0f 05).
       | 
       | If you're going to write x86 machine code, then memorising the
       | instruction set is far easier in octal:
       | 
       | https://gist.github.com/seanjensengrey/f971c20d05d4d0efc0781...
        
         | akkartik wrote:
         | The stuff after / is often just comments. 'syscall' feels more
         | accurate for int 80 than 'interrupt', but the language doesn't
         | encode the name.
         | 
         | I only found out about the octal after I started on SubX. I
         | considered switching to it, but thought it might be useful to
         | keep the same opcodes as the Intel manual.
        
         | akkartik wrote:
         | Thanks for the pointer to terse! I hadn't seen it before.
         | 
         | I think of concise as "expressive" or "cryptic". "Minimalist"
         | usually connotes small implementation. Like chibicc or
         | something.
        
         | jart wrote:
         | Here's another octal x86 reference for comparison:
         | https://justine.lol/blinkenlights/8086.html
        
           | akkartik wrote:
           | Oh I'd missed that page on the blinkenlights site. Thanks!
        
             | jart wrote:
             | I hope you enjoy it! Since you mentioned chibicc earlier in
             | this thread, and you've written an assembler of your own,
             | this might be of interest to you: https://github.com/jart/c
             | osmopolitan/blob/master/third_party... Your work was
             | brought to my attention maybe a year and a half ago and I
             | think what you're doing is pretty cool. Feel free to reach
             | out by email if there's anything I can do to help.
        
       ___________________________________________________________________
       (page generated 2021-03-20 23:00 UTC)