15 November 2016, 18:40 | #21 |
Registered User
Join Date: Jul 2008
Location: Poland
Posts: 662
|
I want use inflate from here https://raw.githubusercontent.com/ke...er/inflate.asm
Code:
long inflate(register z_streamp instream __asm("a5"), register int outdata __asm("a4")); Last edited by arti; 15 November 2016 at 18:55. |
15 November 2016, 18:48 | #22 |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
The order is important. I ended up changing the macro syntax slightly to get the universal macros to work. I changed the example and there is now a test for GCC and vbcc which are now working for me. I updated my earlier post in this thread with an attachment to a new universal macro archive.
Yes, but remember the 68k registers are 32 bits. Wider integer datatypes will not work and most datatypes can vary in size. The safest datatypes are probably int32_t, uint32_t, LONG, ULONG, APTR because they shouldn't vary in width. Narrower datatypes than 32 bit should be handled correctly but may be slower in some cases on the 68020+. Last edited by matthey; 15 November 2016 at 19:03. |
15 November 2016, 23:53 | #23 | |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
Quote:
Something like Code:
void inflate(register char *instream __asm("a5"), register char *outdata __asm("a4")); |
|
16 November 2016, 19:54 | #24 |
Registered User
Join Date: Jul 2008
Location: Poland
Posts: 662
|
That's how I have implemented it, posted here:
http://eab.abime.net/showpost.php?p=...9&postcount=55 |
17 November 2016, 00:34 | #25 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
Is it possible to have a small encoded and a decoded sample in order to play with it?
|
17 November 2016, 12:57 | #26 |
Registered User
Join Date: Jul 2008
Location: Poland
Posts: 662
|
|
17 November 2016, 17:42 | #27 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
Can't really compile it. But...
You are doing Code:
int inflate_asm(register z_streamp instream __asm("a5"), register int outdata __asm("a4")); int __wrap_inflate2(z_streamp instream, int flush) { int outdata; inflate_asm(instream, outdata); //return inflate(instream, flush); return outdata; } z_streamp is (if you peek at zlib.h) Code:
typedef struct z_stream_s { Bytef *next_in; /* next input byte */ uInt avail_in; /* number of bytes available at next_in */ uLong total_in; /* total nb of input bytes read so far */ Bytef *next_out; /* next output byte should be put there */ uInt avail_out; /* remaining free space at next_out */ uLong total_out; /* total nb of bytes output so far */ char *msg; /* last error message, NULL if no error */ struct internal_state FAR *state; /* not visible by applications */ alloc_func zalloc; /* used to allocate the internal state */ free_func zfree; /* used to free the internal state */ voidpf opaque; /* private data object passed to zalloc and zfree */ int data_type; /* best guess about the data type: binary or text */ uLong adler; /* adler32 value of the uncompressed data */ uLong reserved; /* reserved for future use */ } z_stream; typedef z_stream FAR *z_streamp; Your input pointer is not pointing to that. That's your problem, I think |
03 December 2016, 14:52 | #28 |
Registered User
Join Date: Jul 2008
Location: Poland
Posts: 662
|
That's how I corrected it :
Code:
#include "zlib.h" int inflate_asm(register png_structrp png_ptr __asm("a5"), register int outdata __asm("a4")); int /* PRIVATE */ png_zlib_inflate(png_structrp png_ptr, int flush) { int outdata; if (png_ptr->zstream_start && png_ptr->zstream.avail_in > 0) { if ((*png_ptr->zstream.next_in >> 4) > 7) { png_ptr->zstream.msg = "invalid window size (libpng)"; return Z_DATA_ERROR; } png_ptr->zstream_start = 0; } inflate_asm(&png_ptr->zstream, outdata); return outdata; } |
03 December 2016, 19:27 | #29 |
Amigan
Join Date: Feb 2012
Location: London
Posts: 1,311
|
> register int outdata
Try using 'unsigned char *' instead of int. In C int is a signed type which may cause problems (use unsigned int at least). For example: Code:
int inflate_asm(register png_structrp png_ptr __asm("a5"), register unsigned char *outdata __asm("a4")); unsigned char *png_zlib_inflate(png_structrp png_ptr, int flush) After this line add this and see what it outputs: printf("%lx\n", outdata); |
15 December 2019, 18:33 | #30 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,196
|
Been trying to compile ptplayer.h (Frank protracker replayer) file to gcc.
with Bebbo gcc compiler (based on GCC 6) this doesn't work: Code:
void mt_install_cia(register void *custom __asm("a6"), register void *VectorBase __asm("a0"), register UBYTE PALflag, asm("d0")); Code:
void ASM mt_install_cia(REG(a6, void *custom), REG(a0, void *VectorBase), REG(d0, UBYTE PALflag)); |
15 December 2019, 18:59 | #31 | |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
Quote:
I do it with inline assembly. You get to specify how a bunch of local variables are mapped to registers, then you can write a tiny bit of inline asm that is basically just a jsr. It's not as easy as the other way, but once you've done one it's not so bad. I don't know if it's more efficient, but you get to specify which registers get clobbered rather than saving them yourself, if you want, which may help, amongst other things. There's an example in the code attached to this post http://eab.abime.net/showpost.php?p=1361520&postcount=6 which may or may not be 100% correct, I can't check until I'm at a PC tomorrow. Last edited by deimos; 15 December 2019 at 19:18. |
|
15 December 2019, 20:48 | #32 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,196
|
that's how gcc defines OS calls. With this macro technique.
Code:
#define Supervisor(___userFunction) \ LP1A5FP(0x1e, ULONG, Supervisor , __fpt, ___userFunction, d7,\ , EXEC_BASE_NAME, ULONG (*__fpt)()) with macro defined as: #define LP1A5FP(offs, rt, name, t1, v1, r1, bt, bn, fpt) \ ({ \ typedef fpt; \ t1 _##name##_v1 = (v1); \ rt _##name##_re2 = \ ({ \ register int _d1 __asm("d1"); \ register int _a0 __asm("a0"); \ register int _a1 __asm("a1"); \ register rt _##name##_re __asm("d0"); \ register void *const _##name##_bn __asm("a6") = (bn); \ register t1 _n1 __asm(#r1) = _##name##_v1; \ __asm volatile ("exg d7,a5\n\tjsr a6@(-"#offs":W)\n\texg d7,a5" \ : "=r" (_##name##_re), "=r" (_d1), "=r" (_a0), "=r" (_a1) \ : "r" (_##name##_bn), "rf"(_n1) \ : "fp0", "fp1", "cc", "memory"); \ _##name##_re; \ }); \ _##name##_re2; \ }) Last edited by jotd; 15 December 2019 at 21:06. |
15 December 2019, 21:11 | #33 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
|
gcc used to support __asm(), which SDI_compiler.h defines as REG() macro.
All real Amiga gcc-ports worked with it. Seems your port is broken. Last edited by phx; 15 December 2019 at 21:13. Reason: Confused __reg with __asm. |
15 December 2019, 21:42 | #34 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,196
|
yeah probably. I'm using an old distro of Bebbo gcc 6 (6.4). Debugger also doesn't work.
But latest amiga gcc version crashes randomly at startup with my code (on fopen, on printf, other...), and I seriously believe that the latest version is buggy, not my code (which has been ported on Windows & NDS without issues). With this version there are no random crashes at last (yes, I have increased stack to a big value) |
15 December 2019, 21:44 | #35 | ||
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
Quote:
Quote:
Last edited by deimos; 17 December 2019 at 13:54. |
||
15 December 2019, 23:06 | #36 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,196
|
Well, good news, I upgraded, and it compiled okay with the new build.
(m68k-amigaos-gcc (GCC) 6.5.0b 191023121710) https://franke.ms/download/setup-amiga-gcc.exe Well, it still crashes, but when I add -noixemul it works So now I have the debugger and all! I didn't think I would solve several problems because of this. Thanks anyone. |
25 December 2019, 11:34 | #37 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,196
|
Now I'd like to return something as a register. I suppose that:
Code:
ULONG ASM read_joystick(REG(d0, ULONG number)); |
25 December 2019, 12:38 | #38 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
|
Quote:
Quote:
Last edited by phx; 25 December 2019 at 12:47. Reason: Don't forget pointers. |
||
25 December 2019, 17:08 | #39 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,196
|
indeed all I wanted was to return status in D0: working, thanks
|
11 March 2020, 18:42 | #40 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
I know that D0/D1 and A0/A1 are scratch registers and don't need to be saved. What I'm unsure about is, what's the case if I specify another register as param like in the below example:
Code:
uint32_t foo(void *param1 __asm("d0"), void *param2 __asm("d1"), void *param3 __asm("d2")); |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Replacing OS4 functions for OS3.x | arti | Coders. C/C++ | 25 | 17 December 2018 16:03 |
functions benchmark | wawa | Coders. System | 2 | 15 April 2013 18:55 |
How do the non-i/o functions work? | mikro | project.WHDLoad | 3 | 03 November 2011 14:33 |
Lost F key Functions on WINuae startup | breadbaker | support.WinUAE | 8 | 06 December 2005 20:09 |
CD32 blue button functions differently | oldpx | support.WinUAE | 6 | 09 August 2004 13:43 |
|
|