English Amiga Board


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

 
 
Thread Tools
Old 17 January 2024, 18:41   #1
fuzzylogic
Registered User
 
Join Date: Jan 2010
Location: Germany
Posts: 67
VASM wrong opcode generated?

Hello guys,

I am playing around with VASM and came across something odd(?)

If I assemble

asl.b #1,d1

it will produce the opcode $D201 which is in my opinion add.b d1,d1 instead. If I take a look into the M68k manual I would expect opcode $E301 for asl.b #1,d1

Am I doing something wrong or is this a bug? I am using vasm 1.9f.
fuzzylogic is offline  
Old 17 January 2024, 18:48   #2
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,479
Some optimizations are active by default (see manual).

To disable all: -no-opt on command line or opt o- in source.
You can disable and enable the various optimizations individually with other commands (always see manual).
ross is offline  
Old 17 January 2024, 19:00   #3
fuzzylogic
Registered User
 
Join Date: Jan 2010
Location: Germany
Posts: 67
WOW that was fast

Thanks ross , this fixed the issue.
fuzzylogic is offline  
Old 17 January 2024, 19:47   #4
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,303
vasm does that for a reason: for a 1 or 2 bit shift, it's faster to add the register with itself.

That said, I'm not sure that add.b d1,d1 is strictly equivalent to asl.b #1,d1 as there's the arithmetic part that isn't there in lsl.
jotd is offline  
Old 17 January 2024, 20:15   #5
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,479
Quote:
Originally Posted by jotd View Post
vasm does that for a reason: for a 1 or 2 bit shift, it's faster to add the register with itself.

That said, I'm not sure that add.b d1,d1 is strictly equivalent to asl.b #1,d1 as there's the arithmetic part that isn't there in lsl.
Is the arithmetic part (V flag) of lsl that is not the same as add.
Therefore, in this case, the optimization is legitimate

But you are right about being careful with this optimization.
ross is offline  
Old 17 January 2024, 20:40   #6
roondar
Registered User
 
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,423
On a kinda-but-not-fully related question:
Can you disable these optimisations using opt -o for only part of a single file?
If so, how do you enable the default stuff again, opt +o?
roondar is offline  
Old 17 January 2024, 20:52   #7
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,479
Sure!
You can insert opt in the source only for the part of the code on which you want to enable or disable that optimization.
(but the code may become less portable..)
ross is offline  
Old 17 January 2024, 21:52   #8
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,510
Quote:
Originally Posted by ross View Post
But you are right about being careful with this optimization.
By default vasm should only enable optimizations which are absolutely safe and without any side effect. Otherwise it is a bug (please tell me)!
phx is offline  
Old 17 January 2024, 22:11   #9
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 2,006
Yes, default asembler optimisations its always bug for me. I remember ROM original module code, perhaps from wb.find. When jmp was replaced with bra.b (if I remember right). And it was bug.
Anyway for this case i dont see reason for use asl command, for me is totally useles. Lsl is much logical for me.
Don_Adan is offline  
Old 17 January 2024, 22:14   #10
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,479
Quote:
Originally Posted by phx View Post
By default vasm should only enable optimizations which are absolutely safe and without any side effect. Otherwise it is a bug (please tell me)!
Yeah, I was referring to an explicit lsl optimization
If vasm optimize by default asl there is a good reason
ross 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
Question about XREF vs XDEF (vasm 1.8 vs vasm 1.9) roondar Coders. Asm / Hardware 8 01 May 2023 20:59
VASM wrong assembling? deadwood Coders. Asm / Hardware 32 01 January 2015 23:25
WinUAE message - Opcode 0CD9... Bigby support.WinUAE 2 01 February 2014 19:42
New opcode for 68000 family clenched request.UAE Wishlist 15 14 April 2009 15:02
Hidden Amiga 68000 opcode? pmc Coders. General 20 14 May 2007 09:10

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 13:46.

Top

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