English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 09 June 2023, 00:52   #61
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,604
Quote:
Originally Posted by kamelito View Post
@a/b
Set AsmOne to 68000
The code : move.w $bd.w, d0 should not be accepted an odd address error should be given instead.
The 68000 CPU supports this by opcode $303800BD. All 68000-only, and all 680x0 Assemblers must support this. This is the real reason, not that it's an odd address, or that you're reading instead of writing, or that you're moving directly instead of lea $bd.w,a0;move.w (a0),d0. If it warns you, it might (I say might) help you. If it doesn't finish Assembling a program with a valid opcode, I say it's not the Assembler you want.
Photon is offline  
Old 14 June 2023, 22:34   #62
Bruce Abbott
Registered User
 
Bruce Abbott's Avatar
 
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,584
Quote:
Originally Posted by Photon View Post
If it doesn't finish Assembling a program with a valid opcode, I say it's not the Assembler you want.
Branch to an odd address is valid 68000 code too, but you wouldn't want the assembler to accept it.

In kamelito's example the coder made the mistake of forgetting to put a # in front of the number used in a dfb loop count. Their assembler (apparently) silently accepted this, resulting in a nasty bug in the executable.

The chances of wanting to load a word from an odd address on the 68000 is very small. The only valid reason for doing it is to induce an exception. IMO it is better for the assembler to treat it as an error.

On 68020+ it should warn, and have an option to error out (preferably set by default).
Bruce Abbott is offline  
Old 15 June 2023, 16:36   #63
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
I also spent some thoughts on this topic while developing vasm, and I'm with Photon. There should be no reason for the assembler to artificially restrict the developer, even if the code is probably stupid in most cases. As long as it is valid, you should be able to generate it.

In vasm I even allowed unaligned data and instructions, if you really want that (instructions only with an option). You may have a reason for it. And such errors with odd addressing are easily spotted with an Alignment Exception. They don't cause hard to find bugs.

Quote:
Originally Posted by Bruce Abbott View Post
Branch to an odd address is valid 68000 code too, but you wouldn't want the assembler to accept it.
That's probably a different case. It is unclear if branch-opcodes with bit 0 set are really defined. I know that the 68080 uses these patterns for new instructions.
Although I would allow them too. You can't check everything, anyway. For example when branching to an external symbol. An odd addend (label+1) may be legal, when the (unknown) destination label is also at an odd address.

Quote:
The chances of wanting to load a word from an odd address on the 68000 is very small.
Even if the chance is one in a million, you will curse the assembler when you really need it. An optional warning is all I would consider.

Quote:
Originally Posted by a/b View Post
It will only check instruction and directive alignment (DC, DS, ...), and if 68020+ odd data is not enabled (asm prefs) it will error out.
I would turn that into a warning. There may be reasons for data at an odd address. Maybe you want to copy the data somewhere else, before using it, or it is a data structure in an external format you want to replicate. For example DWARF uses words at odd addresses.
phx is offline  
Old 15 June 2023, 18:01   #64
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
I agree with Photon and phx, any valid 680x0 opcodes have to be accepted by the assembler. If the assembler issues an error when it detects "stupid" opcodes, I'd immediately switch to another assembler. It's not the job of the assembler to decide if code is useful or not.
StingRay is offline  
Old 18 June 2023, 06:53   #65
Bruce Abbott
Registered User
 
Bruce Abbott's Avatar
 
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,584
Quote:
Originally Posted by phx View Post
Even if the chance is one in a million, you will curse the assembler when you really need it. An optional warning is all I would consider.
I'm already cursing my assemblers for not creating the opcodes I ask for, not allowing relocation etc. I put up with it because these particular assemblers are much faster.

I also curse compilers that generate code my assembler can't reproduce. What does vasm do with a 'negative' immediate byte value - does it extend it to a word or make the upper byte 0?
Bruce Abbott is offline  
Old 18 June 2023, 16:55   #66
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
Quote:
Originally Posted by Bruce Abbott View Post
What does vasm do with a 'negative' immediate byte value - does it extend it to a word or make the upper byte 0?
As far as I understand bits 8-15 of an 8-bit immediate operand word are undefined and reserved. Usually you would set such bits to 0, and this is what vasm does.

Which means
move.b #-1,d0
and
move.b #$ff,d0
will both be encoded as
$103c $00ff
.

I know there were a few assemblers which extended the sign into the undefined part of the word, and I added a compatibility flag in the IRA reassembler for those.

But this thread is about AsmPro and I hope it does the same.
phx is offline  
Old 19 June 2023, 21:09   #67
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,604
Even if a sizecoder would like to use the high byte e.g. for 'storage', and would like only a warning if the immediate value doesn't fit in a byte, it wouldn't affect execution.

To code in Assembler is to care about every CPU instruction - if you structure you're code well and are not under pressure for speed or size - not every single one of them.

To use a higher-level language is to trust the compiler dev's knowledge of Assembler. (I hear some compilers are written in their own language as some kind of misguided test, but that obviously means the compiler generated unoptimized and generic code.)

My view is that since Assembler is what we use instead of direct opcodes, in theory all opcodes supported by the CPU (definition: does not trigger Illegal Instruction by the CPU) should be supported by the Assembler. Once that is covered, niceties can be added, but it's important to still avoid things we've seen like sub An->suba, dbf->dbra, "moveq.b" etc.

If it makes sense, I want to know that the price I pay and the reward for writing every CPU instruction is that what I write is translated exactly. Otherwise, there can be some confusion, and then you read the Disassembler output and trust moves to the Disassembler instead.

Now we're at a detailed level, and most coders will not be caught out or have the need for such precision. But I think that's still not a reason to not have it, it's a great bragging right! I'm sure all 68k Assemblers have flaws, including whatever GNU uses for 68k.

And this is understood and accepted. In those rare cases I can just declare the opcode.

If you want to make AsmPro more powerful, I have a few directive suggestions that I always wanted to see.
Photon is offline  
Old 04 August 2023, 12:21   #68
oRBIT
Zone Friend
 
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 48
Posts: 339
Any new version coming up soon?
oRBIT is offline  
Old 05 August 2023, 11:37   #69
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Not on the horizon right now. Still haven't decided to fully dig into disassembler because I'd have to allocate a good chunk of time for that and there are too many things on the menu as is. v1.20 will primarily be just more bugfixes, you aren't missing much :P, but if you encounter any problems/bugs let me know and I'll release a new v1.19 build in the meanwhile.
a/b is offline  
Old 08 August 2023, 19:21   #70
oRBIT
Zone Friend
 
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 48
Posts: 339
Quote:
Originally Posted by a/b View Post
Not on the horizon right now. Still haven't decided to fully dig into disassembler because I'd have to allocate a good chunk of time for that and there are too many things on the menu as is. v1.20 will primarily be just more bugfixes, you aren't missing much :P, but if you encounter any problems/bugs let me know and I'll release a new v1.19 build in the meanwhile.
Can't get a macro to work that looks like this (illegal operand):
MyMacro:
MACRO
move.b d2,(a0,\1.l)
ENDM
It assembles in Asm-One... Is it my syntax?
oRBIT is offline  
Old 08 August 2023, 19:32   #71
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,107
Quote:
Originally Posted by oRBIT View Post
Can't get a macro to work that looks like this (illegal operand):
MyMacro:
MACRO
move.b d2,(a0,\1.l)
ENDM
It assembles in Asm-One... Is it my syntax?
Works for me if you don't have a newline between MyMacro and MACRO. I get (probably expected) "illegal operator" otherwise. How are you exactly defining/invoking it? Use sqaure-open-bracket([) CODE square-close-bracket (]) ... sqaure-open-bracket([) back-slash (/) CODE square-close-bracket (]) to inline some code here
paraj is offline  
Old 08 August 2023, 19:38   #72
oRBIT
Zone Friend
 
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 48
Posts: 339
Quote:
Originally Posted by paraj View Post
Works for me if you don't have a newline between MyMacro and MACRO. I get (probably expected) "illegal operator" otherwise. How are you exactly defining/invoking it? Use sqaure-open-bracket([) CODE square-close-bracket (]) ... sqaure-open-bracket([) back-slash (/) CODE square-close-bracket (]) to inline some code here
I attach a screenshot how I type it. Doesn't work that way anyway, running 1.19c..
Attached Thumbnails
Click image for larger version

Name:	asmpro1.png
Views:	69
Size:	2.2 KB
ID:	79911  
oRBIT is offline  
Old 08 August 2023, 19:55   #73
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,107
Quote:
Originally Posted by oRBIT View Post
I attach a screenshot how I type it. Doesn't work that way anyway, running 1.19c..
Ahh, I thought \1 would be a register here. What addressing mode are you expecting to be generated?
paraj is offline  
Old 08 August 2023, 21:18   #74
oRBIT
Zone Friend
 
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 48
Posts: 339
Quote:
Originally Posted by paraj View Post
Ahh, I thought \1 would be a register here. What addressing mode are you expecting to be generated?
Not entirely sure of what you mean but Asm-One assembles this as:
move.b d2,(a0,$00000010.L)
oRBIT is offline  
Old 09 August 2023, 12:29   #75
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
I guess you want this: ($10,a0), or $10(a0) if using the old syntax? If so, the correct way is (\1,a0) or \1(a0). This implies (d16,ax) address reg 16-bit displacement indirect mode.
.L plus placing the offset after Ax implies 020+ full extension addressing. It's basically (d8,ax,ry*scale) but with a 32-bit displacement and supressed index ry.
It was implemented that way in order to differentiate between brief and full modes so you could have control what opcode will be generated because there is some overlap. To put it simple...
There might be bugs and complications/confusion with full extension addressing, because of all of that.
a/b is offline  
Old 09 August 2023, 21:30   #76
oRBIT
Zone Friend
 
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 48
Posts: 339
Quote:
Originally Posted by a/b View Post
I guess you want this: ($10,a0), or $10(a0) if using the old syntax? If so, the correct way is (\1,a0) or \1(a0). This implies (d16,ax) address reg 16-bit displacement indirect mode.
.L plus placing the offset after Ax implies 020+ full extension addressing. It's basically (d8,ax,ry*scale) but with a 32-bit displacement and supressed index ry.
It was implemented that way in order to differentiate between brief and full modes so you could have control what opcode will be generated because there is some overlap. To put it simple...
There might be bugs and complications/confusion with full extension addressing, because of all of that.
Interesting, it's (\1.l,a0) obviously I'm after, but after a bit of testing, that syntax seems to be limited to 16-bit offsets only (both AsmPro/AsmOne), as you obviously wrote above. The
syntax I mentioned earlier that doesn't work in AsmPro, supports 32-bit offsets in AsmOne.
Attached Thumbnails
Click image for larger version

Name:	asmone1.png
Views:	56
Size:	2.9 KB
ID:	79927  

Last edited by oRBIT; 09 August 2023 at 21:45.
oRBIT is offline  
Old 13 October 2023, 14:28   #77
BraxtonDK
Registered User
 
Join Date: Jan 2023
Location: Denmark
Posts: 9
I found this feature in AsmPro .. tested with v1.18 and v1.19c

$B03C0004 CMP.B #4,D0
$0C000004 CMPI.B #4,D0

When AsmPro assembles the Cmp.b, it get turned into Cmpi.b

now CMP.B #4,D0 is a leagal opcode.
so the quesation is should it be turned into Cmpi ?

When I assemble with vasm v1.9e .. it do not get changed.

ps: a/b thanks for updating AsmPro
BraxtonDK is offline  
Old 13 October 2023, 15:45   #78
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Probably shouldn't but it gets away with it because it doesn't matter in 99.99% of situations. It does that not only with cmpi but many other "dual" opcodes, it's the way the parser is written. In this particular case if you write cmp it will ultimately end up using shared code for add/sub/cmp, so all the immediates get an "I".
a/b is offline  
Old 13 October 2023, 16:25   #79
BraxtonDK
Registered User
 
Join Date: Jan 2023
Location: Denmark
Posts: 9
Ahh right .. I just wanted to mention it, in case it was a problem.
BraxtonDK is offline  
Old 13 October 2023, 19:34   #80
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,604
Quote:
Originally Posted by BraxtonDK View Post
I found this feature in AsmPro .. tested with v1.18 and v1.19c

$B03C0004 CMP.B #4,D0
$0C000004 CMPI.B #4,D0

When AsmPro assembles the Cmp.b, it get turned into Cmpi.b

now CMP.B #4,D0 is a leagal opcode.
so the quesation is should it be turned into Cmpi ?

When I assemble with vasm v1.9e .. it do not get changed.

ps: a/b thanks for updating AsmPro
68000 PRM says,

Quote:
CMPA is used when the destination is an address register. CMPI
is used when the source is immediate data. CMPM is used for
memory-to-memory compares. Most assemblers automatically
make the distinction.
The distinction here is that the first allows <ea>, and Imm is an ea. The second is a superfluous hard-coded immediate instruction that can have no other ea. Superfluous as in, there are no result or cycle differences (on 68000). It's probably this way because some other instructions that have no *I syntax share decoding circuitry with a list of ALU instructions of which CMP is a necessary one. Duplicate instructions simplifies the decoding circuit, and should (hopefully) be passed to the same execution circuit/microprogram.

Probably there are many instructions that work this way. I.e. cmp.b #4,a0 (or sub.b #4,a0) should have the same effect as the word size instruction, if you write an assembler that encodes the bit for .b.

But there might be some instruction word bits that are not ignored on the earlier CPUs, so that if the assembler would encode blindly and the CPU executes blindly could give some interesting side effects.
Photon is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASMPro 1.18 on A500/A600? Antiriad_UK Coders. Asm / Hardware 11 28 December 2022 10:49
AsmPro Macro REAKTOR BEAR Coders. Asm / Hardware 2 04 October 2022 13:19
AsmPro and INCLUDE sources OCrowley Coders. General 2 06 July 2014 11:42
AsmPro copse Coders. Asm / Hardware 4 25 April 2012 11:41
AsmPro CmdrVimes Coders. General 5 01 September 2010 12:40

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:03.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.19523 seconds with 14 queries