Skip navigation
NintendoAge
Welcome, Guest! Please Login or Join
Loading...

Reading external subroutines using Asm6

May 06 at 9:16:50 AM
reaktor24 (0)

< Cherub >
Posts: 3 - Joined: 05/06/2019
Profile
I am trying to use a simple subroutine in a seperate .asm file but I'm getting an error message when the program is run:

'Can't determine address'

Do I need to include a memory location or something with .org?

I tried .org $C600 as a test and it seems to assemble without errors. Of course, the rom file doesn't work.

Anyone know where I'm going wrong?

Steve

May 06 at 10:41:46 AM
Mega Mario Man (63)
avatar
(Tim ) < Ridley Wrangler >
Posts: 2743 - Joined: 02/13/2014
Nebraska
Profile
I do this all of the time with storing code in other banks in separate files.

You need to include the file name in the main file of your code like so.
  .bank 0        
  .org $8000  
  .include "maincode2.asm"

So, in Bank 0 of maincode.asm, I am storing the file maincode2.asm. You can do this anywhere in your code, you don't need to have the .org or memory location there unless you are specifically storing it at that location for some reason. The key is to use use that .include. This literally puts all of the code in that file in that exact location in your code.

I like to use this for bankswitching. Below is just a peak at how I organize my banks and include separate files. If you are not to bankswitching yet, don't worry about that part. Just understand that whereever you put the -.include "filename.asm"- in you code is exactly where the assembler sees the code in filename.asm.
 
;;;;;;;;;;;;;;;;;bankSource=00;;;;;;;;;;;;;;;;;;;;
  .bank 0        
  .org $8000  
  .include "maincode2.asm"
    
  .bank 1
  .org $A000
  .include "maincode3.asm" 

;;;;;;;;;;;;;;;;;bankSource=01;;;;;;;;;;;;;;;;;;;; .bank 2 ;;;NO MORE CODE! FOR FLASH SAVING!!! ;.org $8000 .org $0500 ;;put code in ram .include "flashsavefiles\savecode.asm" .bank 3 .org $A000 SCORESFLASH: .incbin "flashsavefiles\blank.bin"

;;;;;;;;;;;;;;;;;bankSource=02;;;;;;;;;;;;;;;;;;;; .bank 4 .org $8000 TitleGraphics: .incbin "CHRfiles\titlesprites.chr" .incbin "CHRfiles\titlegraphics.chr" .bank 5 .org $A000 GameGraphics: .incbin "CHRfiles\gamesprites.chr" GameBGGraphics: .incbin "CHRfiles\gamegraphics.chr"

-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter

May 06 at 12:20:43 PM
reaktor24 (0)

< Cherub >
Posts: 3 - Joined: 05/06/2019
Profile
Hi Mega Mario

That's great thanks. Working okay now!  

Cheers