20 October 2015, 19:31 | #1 |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
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 |
20 October 2015, 20:40 | #2 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,050
|
Try
lea Sprite1,A0 not lea Sprite1(pc),A0 |
20 October 2015, 21:28 | #3 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,574
|
sprite0 and screen are probably in different section == pc relative addressing is not possible.
|
20 October 2015, 22:06 | #4 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,643
|
yes, Toni is on the right track there..
|
20 October 2015, 22:26 | #5 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,552
|
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 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... |
21 October 2015, 00:02 | #6 | |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
Quote:
In short, you are correct So it would work only if the address being referenced lies within the range (16KB?) of the current PC address? |
|
21 October 2015, 11:26 | #7 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,643
|
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 ;-)
|
21 October 2015, 22:02 | #8 |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
Ok, thanks for all the help guys
|
27 October 2015, 11:40 | #9 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,359
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
blizzard 1230 MkII plcc counter chip | arizz | support.Hardware | 1 | 12 April 2022 23:29 |
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 |
|
|