Welcome, Guest. Please login or register.

Author Topic: Looking for assembly syntax slightly different from mototrolla ?  (Read 5419 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show only replies by Einstein
Hello there ! After some years off coding assembly and MC68000, I'm in the mood again. I have an alternative syntax question.

Is there a slightly different syntax than motorola that uses no hash for direct values, and uses parentheses around address/label for indirect values ?

--- motorola syntax ---

direct:
Code: [Select]
move.l #4,var
indirect:
Code: [Select]
move.l 4,var
--- alternative syntax ---

direct:
Code: [Select]
move.l 4,(var)
indirect:
Code: [Select]
move.l (4),(var)
---------------------------

Years ago I played with NASM and FASM in x86 assembly land. Those assemblers use below syntaxes corresponding to above instructions:

direct:
Code: [Select]
mov [var],4
indirect:
Code: [Select]
mov [var],[4]
(Or so I recall)
« Last Edit: October 15, 2017, 09:54:55 PM by Einstein »
I have spoken !
 

Offline BLTCON0

  • Jr. Member
  • **
  • Join Date: Oct 2013
  • Posts: 91
    • Show only replies by BLTCON0
Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #1 on: October 16, 2017, 09:26:53 AM »
There's the old (a->b) and the new (b<-a) syntax as far as I know.
E.g. Devpac2 understands only the old, while Devpac3 understands both old and new, if I recall correctly.
I don't think there's a 3rd option and while nothing would prevent someone from coding a semantically equivalent assembler using your proposed alternative, I doubt anyone would actually bother reinventing the wheel when two official standards already exist.
 

Offline EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show only replies by Einstein
Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #2 on: October 16, 2017, 10:30:49 AM »
@BLTCON0

Thank you for the reply. Saves me time googling around :)
Yes, I am not interested in , order (b<-a) as I prefer to keep the order the same as the machine code (memory-to-memory operations comes to mind).
But having a unified syntax for addresses and aN registers would have been very nice, and overall (considering other instructions) would be more consistent and intuitive.

Yes I know, I could go and implement a syntax module for vasm 68k, but certainly that shall wait as I'm more into playing now :)

Thanks again !

*edit*

Look at that "moto-trolla" title, lmao !
« Last Edit: October 16, 2017, 05:45:20 PM by Einstein »
I have spoken !
 

Offline Thorham

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1149
    • Show only replies by Thorham
Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #3 on: October 16, 2017, 10:37:28 PM »
You want the syntax to be more like Intel? Blasphemy!
 

Offline EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show only replies by Einstein
Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #4 on: October 16, 2017, 11:12:23 PM »
Quote from: Thorham;831833
You want the syntax to be more like Intel? Blasphemy!


Hi!

Not at all. I only included the NASM/FASM syntax to show that this syntax exists already (as opposed to me inventing it). Although I don't remember what official Intel syntax looks like, I did evaluate it along with NASM/FASM syntax and concluded the latter to be much cleaner and logical so I "settled" on that latter syntax for x86.

I also took a look at z80 assembly, and it seems it also uses parentheses for the purpose. The only advantage IMO in motorola syntax is less key presses. I remember I have "occasionally" made mistakes (read bugs) with the motorola syntax ever since I learned it, which is why I was curious about the existence of the alt syntax.
I have spoken !
 

Offline psxphill

Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #5 on: October 17, 2017, 09:39:34 AM »
Quote from: Einstein;831834
I remember I have "occasionally" made mistakes (read bugs) with the motorola syntax ever since I learned it, which is why I was curious about the existence of the alt syntax.


If the idea is to remove mistakes then surely the preferred style would be

immediate: move.w #4,d0
absolute addressing: move.w (4), d0

with an error if you do:
move.w 4,d0

I don't know where the brackets round the number for absolute addressing syntax comes from though.

https://en.wikibooks.org/wiki/68000_Assembly#Absolute_far_addressing
 

Offline BLTCON0

  • Jr. Member
  • **
  • Join Date: Oct 2013
  • Posts: 91
    • Show only replies by BLTCON0
Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #6 on: October 17, 2017, 10:06:22 AM »
Quote from: psxphill;831845

I don't know where the brackets round the number for absolute addressing syntax comes from though.


Probably to maintain an analogy with the address register (i.e. pointer) dereferencing syntax:
move.l (a6),d0 (copy contents of address pointed to by a6)
vs
move.l a6,d0 (copy a6 itself)

since the ambiguity move.l 4,d0 would create has already been resolved by the # prefix for immediate transfer.
With no ambiguity left between move.l 4,d0 and move.l (4),d0, it ends up being a matter of style/personal preference.

I've only seen (and used) the move.l 4,d0 syntax though, both in others' code and in disassemblers' output.
 

Offline psxphill

Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #7 on: October 17, 2017, 12:04:47 PM »
Quote from: BLTCON0;831846
Probably to maintain an analogy with the address register (i.e. pointer) dereferencing syntax:

I understand why the syntax makes sense. I just can't find any official documentation or assembler that uses it.

I thought it might have been MIT standard, but it doesn't appear to be.
 

Offline BLTCON0

  • Jr. Member
  • **
  • Join Date: Oct 2013
  • Posts: 91
    • Show only replies by BLTCON0
Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #8 on: October 17, 2017, 01:59:59 PM »
@psxphill
It's used in Motorolla's Programmer's Reference Manual, e.g. in the MOVE instruction the corresponding addressing modes are indicated by (xxx).W and (xxx).L
 

Offline EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show only replies by Einstein
Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #9 on: October 17, 2017, 03:11:43 PM »
Quote from: psxphill;831845
If the idea is to remove mistakes then surely the preferred style would be

immediate: move.w #4,d0
absolute addressing: move.w (4), d0

with an error if you do:
move.w 4,d0

I don't know where the brackets round the number for absolute addressing syntax comes from though.

https://en.wikibooks.org/wiki/68000_Assembly#Absolute_far_addressing


The '#' would then be enforced superfluous syntax. I don't know which assemblers support the parentheses-based syntax, but in such case the parentheses are then superfluous. The point is to force a certain syntax, and in my prefered case that would be what I wrote earlier. Honestly I rather stick to contemporary motorola syntax than '#x' and '(x)', for direct and indirect value respectively.
I have spoken !
 

Offline psxphill

Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #10 on: October 17, 2017, 05:26:37 PM »
Quote from: Einstein;831854
The '#' would then be enforced superfluous syntax.

Yes, that is entirely the point. If you are explicit about whether it's # or () then it will be more obvious to you if you make a mistake and use the wrong one, using naked numbers opens up the possibility to misread it. Which I thought was the problem you were trying to solve in the first place.
 

guest11527

  • Guest
Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #11 on: October 17, 2017, 07:06:51 PM »
Quote from: psxphill;831855
Yes, that is entirely the point. If you are explicit about whether it's # or () then it will be more obvious to you if you make a mistake and use the wrong one, using naked numbers opens up the possibility to misread it. Which I thought was the problem you were trying to solve in the first place.

Unfortunately, it is still pretty ambigious. "move.l (4),a6" is still a valid 68020 addressing mode: Indirect with suppressed base and index register.

gcc had a very "special" syntax for 68k, with indirection indicated with @, if I recall correctly. Motorola itself used another strange syntax in their FPSP source code, especially with "cmp" working "the wrong way around", which required me - for porting - first write an automatic conversion to the official service.
 

Offline EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show only replies by Einstein
Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #12 on: October 17, 2017, 10:01:59 PM »
Quote from: psxphill;831855
Yes, that is entirely the point. If you are explicit about whether it's # or () then it will be more obvious to you if you make a mistake and use the wrong one, using naked numbers opens up the possibility to misread it. Which I thought was the problem you were trying to solve in the first place.

I don't like syntactic polymorphism. Naked numbers aren't the issue for me. The issue for me is this:

Consider 'move' and 'bsr'. Although 68000 doesn't support a counterpart to x86's (NASM/FASM syntax) 'call [funcptr]' (C counterpart: '(*funcptr)();') a later 680x0 cpu could do just that. And if/when so, what would the syntax then be ? It's natural and intuitive to then look at 'move.l funcptr,a0' and suggest 'bsr funcptr', but as you already know that syntax already exists but only means "jumping" to the address represented by that label, and not to the address that is located there. So analogous to 'move', we would find it more logical to change current syntax for 'bsr
' to 'bsr #
' and instead use the syntax 'bsr
' as the counterpart to (NASM/FASM) x86's 'call [
]'. That's what I meant by consistency in an earlier comment of mine. The alternative syntax with parentheses is just a preference thing, and of second priority.

As I'm just starting assembly coding again, there might be things that I've overlooked that may be valid reasons(s) for the syntax "contradiction" between 'move' and 'jmp/bra/jsr/bsr' instructions. I'd like to know.
« Last Edit: October 17, 2017, 10:04:53 PM by Einstein »
I have spoken !
 

guest11527

  • Guest
Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #13 on: October 18, 2017, 07:48:28 AM »
Quote from: Einstein;831862
Consider 'move' and 'bsr'. Although 68000 doesn't support a counterpart to x86's (NASM/FASM syntax) 'call [funcptr]' (C counterpart: '(*funcptr)();') a later 680x0 cpu could do just that.

Huh, why not? Of course it does, in the same sense the 68020 onwards supports a move with indirection without an address register. The same address mode can - of course - be used for JMP or JSR. The 68K series is really very orthogonal. Since there is a move.l (a0),d0, there is of course also a jsr (a0), and since there is a move.l (abs.l),d0 (for the 68020 on) there is also an jsr (abs.l). No problem - this is extended indirect with index and supressed base register.
 

Offline EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show only replies by Einstein
Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #14 on: October 18, 2017, 10:27:26 AM »
Quote from: Thomas Richter;831892
Huh, why not? Of course it does, in the same sense the 68020 onwards supports a move with indirection without an address register. The same address mode can - of course - be used for JMP or JSR. The 68K series is really very orthogonal. Since there is a move.l (a0),d0, there is of course also a jsr (a0), and since there is a move.l (abs.l),d0 (for the 68020 on) there is also an jsr (abs.l). No problem - this is extended indirect with index and supressed base register.


Hi!

I mean plain 68000 (not 68020, I have never examined/played with anything 680x0 above 68000). I'm not talking about indirect calls/jumps through aN, but through memory locations. I don't remember below instruction to be possible/supported on 68000, is it ?

Code: [Select]
bsr (funcptr)

'funcptr' being label for some (relative) address.
I have spoken !