English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 14 September 2023, 14:52   #1501
bebbo
botcher
 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 674
I just added the (requested) feature to optimize the shift instructions:

Superfluous signed/unsigned extensions are suppressed and the smallest possible shift is used.

Have a look here: https://franke.ms/cex/z/3q19bh.
bebbo is offline  
Old 14 September 2023, 21:31   #1502
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 52
Posts: 712
Something is not pushed to repository?
with
-O2 -fomit-frame-pointer -mregparm -m68020
I get

Code:
_lsl_ubb:
        and.l #255,d0
        lsl.l d1,d0
        rts
_lsl_sbb:
        lsl.b d1,d0
        rts
_lsr_ubb:
        and.l #255,d0
        asr.l d1,d0
        rts
_lsr_sbb:
        asr.b d1,d0
        rts
_lsl_usb:
        and.l #65535,d0
        lsl.l d1,d0
        rts
_lsl_ssb:
        lsl.w d1,d0
        rts
_lsr_usb:
        and.l #65535,d0
        asr.l d1,d0
        rts
_lsr_ssb:
        asr.w d1,d0
        rts
for 68000, 68010,68030,68040 I get the "correct" shorter assembly.
If I switch to -O3 I get the correct code for all cpus.
So only for 68020 with -O2 there seems to be a glitch.

(I've cleaned and rm'd the target directory. All compiled from scratch on pi400)
alkis is offline  
Old 15 September 2023, 10:44   #1503
bebbo
botcher
 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 674
Quote:
Originally Posted by alkis View Post
Something is not pushed to repository?
with
-O2 -fomit-frame-pointer -mregparm -m68020
I get

Code:
_lsl_ubb:
        and.l #255,d0
        lsl.l d1,d0
         rts
...
for 68000, 68010,68030,68040 I get the "correct" shorter assembly.
If I switch to -O3 I get the correct code for all cpus.
So only for 68020 with -O2 there seems to be a glitch.

(I've cleaned and rm'd the target directory. All compiled from scratch on pi400)

did the same on an odroid and it's ok.
gcc version 6.5.0b 230914152536


the result on the pi400 is still better than before :-)
bebbo is offline  
Old 15 September 2023, 11:01   #1504
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 51
Posts: 7,589
Bebbo something should be done for code short branches to the next instruction

Code:
   bne.b 0f
0:
this generates incorrect assembly and crashes because short branch cannot be of offset 0. jne probably fixes that, but a compile-time error would be nice.
jotd is offline  
Old 15 September 2023, 11:48   #1505
bebbo
botcher
 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 674
Quote:
Originally Posted by jotd View Post
Bebbo something should be done for code short branches to the next instruction

Code:
   bne.b 0f
0:
this generates incorrect assembly and crashes because short branch cannot be of offset 0. jne probably fixes that, but a compile-time error would be nice.

example code please

Code:
Disassembly of section .text:

00000000  .text:
   0:   6600 0000       bne.w 0x2

Last edited by bebbo; 15 September 2023 at 15:53.
bebbo is offline  
Old 17 September 2023, 04:20   #1506
NorthWay
Registered User
 
Join Date: May 2013
Location: Grimstad / Norway
Posts: 818
I just stumbled into this shift discussion here, and possibly dancing into a minefield (especially at this hour), wouldn't you rather do
Code:
moveq #$3f,d1
and.b 11(sp),d1
Or did I possibly miss out on something bigtime?
NorthWay is offline  
Old 17 September 2023, 08:41   #1507
bebbo
botcher
 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 674
Quote:
Originally Posted by NorthWay View Post
I just stumbled into this shift discussion here, and possibly dancing into a minefield (especially at this hour), wouldn't you rather do
Code:
moveq #$3f,d1
and.b 11(sp),d1
Or did I possibly miss out on something bigtime?

That AND is implicitly executed by the CPU, no need to add it into the asm code.
Quote:
2. Register—The shift count is the value in the data register specified in the instruction modulo 64.
Also the extension to long can be omitted for the shift count. Thus the original code
Code:
_lsr_sbb:
        move.b 7(sp),d1
        ext.w d1
        ext.l d1
        move.b 11(sp),d0
        ext.w d0
        ext.l d0
        asr.l d0,d1
        move.l d1,d0
        rts
is shorter now:
Code:
_lsr_sbb:
        move.b (7,sp),d0
        move.b (11,sp),d1
        asr.b d1,d0
        rts

Last edited by bebbo; 17 September 2023 at 08:46.
bebbo is offline  
Old 17 September 2023, 10:28   #1508
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 51
Posts: 7,589
Code:
main:
	bra.b	0f
0:
	rts
yields

Code:
	SECTION S_0,CODE

__stext:
	DC.W	$6000			;0
__etext:
	RTS				;2: 4e75
	END
K:\jff\AmigaHD\PROJETS\arcade_remakes\asm_test>c:\amiga-gcc\bin\m68k-amigaos-as --version
GNU assembler (GNU Binutils) 2.39.0.230129-131808
Copyright (C) 2022 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `m68k-amigaos'.

I also had a problem with add.b #1,a0 generating an illegal instruction without errors but now I can't reproduce it.

not using any optimization, and using -m68000 flag.
jotd is offline  
Old 17 September 2023, 20:31   #1509
bebbo
botcher
 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 674
Quote:
Originally Posted by jotd View Post
[CODE]
...
K:\jff\AmigaHD\PROJETS\arcade_remakes\asm_test>c:\amiga-gcc\bin\m68k-amigaos-as --version
GNU assembler (GNU Binutils) 2.39.0.230129-131808
Copyright (C) 2022 Free Software Foundation, Inc.

wow, msys2...


... fix is on the way - no idea when msys2 builds successfully again...
bebbo is offline  
Old 17 September 2023, 20:35   #1510
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 51
Posts: 7,589
Don't look at me, I positively hate MSYS2 and its fake linux compatibility

I always use python to control my toolchains, no damn fake shells that can call .bat files (called by .bat files).

Take your time. I'm aware of this issue and I'm using jcc a lot anyway.
jotd is offline  
Old 19 September 2023, 22:41   #1511
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 51
Posts: 7,589
Oh I found the other bug

Code:
main:
	subq.b	#1,a1 
	rts
assembles without errors, when sub to Ax register should be w or l not b

disassembly: junk

Code:
        SECTION S_0,CODE

__stext:
        DC.W    $5309                   ;0
__etext:
        RTS                             ;2: 4e75
        END
jotd is offline  
Old 21 September 2023, 08:57   #1512
bebbo
botcher
 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 674
Quote:
Originally Posted by jotd View Post
Oh I found the other bug

Code:
main:
    subq.b    #1,a1 
    rts
assembles without errors, when sub to Ax register should be w or l not b

that's a binutils issue... anyway, it's fixed now. And I managed to create a new MSYS2 version.
bebbo is offline  
Old 21 September 2023, 14:05   #1513
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 51
Posts: 7,589
you rock!

where can it be downloaded?
jotd is offline  
Old 21 September 2023, 14:22   #1514
bebbo
botcher
 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 674
Quote:
Originally Posted by jotd View Post
you rock!
where can it be downloaded?

there you go: https://franke.ms/download/setup-amiga-gcc.exe


... keep a backup^^
bebbo is offline  
Old 21 September 2023, 16:28   #1515
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 51
Posts: 7,589
going to burn this on a CD
jotd is offline  
Old 21 September 2023, 19:45   #1516
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 51
Posts: 7,589
bingo

bagman.68k:6737: Error: operands mismatch -- statement `subq.b #1,a2' ignored
jotd is offline  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
New GCC based dev toolchain for AmigaOS 3.x cla Coders. Releases 8 24 December 2017 10:18
Issue with photon/xxxx WinUAE Toolchain arpz Coders. Asm / Hardware 2 26 September 2015 22:33
New 68k gcc toolchain arti Coders. C/C++ 17 31 July 2015 03:59
Hannibal's WinUAE Demo Toolchain 5 Bobic Amiga scene 1 23 July 2015 21:04
From gcc to vbcc. Cowcat Coders. General 9 06 June 2014 14:45

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 08:22.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Page generated in 1.80471 seconds with 15 queries