Welcome, Guest. Please login or register.

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

Description:

0 Members and 1 Guest are viewing this topic.

Offline EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show all replies
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 EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show all replies
Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #1 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 EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show all replies
Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #2 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 EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show all replies
Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #3 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 EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show all replies
Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #4 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 !
 

Offline EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show all replies
Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #5 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 !
 

Offline EinsteinTopic starter

  • Sr. Member
  • ****
  • Join Date: Dec 2004
  • Posts: 402
    • Show all replies
Re: Looking for assembly syntax slightly different from mototrolla ?
« Reply #6 on: October 18, 2017, 12:15:01 PM »
@Thomas Richter

Thanks for the clarification.
I have spoken !