English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 20 October 2015, 19:31   #1
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 41
Posts: 1,924
Address pointers with Program Counter

Hi,

I have some code that I have been working on for some time (due to many distractions...). Now that it is pretty much finished I am trying to convert it so that it is compatible with systems with fast memory.

Clearly I don't fully understand the limitations of using the program counter as I get the following errors when assembling (with DevPac 3.18):

Code:
Error: linker format restriction at line 1007 in file DD_L-Strikes.s33
 1007 01.0000009A 41FAC7C2                     lea.l   sprite0(pc),a0

Error: linker format restriction at line 1016 in file DD_L-Strikes.s33
 1016 01.000000AC 4BFA0000                     lea.l   screen(pc),a5

...and I know someone will ask to see example code, so here it is:


Code:
pre_title_screen:

    jsr         setup_screen2           ;setup screen and colours (logo_cop)

                                        ;*** Clear screen ***
    moveq       #4-1,d7                 ;bitplanes to clear (e.g. 4=4-1)
    lea.l       screen,a0               ;destination address
.next_plane
                                        ;clear 597 lines...
    move.w      #0,d0                   ;modulo (e.g. 40-width for Lowres)
    move.w      #%1001010101010100,d1   ;size of area, in BLTSIZE format
                                        ;(%hhhhhhhhhhwwwwww) h=lines,w=words
    jsr         clear_screen            ;clear main menu text from screen
    adda.l      IDAT_img_plane,a0       ;point to next bitplane
    dbra        d7,.next_plane

                                        ;*** Clear sprites 0-7 and 0b-7b ***
    lea.l       sprite0(pc),a0          ;start of data to clear
    move.w      #0,d0                   ;modulo (e.g. 40-width for Lowres)
    move.w      #%0010000000010111,d1   ;size of area, in BLTSIZE format
                                        ;(%hhhhhhhhhhwwwwww) h=lines,w=words
                                        ;5888 bytes = 2944 words
                                        ;           = 128 words * 23 'lines'
    jsr	        clear_screen

                                        ;*** Decode & display title image ***
    lea.l       screen(pc),a5           ;set destination
    move.l      a5,IDAT_img_dest
    lea.l       title+12,a6             ;address of sourcefile+offset to IHDR
    move.w      #1,IDAT_image_type      ;1=Ppaint, 2=MSpaint
    jsr	        decode_png

    WaitLine MAX_SCANLINE

What am I doing wrong?

Last edited by Lonewolf10; 20 October 2015 at 19:46. Reason: formatting changes
Lonewolf10 is offline  
Old 20 October 2015, 20:40   #2
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 52
Posts: 1,320
Try
lea Sprite1,A0
not
lea Sprite1(pc),A0
Don_Adan is offline  
Old 20 October 2015, 21:28   #3
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 46
Posts: 24,737
sprite0 and screen are probably in different section == pc relative addressing is not possible.
Toni Wilen is online now  
Old 20 October 2015, 22:06   #4
hooverphonique
ex. demoscener "Bigmama"

 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,246
yes, Toni is on the right track there..
hooverphonique is offline  
Old 20 October 2015, 22:26   #5
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,883
Toni is certainly right for the 'screen' reference. But 'sprite0' seems to be in the same section, although the distance is larger than 32K. Look at the $c7c2 in Devpac's output:
Code:
1007 01.0000009A 41FAC7C2                     lea.l   sprite0(pc),a0
Unfortunately both cases generate the same error message.

BTW, a PC-relative reference to a different section is not always illegal. This is just a problem for AmigaDOS, because you cannot predict the address of a section. The scatter-loader will allocate individual memory for each section and relocate it there.

The AtariST would have no problem with PC-referencing data-symbols from the text-section, as text, data and bss are always loaded as a single unit. Also Unixes have fixed section addresses.

I would like to know if Devpac-Atari (GenST) would show the same error...
phx is offline  
Old 21 October 2015, 00:02   #6
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 41
Posts: 1,924
Quote:
Originally Posted by Toni Wilen View Post
sprite0 and screen are probably in different section == pc relative addressing is not possible.
'sprite0' and 'screen' are both in a BSS section, at the end of the file. All the code is in a CODE section at the start of the file.
In short, you are correct


Quote:
Originally Posted by phx View Post
BTW, a PC-relative reference to a different section is not always illegal.
So it would work only if the address being referenced lies within the range (16KB?) of the current PC address?
Lonewolf10 is offline  
Old 21 October 2015, 11:26   #7
hooverphonique
ex. demoscener "Bigmama"

 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,246
Quote:
Originally Posted by Lonewolf10 View Post
So it would work only if the address being referenced lies within the range (16KB?) of the current PC address?
on amiga it is not possible to use a pc-relative address to a different section, because the assembler/linker cannot know up front, what the address offset between the two will be ;-)
hooverphonique is offline  
Old 21 October 2015, 22:02   #8
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 41
Posts: 1,924
Ok, thanks for all the help guys
Lonewolf10 is offline  
Old 27 October 2015, 11:40   #9
meynaf
son of 68k
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 48
Posts: 4,256
Quote:
Originally Posted by phx View Post
I would like to know if Devpac-Atari (GenST) would show the same error...
I did that all the time in my ST days, and Devpac 2 didn't show an error at all.
meynaf is offline  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for Cool Pointers squidbass Amiga scene 2 27 March 2015 12:12
Program Counter with Offset - why? Jherek Carnelia Coders. General 26 21 March 2011 10:49
2 Mouse Pointers!!! wandeep support.WinUAE 3 21 May 2008 13:44
blizzard 1230 MkII plcc counter chip arizz support.Hardware 0 23 April 2005 02:04

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 15:01.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.08456 seconds with 13 queries