Warning

You're browsing the old v2.x documentation. This version is no longer maintained. Click here to go the v3.x documentation.

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
extensions_tutorial [2019/12/12 11:10] – [Adding new functions] neilsextensions_tutorial [2019/12/12 11:36] – [Referencing XC=BASIC symbols in assembly language] neils
Line 51: Line 51:
 Simply use the [[fun|FUN ... ENDFUN]] block to define new functions. Simply use the [[fun|FUN ... ENDFUN]] block to define new functions.
  
-==== Referencing XC=BASIC symbols in assembly language ====+===== Referencing XC=BASIC symbols in assembly language =====
  
 To speed things up, you should write functions in assembly language. To be able to do this, you need to know how to access **XC=BASIC** symbols and features in assembly. The following table serves as a guide: To speed things up, you should write functions in assembly language. To be able to do this, you need to know how to access **XC=BASIC** symbols and features in assembly. The following table serves as a guide:
Line 70: Line 70:
      
   fun joy_firepressed!(port!)   fun joy_firepressed!(port!)
-    rem -- we start +    dim result!
     asm "     asm "
-    +      ; This is how to refer to a function's argument 
 +      lda {self}.port 
 +      ; Port #2 becomes 0, Port #1 remains 1 
 +      ora #%00000001 
 +      tax 
 +      ; This is how to refer to a global constant 
 +      lda _JOY_PORT2, x 
 +      ora #%00001000 
 +      eor #%00001000 
 +      lsr 
 +      lsr 
 +      lsr 
 +      ; A now holds the return value of our function 
 +      ; Write it to the variable "result!" 
 +      sta {self}.result
     "     "
 +    return result!
   endfun   endfun