;
; Veneer for our C code
;

   AREA   |!!!!First|, CODE, READONLY

; VENEER - a simple veneer so that we can call our C code from BASIC
;          without having to re-write things many times
;          The C routine $n will be called with
   MACRO
$n VENEER $args
   IMPORT $n

veneer_$n
   LCLS   myargs
    [ "$args" = "" :LOR: "$args" = "0" :LOR: "$args" = "1" :LOR: "$args" = "2" :LOR: "$args" = "3" :LOR: "$args" = "4"
myargs SETS ""
    |
      [ "$args" = "5"
myargs SETS "r4,"
      |
        [ "$args" = "6"
myargs SETS "r4-r5,"
        |
          [ "$args" = "7"
myargs SETS "r4-r6,"
          |
            [ "$args" = "8"
myargs SETS "r4-r7,"
            ]
          ]
        ]
      ]
    ]
   STMFD  sp!,{$myargs.r14}
   BL     $n
   CMP    r0,r0
   LDMFD  sp!,{$myargs.pc}
   MEND

; Start of the output file
   B      veneer___RelocCode
   B      veneer_get_version

; the veneered code itself
__RelocCode VENEER 0
get_version VENEER 0

   END
