reesey-spoon wrote:
In C, I would make a header file and declare these before I defined them so they can be used in other modules (right?) and include the header file whenever I needed it. I am not sure what is the """"right way"""" to do this in assembly, but I have a vested interest in doing this per-industry-standard as I begin searching for careers in the tech field. Any input or words of wisdom about program structure would be greatly appreciated
What I do in ca65 (and this is the ca65 from the cc65 suite) is to have a header file for each program (.s) file and that's included in both the .s file and any other files that needs to access the symbols in that particular file. The keyword in the header file is
.global which effectively says "export this symbol if defined in this file, or act as a placeholder in the object file to be resolved at link time"
So e.g.
Code:
;********************************************************************************
;* strout.h:
;* String print utility
;********************************************************************************
.global _strout
Then in the strout.s file:
Code:
;********************************************************************************
;* strout.s:
;* String print utility
;********************************************************************************
.macpack generic
.include "rubyOs.h"
.include "osVectors.h"
.include "strout.h"
and in any other file that needs to call _strout:
Code:
;********************************************************************************
; textUtil.s:
; Utility text handling subroutines
; Note: Underline functions are called from the standard osVectors
; block at the top of memory
;********************************************************************************
.macpack generic
.include "hardware.h"
.include "keys.h"
.include "zeroPage.h"
.include "osVectors.h"
.include "strout.h"
.include "oHex.h"
.include "textUtil.h"
and so on.
I don't use scopes and the
:: construct in my code at all, but this way lets me treat it as separately compiled modules in exactly the same way I separately compile C programs.
(I do use
.proc and
.endproc several times in the same file but merely as a way to keep labels separate between individual little subroutines. This works exactly the way defining a function does in C).
Hope that helps a little...
-Gordon
_________________
--
Gordon Henderson.
See my
Ruby 6502 and 65816 SBC projects here:
https://projects.drogon.net/ruby/