MOVM.L syntax

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
ob1
Very interested
Posts: 408
Joined: Wed Dec 06, 2006 9:01 am
Location: Aix-en-Provence, France

MOVM.L syntax

Post by ob1 » Fri Jun 05, 2015 12:28 pm

Hello.

I've stumbled upon the MOVM.L syntax.
It's a form of MOVEM that is used by GAS in order to push/pop registers on the stack.

I had

Code: Select all

	movm.l #0x3020,-(a7)	; Backup registers
	...
	movm.l (a7)+,#0x40c		; Restore registers
I had to come back to the M68000PRM.pdf in order to get it. The manual states that there is a syntax to backup, and a syntax to restore :

pre-decrement

Code: Select all

15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
D0 D1 D2 D3 D4 D5 D6 D7 A0 A1 A2 A3 A4 A5 A6 A7

       1  1                    1
So, registers D2, D3 and A2 will be pushed (saved on the stack).

post-increment

Code: Select all

15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
A7 A6 A5 A4 A3 A2 A1 A0 D7 D6 D5 D4 D3 D2 D1 D0

                1                    1  1
So, registers D2, D3 and A2 will be popped (retrieved from the stack), that makes sense.

I thought it would help ^^

Stef
Very interested
Posts: 3009
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Fri Jun 05, 2015 3:41 pm

It's quite painful to use this syntax imo, it's even worst because postinc/predec mode use different register order !
You will better to use this one instead (which is supported by GAS) :

Code: Select all

movm.l d1-d4/d6-d7/a1-a3,-(a7)

ob1
Very interested
Posts: 408
Joined: Wed Dec 06, 2006 9:01 am
Location: Aix-en-Provence, France

Post by ob1 » Sun Jun 07, 2015 8:53 am

Thanx Stef, I didn't know.
I was messing around with these bloody "%" syntax, eg move %d1,(%a2)
:D

notaz
Very interested
Posts: 192
Joined: Mon Feb 04, 2008 11:58 pm
Location: Lithuania

Post by notaz » Wed Jun 10, 2015 4:42 pm

Why not just use as --register-prefix-optional ?

ob1
Very interested
Posts: 408
Joined: Wed Dec 06, 2006 9:01 am
Location: Aix-en-Provence, France

Post by ob1 » Fri Jun 12, 2015 11:35 am

notaz wrote:Why not just use as --register-prefix-optional ?
Oh my !
I didn't know this option.
I gonna try it as soon as I get back to home !
Thank you notaz.

Truth be told, this "%" is why I picked @plee (thank you again SO much !!!) asm.exe firsthand instead !

Post Reply