English Amiga Board


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

 
 
Thread Tools
Old 04 November 2019, 14:20   #61
Spec-Chum
Registered User
 
Join Date: Dec 2016
Location: England
Posts: 87
Quote:
Originally Posted by deimos View Post
I've not touched anything yet, so my makefile looks like:

Code:
CCFLAGS = -g -MP -MMD -m68000 -O1 -nostdlib -Wall -Wno-pointer-sign -Wno-unused-function -Wno-volatile-register-var -Wno-discarded-qualifiers -fomit-frame-pointer -fno-tree-loop-distribution -flto -fwhole-program
I will try to change that and hopefully reproduce your problem.

EDIT:

Yes, problem confirmed with the default of:

Code:
CCFLAGS = -g -MP -MMD -m68000 -Ofast -nostdlib -Wall -Wno-pointer-sign -Wno-unused-function -Wno-volatile-register-var -Wno-discarded-qualifiers -fomit-frame-pointer -fno-tree-loop-distribution -flto -fwhole-program
The sprite doesn't move.
Thanks for confirming, can you just put volatile on the spr[1]++ cast at all?

I'm at work, so can't check
Spec-Chum is offline  
Old 04 November 2019, 14:21   #62
deimos
It's coming back!
 
deimos's Avatar
 
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
And it looks like your diagnosis is correct:

Code:
((/* important */ volatile /* here */ UBYTE *)spr)[1]++;
deimos is offline  
Old 04 November 2019, 14:31   #63
Spec-Chum
Registered User
 
Join Date: Dec 2016
Location: England
Posts: 87
Quote:
Originally Posted by deimos View Post
And it looks like your diagnosis is correct:

Code:
((/* important */ volatile /* here */ UBYTE *)spr)[1]++;
Awesome, thanks for checking
Spec-Chum is offline  
Old 04 November 2019, 19:40   #64
Spec-Chum
Registered User
 
Join Date: Dec 2016
Location: England
Posts: 87
Quote:
Originally Posted by deimos View Post
And it looks like your diagnosis is correct:

Code:
((/* important */ volatile /* here */ UBYTE *)spr)[1]++;
Home now, confirmed working again with -Ofast, hooray!

Thanks again for checking, much appreciated!
Spec-Chum is offline  
Old 19 November 2019, 04:01   #65
Tom_Goblins
Registered User
 
Join Date: Dec 2018
Location: Seattle
Posts: 13
Please can you confirm if it works for c++?, I saw a comment before but It wasn't clear enough.

I am trying to find my environment to code on c++ but now I am missing a nice debugger and this could be a great solution. I have been using Bebbo's gdbserver, printf!!, tons of them XD.

Thanks!

Last edited by Tom_Goblins; 19 November 2019 at 18:04.
Tom_Goblins is offline  
Old 02 December 2019, 15:25   #66
asymetrix
Registered User
 
Join Date: Jul 2009
Location: UK
Posts: 112
I got the addon to work but could not figure out how to include standard C/C++ headers - I could not follow an Amiga C book nor a standard windows C book.
Amiga really hinders my programming experience.
asymetrix is offline  
Old 02 December 2019, 21:05   #67
deimos
It's coming back!
 
deimos's Avatar
 
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
Quote:
Originally Posted by asymetrix View Post
I got the addon to work but could not figure out how to include standard C/C++ headers - I could not follow an Amiga C book nor a standard windows C book.
That's not what it's for. It's not a full C++ environment with all those libraries. It's a cut down pure Amiga environment for demo / game creators.
deimos is offline  
Old 09 December 2019, 21:54   #68
roondar
Registered User
 
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,409
I've recently found this rather useful extension. It works well, but I have run into a small problem.

Debugging only seems to work once.

That is, I can debug to my hearts content, until I stop debugging. When I use the Stop Debugging command from VS Code (prior to the program itself ending), this does stop the debugger. But after that I can't get it to start again. I have to restart Visual Studio Code for it to work once more.

Does anyone here know how to fix this?
roondar is offline  
Old 18 January 2020, 12:49   #69
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 189
For debugging I'm building the object files like

Code:
/opt/amiga/bin/m68k-amigaos-c++ -fno-rtti -fno-exceptions -noixemul -O0 -g -Wl,--amiga-debug-hunk -ldebug -c -o file.o file.cpp
Then I link them all using the silimar call

Code:
/opt/amiga/bin/m68k-amigaos-c++ -fno-rtti -fno-exceptions -noixemul -O0 -g -Wl,--amiga-debug-hunk -ldebug -o Application *.o
When debugging the stepping through the code works. But all variables are displayed with wrong / random values. These values don't change when stepping over a line where such a variable is set.

Is there something obviously wrong with my gcc/c++ options?
thyslo is offline  
Old 08 May 2020, 14:31   #70
Bartman
Registered User
 
Join Date: Feb 2019
Location: Munich, Germany
Posts: 63
Update: new version 0.8.1 released, supports C++ now
Download Github
Bartman is offline  
Old 08 May 2020, 14:48   #71
deimos
It's coming back!
 
deimos's Avatar
 
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
Quote:
Originally Posted by Bartman View Post
Update: new version 0.8.1 released, supports C++ now
Download Github
Nice. Thank you.
deimos is offline  
Old 08 May 2020, 14:58   #72
coldacid
WinUAE 4000/40, V4SA
 
coldacid's Avatar
 
Join Date: Apr 2020
Location: East of Oshawa
Posts: 538
@Bartman

Any chance you might get this added to the VS Marketplace?
coldacid is offline  
Old 11 May 2020, 15:52   #73
Bartman
Registered User
 
Join Date: Feb 2019
Location: Munich, Germany
Posts: 63
Updated. New version 0.9.0 features GCC 10.1, binutils 2.34, GDB 9.1
Download GitHub
should improve code performance a bit.
Bartman is offline  
Old 11 May 2020, 16:17   #74
deimos
It's coming back!
 
deimos's Avatar
 
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
Quote:
Originally Posted by Bartman View Post
Updated. New version 0.9.0 features GCC 10.1, binutils 2.34, GDB 9.1
Download GitHub
should improve code performance a bit.
But GCC 10.1 is only 4 days old!
deimos is offline  
Old 12 May 2020, 01:58   #75
coldacid
WinUAE 4000/40, V4SA
 
coldacid's Avatar
 
Join Date: Apr 2020
Location: East of Oshawa
Posts: 538
Quote:
Originally Posted by Bartman View Post
Updated. New version 0.9.0 features GCC 10.1, binutils 2.34, GDB 9.1

This thing's HUGE for A VSCode extension! Did you include all those in it?
coldacid is offline  
Old 12 May 2020, 17:33   #76
Bartman
Registered User
 
Join Date: Feb 2019
Location: Munich, Germany
Posts: 63
Quote:
Originally Posted by coldacid View Post
This thing's HUGE for A VSCode extension! Did you include all those in it?
Yes!
Bartman is offline  
Old 31 May 2020, 20:14   #77
Bartman
Registered User
 
Join Date: Feb 2019
Location: Munich, Germany
Posts: 63
Smile

Hey guys,
I just released version 1.0.0 on the Visual Studio Code Marketplace.

This is probably the biggest update ever.

excerpts from CHANGELOG for 1.0.0:
  • added function-level + DMA profiling: during a debugging session, press the Profile button on the right of the debug toolbar, and 1 frame will be profiled.
  • added ELF file size profiling: right-click an ELF file in the explorer, and select Amiga: Profile File Size
  • added WinUAE debug overlays. See template project for debug_* function calls for an example
  • updated to latest 64-bit WinUAE
  • added command Amiga: Open Terminal
  • improved INCBIN macro to correctly report binary size to the size profiler.
  • added INCBIN_CHIP macro to put binaries directly into chip mem.
  • better demo project, shows copper, bitplanes
  • support for different Amiga models (A500, A1200, A4000) in .vscode/launch.json
  • now available in the Visual Studio Code Marketplace

Here are some screenshots for ya.



Bartman is offline  
Old 02 June 2020, 09:36   #78
korruptor
TDI
 
korruptor's Avatar
 
Join Date: Feb 2007
Location: Blitter Town
Posts: 124
Thank you! I've been using it for a couple of weeks, from your github, and it's insanely cool. Thank you for sharing all your hard work.
korruptor is offline  
Old 18 June 2020, 17:58   #79
Antiriad_UK
OCS forever!
 
Antiriad_UK's Avatar
 
Join Date: Mar 2019
Location: Birmingham, UK
Posts: 418
Hi,

I've got an external assembler file with an exported function, e.g just takes d0 as input and moves to d1 then returns.

Code:
  xdef MyFunction
MyFunction:
  move.l d0,d1
  rts
Assembled to elf object format with:
vasmm68k_mot.exe -m68000 -Felf

How do I write a C header prototype that can call that function. Tried every example for gcc 6 and they all give errors. It's going to be something like
void MyFunction(register const void* input __asm("d0"));

But it doesn't like __asm.

In the example project with the compiler there's a wrapper around p61 player. It looks like a custom version of p61 has been created and then a jump table has been implemented at the start. So then the C is :

Code:
void p61Music() {
	volatile register const void* _a3 __asm("a3") = player;
	volatile register const void* _a6 __asm("a6") = (void*)0xdff000;
	__asm volatile (
		"movem.l %%d0-%%d7/%%a0-%%a2/%%a4-%%a5,-(%%sp)\n"
		"jsr 4(%%a3)\n"
		"movem.l (%%sp)+,%%d0-%%d7/%%a0-%%a2/%%a4-%%a5"
	: "+rf"(_a3), "+rf"(_a6)
	:
	: "cc", "memory");
}
I could totally implement my own jumptable and then copy this idea, but is there really no way to do it directly from a prototype to an exported function? Also where is this documented - I can guess the idea but where is "+rf" and "cc" "memory" documented for m68k? Or is it part of bartman's port?

Thanks, driving me nuts

Edit: I got the jump table version working but would be nice to know if there's an alternative.

Last edited by Antiriad_UK; 18 June 2020 at 20:36.
Antiriad_UK is offline  
Old 19 June 2020, 08:38   #80
deimos
It's coming back!
 
deimos's Avatar
 
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
Quote:
Originally Posted by Antiriad_UK View Post
How do I write a C header prototype that can call that function. Tried every example for gcc 6 and they all give errors. It's going to be something like
void MyFunction(register const void* input __asm("d0"));

But it doesn't like __asm.
This is how I do it:

Code:
void ClipAndFillPolygon2D(const UWORD n, const Point2D * polygon, const UWORD colour) {
    WaitForBlitter();

    {
        register APTR * _a0 asm("a0") = display.backBufferBitplanes;
        register UWORD _d0 asm("d0") = n;
        register Point2D * _a1 asm("a1") = polygon;
        register UWORD _d1 asm("d1") = colour;

        asm volatile (
            "        jsr     _scanlineFill"
            : // no outputs
            : "r" (_d0), "r" (_d1), "r" (_a0), "r" (_a1) // inputs
            : "memory" // changes memory
        );
    }
}
This is where it's documented: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html

Function prototypes with parameters mapped to registers is not supported, but you can map variables to registers, so you need to write a little bit of wrapper code like this. The supplied library code wrappers by bartman use macros for this and are probably also worth a look.

The gcc assembly syntax is unpleasant, so you probably don't want to use it for much more than wrapping a function.

The
"cc", "memory"
bit says that the assembly code will clobber the condition code register and memory, so disable any optimisations that depend on them. You can specify individual registers that get clobbered as well, which may allow for smarter optimisations.
deimos 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
Amiga Assembly extension for Visual Studio Code prb28 Coders. Asm / Hardware 342 15 December 2023 21:22
Visual Studio Code Blitz Basic extension earok Coders. Blitz Basic 29 16 July 2019 17:59
very basic C/ASM/Visual Studio hand holding Sephnroth Coders. C/C++ 2 08 March 2016 20:15
Profiling WinUAE with Visual Studio 2013 mark_k support.WinUAE 3 14 January 2014 20:26

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

Top

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