English Amiga Board Amiga Lore


Go Back   English Amiga Board > Coders > Coders. General > Coders. Tutorials

 
 
Thread Tools
Old 17 June 2013, 22:26   #1
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 38
Posts: 1,917
Creating Macros

Hi,

I have already created some macros for use in my own ASM code, but I am wondering if it is possible to create a macro to print text that follows it, for example:

Code:
    Print "text"
I could dump all the text strings together and select them by number, but that is time consuming and these text strings are only going to be for debugging.
I tried doing the following, but it seems to just end up pointing the address registers to nothing!

Code:
    Print    MACRO
             move.l    /1,a1
             ENDM

Is it possible to do this in DevPac 3.18?
Lonewolf10 is offline  
AdSense AdSense  
Old 17 June 2013, 23:13   #2
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,017
One way of doing it (you may have to change the syntax for DevPac):
Code:
Print    macro
         lea   .text\@, a0
         ...
         bra   .done\@

.text\@  dc.b  \1
         even
.done\@
         endm
Leffmann is offline  
Old 18 June 2013, 08:54   #3
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 996
You can get rid of the branch instruction when you put the strings into another section (e.g. "data"). Or put them into a second code section and rely on the linker to merge it with your main code section, due to PC-relative references (or force the merge with some small-code option).

A separate section for strings also has the advantage that you don't need to align the address after each definition.

Code:
Print   macro
        section texts,code
.text\@ dc.b    \1
        dc.b    0

        code
        lea     .text\@(pc),a0
        bsr     print_function
        endm
If you want to create absolute output instead of an AmigaDOS executable you can still use sections, but define the layout in memory using a linker script. For example:
Code:
SECTIONS {
        . = 0x10000;
        .text: { *(CODE code) *(texts) }
        . = ALIGN(2);
        .data: { *(DATA data) }
        . = ALIGN(2);
        .sdata: {
                _LinkerDB = . + 0x7ffe;
                _SDA_BASE_ = . + 0x7ffe;
                *(.sdata __MERGED)
        }
        . = ALIGN(2);
        .bss: { *(BSS bss) }
}
phx is offline  
Old 18 June 2013, 22:12   #4
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 38
Posts: 1,917
Thanks for the help guys
Lonewolf10 is offline  
AdSense AdSense  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating your own IPFs kaffer project.SPS (was CAPS) 72 19 August 2014 04:04
Creating a Self-Booting CD32 CD (Here we go again...) Heavy Stylus support.Hardware 69 14 August 2008 19:08
Keyboard Input Options > macros/key combinations ? Konrad support.WinUAE 3 23 May 2007 17:22
Creating Adf Retro1234 support.Other 0 17 July 2006 16:25

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:27.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Page generated in 0.13368 seconds with 12 queries