Re: [cc65] How to prototype an assembler function?

From: Payton Byrd <plbyrd1gmail.com>
Date: 2010-04-25 11:04:28
Success!!!  Thank you so much for your help.  I was able to get it working
with the following assembler code

.setcpu "6502"

.smart on

.autoimport on

.case on

.importzp sp, sreg, regsave, regbank, tmp1, ptr1, ptr2

.macpack longbranch


> .export _writeVdcRegister

.export _readVdcRegister


> ;------------------------

; Write A to VDC Register

; stored in X

.proc _writeVdcRegister

 JSR pusha ; Store the accumulator


>  LDY #$01 ; Offset for first of two parameters

 LDX #$00 ; Dunno yet

 LDA (sp),y ; Load accumulator with parameter value


>  STA $D600 ; Put the value into the register

WVR1: BIT $D600 ; Compare the top bit of the register

 BPL WVR1 ; Branch if the top bit is low (0)

  LDY #$00 ; Offset for the second of two parameters

 LDX #$00 ; Still dunno

 LDA (sp),y ; Store the parameter in the accumulator


>  STA $D601 ; Store the accumulator in the register's value


>  JSR incsp2 ; Finish our function

 RTS

.endproc


> ;-------------------------

; Read A from VDC Register

; stored in X

.proc _readVdcRegister

 JSR pusha ; Store the accumulator


>  LDY #$00 ; Offset for the parameter

 LDX #$00 ; Still dunno

 LDA (sp),y ; Store the parameter in the accumulator


>  STA $D600 ; Put the value into the register

RVR1: BIT $D600 ; Compare the top bit of the register

 BPL RVR1 ; Branch if the top bit is low (0)

  LDA $D601 ; Get the result into the accumulator


>  JSR incsp1 ; I assume the returns the accumulator

 RTS ; as the return value of the function?

.endproc

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Apr 25 11:04:56 2010

This archive was generated by hypermail 2.1.8 : 2010-04-25 11:04:58 CEST