Assembly Programming - Perihelion tutorial 6 - Addressing Mode Not Allowed

GFA, ASM, STOS, ...

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

ZerONOP
Atarian
Atarian
Posts: 5
Joined: Thu Mar 05, 2015 5:40 am

Assembly Programming - Perihelion tutorial 6 - Addressing Mode Not Allowed

Postby ZerONOP » Thu Mar 05, 2015 6:07 am

Hi, new to the forum and new to assembly code as well, and I have hit a wall that I am unable to find answers elsewhere.

I have been going through the Perihelion tutorials, and they have been really good so far, and I feel like I am actually beginning to grasp what is being presented. I am currently going through tutorial 6, that guides you in creating a program that displays a Degas Elite image and then exits back out when a key is pressed. I am using DEVPAC 3.10 through the Hatari emulator.

After deciphering the code on the wiki(Seems to be some formatting issues with the body of code used for the display program on the wiki) this is what I have for my code. (NOTE: I use a custom 320x200px image for my code as the image used in the tutorial doesn't seem to be available anymore...)

Code: Select all

   jsr   initialize
   movem.l   #picture+2,d0-d7   ;put picture palette in d0-d7
   movem.l   d0-d7,$ffff8240   ;move pallett from cpu to pallett mem
   move.w   #2,-(a7)   ;get physbase
   trap   #14
   addq.l   #2,a7
   move.l   d0,a0      ;points to screen memory
   move.l   #picture+34,a1   ;a1 now points to the actual picture data
   move.l   #7999,d0   ;7999 longwords to a screen loop
   
loop:
   move.l   (a1)+,(a0)+   ;Move one longword to screen
   dbf   d0,loop
   move.w   #7,-(a7)   ;wait for keeppress
   trap   #1
   addq.l   #2,a7
   
   jsr restore
   clr.l   -(a7)
   trap   #1

initialize:   
   clr.l   -(a7)      ;clear stack
   move.w   #32,-(a7)   ;prepare for super mode
   trap   #1      ;call gemdos
   addq.l   #6,a7      ;clear up stack
   move.l   d0,old_stack   ;backup old stack pointer
   
   rts
   
restore:
   move.l old_stack,-(a7)   ;restore olde stack pointer
   move.w   #32,-(a7)   ;back to user mode
   trap   #1      ;call gemdos
   addq.l   #6,a7      ;clear the stack
   clr.l   -(a7)      ;clen the stack address
   trap   #1      ;call gemdos
   
   rts
   
picture:   incbin   "\GFX\64BIT.PI1"

old_stack:   dc.l   0


This produces an error during assemble that says

Code: Select all

Error: addressing mode not allowed at line 3 in file C:\\DEVPAK\MY_STUFF\PI
3 T  00000006 4CFC00FF00000002   movem.l #picture+2,d0-d7


From what I can gather it doesn't seem to like what is in the destination operand for the instruction on line 3. The way that the addresses are called maybe? From what I have been able to find on the internets, this seems to be a valid form of calling these registers, buy might be a processor incompatibility. But, according to the tutorial, this seems to be the way that you grab the pallet data from the picture file, and drop it to the data registers, before shoving it into the appropriate point in memory in the next line of code.

Is there something wrong with my code, or is there another way to perform the task at line 3?

If I comment out line 3, the program assembles without errors, and loads the image, without the proper pallet of course. It does load though.

I have attached the image file that I use in my code, if someone else wishes to give it a try.
64BIT.PI1.zip
You do not have the required permissions to view the files attached to this post.

rpineau
Atari Super Hero
Atari Super Hero
Posts: 501
Joined: Wed Jun 29, 2011 6:39 am
Location: California / USA
Contact:

Re: Assembly Programming - Perihelion tutorial 6 - Addressing Mode Not Allowed

Postby rpineau » Thu Mar 05, 2015 7:30 am

From memory , movem.l requires an address register as the source or destination, I think.
so you probably need something like this :

Code: Select all

move.l #picture+2,A0
movem.l (a0)+,d0-d7


Rodolphe
Falcon + AB040 + Eclipse PCI + ATI Rage VGA card + NE2000 Ethernec + HxC Floppy Emulator
MegaSTE 4MB + CosmosEx / 1040 STF for hardware dev
http://www.rti-zone.org/atari.php

User avatar
spiny
Disk Imager Supreme
Disk Imager Supreme
Posts: 2333
Joined: Mon Aug 11, 2003 11:53 pm
Location: just outside bristol
Contact:

Re: Assembly Programming - Perihelion tutorial 6 - Addressing Mode Not Allowed

Postby spiny » Thu Mar 05, 2015 8:46 am

your code looks good, and from the error, it seems that devpac can't open the .PI1 image you're using. I am also unable to open the image you attached, so is probably that :)

this is the one from the tutorial:

JET_LI.zip


try that instead :)

also, you didn't show how you are calling the image in your code, something like this works:

picture incbin c:\2012\sdown12\picture.pi1

where the path is relative to the mount point in your emulator, not the absolute path on your PC/MACs hard drive :)
You do not have the required permissions to view the files attached to this post.

User avatar
spiny
Disk Imager Supreme
Disk Imager Supreme
Posts: 2333
Joined: Mon Aug 11, 2003 11:53 pm
Location: just outside bristol
Contact:

Re: Assembly Programming - Perihelion tutorial 6 - Addressing Mode Not Allowed

Postby spiny » Thu Mar 05, 2015 8:51 am

another thing, not sure if this makes a difference, but you have two extra 'f's in your palete address than I use, this is what I use:

Code: Select all

   movem.l   picture2+2,d0-d7   ; put picture palette in d0-d7
   movem.l   d0-d7,$ff8240      ; move palette from d0-d7 to actual hardware register where pal lives

ZerONOP
Atarian
Atarian
Posts: 5
Joined: Thu Mar 05, 2015 5:40 am

Re: Assembly Programming - Perihelion tutorial 6 - Addressing Mode Not Allowed

Postby ZerONOP » Fri Mar 06, 2015 5:35 am

rpineau wrote:From memory , movem.l requires an address register as the source or destination, I think.
so you probably need something like this :

Code: Select all

move.l #picture+2,A0
movem.l (a0)+,d0-d7


Rodolphe


The above change worked like a charm. Even my custom image worked just fine once I realized that I was coding for the low resolution mode, and actually switch back to low res before executing the program. Thank you rpineau! Should this be adjusted in the orginal tutorial, or is the tutorial being historically preserved?

And just so I understand, the "movem" instruction requires address/register for both source and destination operands?

spiny wrote:another thing, not sure if this makes a difference, but you have two extra 'f's in your palete address than I use, this is what I use:

Code: Select all

   movem.l   picture2+2,d0-d7   ; put picture palette in d0-d7
   movem.l   d0-d7,$ff8240      ; move palette from d0-d7 to actual hardware register where pal lives


Thanks spiny for the Jet Li image, it works as well.

It doesn't make any noticeable difference whether or not I have 2 or 4 f's. Based on my very very limited knowledge with assembler, it seems that addresses are usually long-word right? Requiring 4 f's for the address to read along with the other two bites(word) to make a complete address. But 2 f's seems to work fine as well. Could someone explain please?

User avatar
spiny
Disk Imager Supreme
Disk Imager Supreme
Posts: 2333
Joined: Mon Aug 11, 2003 11:53 pm
Location: just outside bristol
Contact:

Re: Assembly Programming - Perihelion tutorial 6 - Addressing Mode Not Allowed

Postby spiny » Fri Mar 06, 2015 4:11 pm

glad you got it working, coding isn't my strong point (as people subjected to my demos will confirm :D ) the Perihellion tutorials are worth sticking with, I learnt a lot!

rpineau
Atari Super Hero
Atari Super Hero
Posts: 501
Joined: Wed Jun 29, 2011 6:39 am
Location: California / USA
Contact:

Re: Assembly Programming - Perihelion tutorial 6 - Addressing Mode Not Allowed

Postby rpineau » Fri Mar 06, 2015 4:56 pm

ZerONOP wrote:It doesn't make any noticeable difference whether or not I have 2 or 4 f's. Based on my very very limited knowledge with assembler, it seems that addresses are usually long-word right? Requiring 4 f's for the address to read along with the other two bites(word) to make a complete address. But 2 f's seems to work fine as well. Could someone explain please?


The 68000 has a 24 bit address bus on the chip. So $FFFF8240 and $00FF8240 point to the same physical address. This only makes a difference if you intend to run your code on a 68020 and up that are fully wired to 32 bit address space. Atari machine with a 68030 and up usualy use the MMU to remap all of this to the same address space anyway.

Rodolpeh
Falcon + AB040 + Eclipse PCI + ATI Rage VGA card + NE2000 Ethernec + HxC Floppy Emulator
MegaSTE 4MB + CosmosEx / 1040 STF for hardware dev
http://www.rti-zone.org/atari.php

User avatar
dml
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3468
Joined: Sat Jun 30, 2012 9:33 am

Re: Assembly Programming - Perihelion tutorial 6 - Addressing Mode Not Allowed

Postby dml » Fri Mar 06, 2015 9:50 pm

And just so I understand, the "movem" instruction requires address/register for both source and destination operands?


Actually, this was not the problem. See below.

Code: Select all

movem.l   #picture+2,d0-d7   ;put picture palette in d0-d7


The original code was an invalid addressing mode, because of the '#' hash, which actually means 'move *immediate* data' - constant data encoded into the instruction itself. move does support that, but movem does not.

Regardless, it is not what you intended to do - i.e. to read data from some indirect location in ram, and not some constant.

Code: Select all

movem.l   picture+2,d0-d7   ;put picture palette in d0-d7


...whereas without the hash, the 'movem.l picture+2' interprets as a source *address* for the data instead, which is valid. This is the same as putting the address in a register first and dereferencing it via 'movem.l (a0)'

The hash was however required here:

Code: Select all

move.l #picture+2,a0


...because that is immediate data - you're loading the address itself into a register, and not some value from elsewhere ram.

rpineau
Atari Super Hero
Atari Super Hero
Posts: 501
Joined: Wed Jun 29, 2011 6:39 am
Location: California / USA
Contact:

Re: Assembly Programming - Perihelion tutorial 6 - Addressing Mode Not Allowed

Postby rpineau » Sat Mar 07, 2015 2:41 am

@dml : good catch, I forgot that you can use this direct addressing mode in a movem.
Regards, Rodolphe
Falcon + AB040 + Eclipse PCI + ATI Rage VGA card + NE2000 Ethernec + HxC Floppy Emulator
MegaSTE 4MB + CosmosEx / 1040 STF for hardware dev
http://www.rti-zone.org/atari.php

StanZ
Atariator
Atariator
Posts: 28
Joined: Tue Dec 21, 2004 1:33 am

Re: Assembly Programming - Perihelion tutorial 6 - Addressing Mode Not Allowed

Postby StanZ » Sat Mar 18, 2017 5:27 pm

Code: Select all

initialize:   
   clr.l   -(a7)      ;clear stack
   move.w   #32,-(a7)   ;prepare for super mode
   trap   #1      ;call gemdos
   addq.l   #6,a7      ;clear up stack
   move.l   d0,old_stack   ;backup old stack pointer
   
   rts


Hi all, I'm a newbie trying to learn a bit of Atari ST coding. I've been using this Perihelion's routine (INITLIB.S) It works well but I'm a bit curious about ";prepare for super mode". Isn't it a XBIOS function there? Then 32 ($20) is Dosound, but I call this routine to set the supervisor mode, 38 ($26) Supexec.

Edit: aarg ;call gemdos ... 32 $20 Super


Social Media

     

Return to “Coding”

Who is online

Users browsing this forum: No registered users and 1 guest