Apollo Accelerators
http://forum.apollo-accelerators.com/

Detecting AC68080 programmaticaly
http://forum.apollo-accelerators.com/viewtopic.php?f=10&t=19
Page 1 of 1

Author:  flype [ Mon 28 Nov 2016 09:12 ]
Post subject:  Detecting AC68080 programmaticaly

This article is intended to speak about detection of the APOLLO Core (M68k AC68080). There are some differents ways to do this.



AttnFlags, the recommended method


On AmigaOS, the recommended method to detect the CPU is by reading the AttnFlags property of the ExecBase.

Since the core GOLD2.5, this system flag is aware of the presence of a AC68080 processor.

viewtopic.php?f=3&t=1753
http://apollo-accelerators.com/files/GOLD2.5/


The AttnFlags are defined in the exec/execbase.i and exec/execbase.h include files :

http://amigadev.elowar.com/read/ADCD_2. ... e007C.html
http://amigadev.elowar.com/read/ADCD_2. ... e009E.html


For our usage, coder-side, we just need to extend the execbase includes :


- In Assembly Language, add this to your execbase.i, or to your code :
	IFND AFB_68080
;
; The AFB_68080 bit is set when a working AC68080
; is in the system. If this is set then all bits
; for 010/020/030/040 are also set, since the 080
; is intended to be compatible with all of them.
;
AFB_68080	EQU 10
AFF_68080	EQU (1<<10)
	ENDC

- In C Language, add this to your execbase.h, or to your code :
#ifndef AFB_68080
/*
 * The AFB_68080 bit is set when a working AC68080
 * is in the system. If this is set then all bits
 * for 010/020/030/040 are also set, since the 080
 * is intended to be compatible with all of them.
 */
#define AFB_68080	10
#define AFF_68080	(1<<10)
#endif

You can obtain the Amiga OS3.x includes from these links, for example :

http://aminet.net/package/dev/gcc/ADE
http://aminet.net/package/dev/gcc/ADE-repack

The includes are in the ADE/os-include/ folder.
You can eventually assign this folder in your S:user-startup.
ASSIGN includes: WORK:ADE/os-include/


Assembly, using VASM and GOLD2.5+


I advise to read the VASM documentation for M68K, and look at the "68080" occurrences.
http://sun.hasenbraten.de/vasm/release/ ... cpu-module


To experiment the example below, you can download VASM for Amiga OS3 :
http://sun.hasenbraten.de/vasm/index.php?view=binrel
http://sun.hasenbraten.de/vasm/bin/rel/ ... ot_os3.lha


Example of Assembly Language code that use AFB_AC68080 :
;==============================================================
;
; Detect the AC68080, the OS friendly way
;
; (C) APOLLO-Team 2016-2017
;
;==============================================================

	INCDIR  includes
	INCLUDE exec/execbase.i
    
	IFND AFB_68080
;
; The AFB_68080 bit is set when a working AC68080
; is in the system. If this is set then all bits
; for 010/020/030/040 are also set, since the 080
; is intended to be compatible with all of them.
;
BITDEF AF,68080,10 ; Set if AC68080
	ENDC

;==============================================================

	IFD      __VASM
	MACHINE  AC68080          ; VASM doc => MACHINE <cpu_type>
	ENDC

;==============================================================

MAIN:
	move.l   $4.w,a6          ; Load ExecBase
	move.w   AttnFlags(a6),d0 ; Read AttnFlags
	btst.l   #AFB_68080,d0    ; AC68080 ?
	bne.s    2$               ; Use 080
1$	bsr      Use68K           ; Specific 68K code
2$	bsr      Use080           ; Specific 080 code
	rts                       ; Return ($RC is 0 or 1)

Use68K:
	AND      d0,d0            ; Dummy 68K instr
	moveq.l  #0,d0            ; Result
	rts                       ; Return

Use080:
	PAND     d0,d0,d0         ; Dummy 080 instr
	moveq.l  #1,d0            ; Result
	rts                       ; Return

;==============================================================

	end


Compile using MACHINE AC68080 directive in the source code :
vasmm_mot_os3 -Fhunkexe detect080.asm -o detect080
Compile without using MACHINE AC68080 directive in the source code :
vasmm_mot_os3 -m68080 -Fhunkexe detect080.asm -o detect080
Once compiled, run the program :
detect080  ; run program
echo $RC   ; output 1 on a 68080 machine, else 0.


C Language, using GCC and GOLD2.5+

Example of C Language code that use AFF_AC68080 :
#include <exec/execbase.h>

struct ExecBase *SysBase;

#ifndef AFB_68080
/*
 * The AFB_68080 bit is set when a working AC68080
 * is in the system. If this is set then all bits
 * for 010/020/030/040 are also set, since the 080
 * is intended to be compatible with all of them.
 */
#define AFB_68080	10
#define AFF_68080	(1<<10)
#endif

int main(int argc, char *argv[])
{
	if( SysBase->AttnFlags & AFF_68080 ) {
		printf( "AC68080 detected.\n" );
	} else {
		printf( "AC68080 NOT detected.\n" );
	}
	
	return 0;
}

Simply compile it this way :
gcc Detect080.c -o Detect080gcc

Author:  flype [ Mon 28 Nov 2016 09:12 ]
Post subject:  Re: Detecting AC68080 programmaticaly

** RESERVED **

Author:  UltraSBM [ Thu 10 Aug 2017 16:14 ]
Post subject:  Re: Detecting AC68080 programmaticaly

What programming language do you guys use to write your Amiga applications?

Author:  flype [ Sat 26 Aug 2017 15:36 ]
Post subject:  Re: Detecting AC68080 programmaticaly

UltraSBM wrote: *  Thu 10 Aug 2017 16:14
What programming language do you guys use to write your Amiga applications?
There are many that can be used.

I can see often people using on amiga OS 3.x :

- ASM 68K, using VASM or Devpac (many others are available)
- C Lang, much more suitable for Amiga than C++, using GCC, VBCC, SASC
- Amiga E using ECX for Amiga
- Some use also AmiBlitz, Amos, Pascal, ...

Page 1 of 1 All times are UTC+02:00
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/