English Amiga Board


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

 
 
Thread Tools
Old 14 September 2023, 14:52   #1501
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
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: 53
Posts: 719
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
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
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: 52
Posts: 8,197
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
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
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: 839
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
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
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: 52
Posts: 8,197
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
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
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: 52
Posts: 8,197
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: 52
Posts: 8,197
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
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
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: 52
Posts: 8,197
you rock!

where can it be downloaded?
jotd is offline  
Old 21 September 2023, 14:22   #1514
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
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: 52
Posts: 8,197
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: 52
Posts: 8,197
bingo

bagman.68k:6737: Error: operands mismatch -- statement `subq.b #1,a2' ignored
jotd is offline  
Old 24 October 2023, 11:04   #1517
girv
Mostly Harmless
 
girv's Avatar
 
Join Date: Aug 2004
Location: Northern Ireland
Posts: 1,114
I'm trying to build master on macOS Monterey. I'd managed to do this before without issue.

isl@0.18 is disabled in homebrew now, but I managed to get it installed by changing the system date temporarily.

Using the script posted in this thread previously: https://gist.github.com/rrs42/5e5b7b...b89d0f4dd3a2a8
with CC=gcc-12 CXX=g++-12 gmake all SHELL=$(brew --prefix)/bin/bash

It fails on building gcc with:
Code:
...
make use of stdint.h in include/isl/stdint.h (assuming C99 compatible system)
checking which gmp to use... system
checking gmp.h usability... no
checking gmp.h presence... no
checking for gmp.h... no
configure: error: gmp.h header not found
gmake[1]: *** [Makefile:4921: configure-isl] Error 1
make gcc...failed
bison and texinfo paths are set.
isl@0.18 and gmp are linked in brew.
gmp.h exists at /usr/local/Cellar/gmp/6.3.0/include/gmp.h

I'm guessing theres some issue with isl@0.18 and the installed version of gmp? Any ideas?

Also - is the gcc 13 branch gone now?
girv is offline  
Old 24 October 2023, 11:24   #1518
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,187
@girv
What version of gmake are you using? Gmake 4.4.1 is known to work. 3.x is known not to work.
Samurai_Crow is offline  
Old 24 October 2023, 11:26   #1519
girv
Mostly Harmless
 
girv's Avatar
 
Join Date: Aug 2004
Location: Northern Ireland
Posts: 1,114
$ gmake -v
GNU Make 4.4.1
Built for x86_64-apple-darwin21.6.0
...
girv is offline  
Old 24 October 2023, 11:32   #1520
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,187
Ok. What about Bash?
Samurai_Crow 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
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 03:53.

Top

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