überSpark: add CASM JSON definitions for x86 32-bit CPU HWM

This task will add next-gen tool-chain support for JSON based CASM instruction definitions for the x86 32-bit CPU HWM. Specifically, we will be enhancing the
the überSpark manifest found here: https://github.com/uberspark/uberspark/blob/develop/src-nextgen/hwm/cpu/x86/32-bit/core-gen1/uberspark.json

The following are the proposed subtasks:

  1. Ensure your fork of uberspark.git is up to date with the upstream uberspark.git repository. The following commands can achieve this on a local checkout of your fork.

    git remote add upstream https://github.com/uberspark/uberspark.git
    git fetch -a upstream  
    git checkout develop 
    git pull upstream develop 
    git push origin develop
    
  2. Build and install the uberspark tool-chain as detailed here: uberspark/install.rst at develop · uberspark/uberspark · GitHub

  3. Create a feature branch on your fork off the develop branch. Name it feature-cpu-hwm-casm-x86-32bit

  4. Revise: https://github.com/uberspark/uberspark/blob/develop/src-nextgen/hwm/cpu/x86/32-bit/core-gen1/uberspark.json to add a new JSON array node for CASM instruction definitions as below:

    "uberspark.hwm.cpu.casm_instructions" : [ 
        {
           "casm_mnemonic" : "<casm_mnemonic>", 
           "casm_total_operands": "<casm_total_operarands>",
           "casm_implementation" : "<casm_implementation>",
           "output_assembly" : "<output_assembly>"
         }
    ]
    

    Note that the there can be multiple records within this array definition each defining a unique CASM instruction. Each record will basically be constructed using the contents of the CASM instruction macros as definied in: https://github.com/uberspark/uberspark/blob/develop/src-nextgen/hwm/cpu/x86/32-bit/generic/include/cpu.h#L2641

    As an example for the __casm_jmplabel(x) definition as in: https://github.com/uberspark/uberspark/blob/develop/src-nextgen/hwm/cpu/x86/32-bit/generic/include/cpu.h#L2650 the following will be the corresponding JSON node:

    {
            "casm_mnemonic" : "__casm__jmplabel", 
            "casm_total_operands": "1",
            "casm_implementation" : "if (1) goto #1",
            "output_assembly" : "jmp #1"
    }
    
  5. The above will be repeated for all the instruction mnemonics defined within: https://github.com/uberspark/uberspark/blob/develop/src-nextgen/hwm/cpu/x86/32-bit/generic/include/cpu.h#L2641

Working branches:
TBD

PR(s):

Merge(s):

Should both casm_implementation and output_assembly be arrays?
Example1: https://github.com/uberspark/uberspark/blob/a016c66308a39910915ab0149042caa3a8ae8ca3/src-nextgen/hwm/cpu/x86/32-bit/generic/include/cpu.h#L2702
Json:

   {
       "casm_mnemonic" : "__casm__call_c_2p", 
       "casm_total_operands": "3",  
       "casm_implementation" : [
           "_impl__casm__pushl_mem(CASM_RET_EIP)",
           "1( (#2) *((uint32_t *)(hwm_cpu_gprs_esp+4)) , (#3) *((uint32_t *)(hwm_cpu_gprs_esp+8)) )"}
       ],
       "output_assembly" : ["call "#1" "]
    }

Example2: https://github.com/uberspark/uberspark/blob/a016c66308a39910915ab0149042caa3a8ae8ca3/src-nextgen/hwm/cpu/x86/32-bit/generic/include/cpu.h#L2740
Json:

   {
       "casm_mnemonic" : "__casm__jmpapentry", 
       "casm_total_operands": "0",  
       "casm_implementation" : [
           "hwm_vdriver_apentry()",
           "_impl__casm__hlt()"
       ],
       "output_assembly" : [
           "jmpl *%eax",
           "hlt "
       ]
    }

And the example in the task description will be:

{
        "casm_mnemonic" : "__casm__jmplabel", 
        "casm_total_operands": "1",
        "casm_implementation" : ["if (1) goto #1"],
        "output_assembly" : ["jmp #1"]
}

Good point. Yes!. Would be great if you can make them arrays. Thanks @zhang-zichao !

Hi @amitvasudevan ,

Sorry for the delay. Just create the PR. Please have a look, thanks!

Merged PR upstream. Add PR and merge info to OP. Closing this task/topic thread. Thanks @zhang-zichao !

1 Like