Last active
          December 31, 2015 22:39 
        
      - 
      
- 
        Save vittorioromeo/8055017 to your computer and use it in GitHub Desktop. 
    veeasm test
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | //!ssvasm | |
| $require_registers(3); | |
| $define(R0, 0); | |
| $define(R1, 1); | |
| $define(ROutput, 2); | |
| // _______________________________ | |
| // FN_MAIN function | |
| // * entrypoint | |
| // * returns in ROutput | |
| // _______________________________ | |
| $label(FN_MAIN); | |
| // Load constants | |
| loadFloatCVToR(R0, 2.f); | |
| loadFloatCVToR(R1, 123.f); | |
| // Save registers | |
| pushRVToS(R0); | |
| pushRVToS(R1); | |
| // Push args | |
| pushRVToS(R0); | |
| // Call func | |
| callPI(FN_DUP_INV); | |
| // Get return value | |
| moveRVToR(ROutput, R0); | |
| // Pop args | |
| popSV(); | |
| // Restore registers | |
| popSVToR(R1); | |
| popSVToR(R0); | |
| // Push output to stack | |
| pushRVToS(ROutput); | |
| halt(); | |
| // _______________________________ | |
| // FN_DUP_INV function | |
| // * needs 1 float argument | |
| // * uses R0 | |
| // * returns in R0 | |
| // _______________________________ | |
| $label(FN_DUP_INV); | |
| // Get arg from stack | |
| moveSBOVToR(R0, 2); | |
| // Duplicate value | |
| pushRVToS(R0); | |
| pushSVToS(); | |
| addFloat2SVs(); | |
| // Store return value | |
| popSVToR(R0); | |
| // Save registers | |
| // Not needed | |
| // Push args | |
| pushRVToS(R0); | |
| // Call func | |
| callPI(FN_INV); | |
| // Get return value | |
| // Return value is in R0 | |
| // Pop args | |
| popSV(); | |
| // Restore registers | |
| // Not needed | |
| returnPI(); | |
| // _______________________________ | |
| // FN_INV function | |
| // * needs 1 float argument | |
| // * uses R0 | |
| // * returns in R0 | |
| // _______________________________ | |
| $label(FN_INV); | |
| // Get arg from stack | |
| moveSBOVToR(R0, 2); | |
| // Invert value | |
| pushRVToS(R0); | |
| pushFloatCVToS(-1.f); | |
| multiplyFloat2SVs(); | |
| // Store return value | |
| popSVToR(R0); | |
| returnPI(); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment