![]() |
![]() |
#1 |
Registered User
Join Date: Apr 2018
Location: Germany
Posts: 201
|
Beginner question: How to use an Include file for own functions (sub routines)
Suppose I have an assembler program that consists of the file main.asm and works. In this program there is a call
Code:
bsr test_func Code:
test_func moveq #111,d0 ; Imagine something useful here rts Code:
include my_functions.asm I come from C, and there includes are included at the beginning of the file and the functions are called further down. How is this properly done in assembler; are the own helper files included below the main code to avoid the entry point problem? |
![]() |
![]() |
#2 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,097
|
Don't include at the beggining, or add "bra your_main_function" before the include statement (that bra will become the first instruction of your program).
|
![]() |
![]() |
#3 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,583
|
You could also remove the
include, add an xdef test_funcand assemble my_functions.asm into its own object file. Then use a linker and link my_functions.o last. You should be used to it when coming from C. ![]() The advantage is that symbols from my_function.asm don't clutter your namespace and you don't have to assemble everything on any tiny modification. |
![]() |
![]() |
#4 |
Registered User
Join Date: Apr 2018
Location: Germany
Posts: 201
|
Thanks for your answers, bot are helpful
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Include file path priorities for assemblers | phx | Coders. General | 20 | 07 July 2020 16:30 |
C Include file with hardware registers | sparhawk | Coders. General | 4 | 20 November 2019 20:59 |
Beginner question about WHLoad (2 different methods?) | c0dehunter | support.Apps | 17 | 13 January 2019 20:29 |
NDK 3.1 Include file problem. | Thorham | Coders. General | 4 | 04 February 2011 20:58 |
beginner question - how to use USB joystick/pad with WINUAE??! | extentofmysin | support.WinUAE | 7 | 23 August 2006 18:56 |
|
|