Skip to content

Enhanced OS independent CPU and FPU detection - #18

Open
0xecc0-devices wants to merge 18 commits into
larsonmars:mainfrom
0xecc0-devices:main
Open

Enhanced OS independent CPU and FPU detection#18
0xecc0-devices wants to merge 18 commits into
larsonmars:mainfrom
0xecc0-devices:main

Conversation

@0xecc0-devices

@0xecc0-devices 0xecc0-devices commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

Rewrote CPU and FPU detection which now should be OS independent. Veryfied working on OS3.1 and WinUAE only though.

  • Support for FPU version added, not exposed yet.
  • Support for EC/LC variants of MC68040/MC68060 added, though not exposed yet. Reason is really that the MMU detection code is not yet implemented.
  • FPU get's set to "none" if no FPU is found

@0xecc0-devices

Copy link
Copy Markdown
Contributor Author

fpu detection crash fixed on plain 68000 machines.

@0xecc0-devices

Copy link
Copy Markdown
Contributor Author

@larsonmars finally verified working with Kickstart 1.3..my vasm DOS script needed fixing, so it now produces Kickstart 1.x compatible hunks ;D
sysvars_WB13_001

@larsonmars larsonmars self-assigned this Mar 31, 2026
@larsonmars larsonmars added the enhancement New feature or request label Mar 31, 2026
Signed-off-by: 0xecc0-devices <retromachines@vodafonemail.de>
…on of emulation environment

Signed-off-by: 0xecc0-devices <retromachines@vodafonemail.de>
@larsonmars
larsonmars self-requested a review April 20, 2026 00:15
- added emulation environment variable $Emulation which detects UAE, Emu68 or Musashi emulations
- added CPU revision environment variable $CPURev for MC68060/MC68LC060/MC68EC060 and AC68080
- fixed and simplified AC68080 detection (note: AC68080 doesn't support CACR.NAI)
- added detection of MC68LC060/MC68EC060 which will be shown for now as '68LC060' in $CPU
- added detection of MC68LC040/MC68EC040 which will be shown for now as '68LC040' in $CPU
- added detection of MC68EC020 which will be shown as '68EC020' in $CPU
- refactored CPU string output to use a table based approach instead of digit replacement
- optimized various assembler instructions as of VASM's suggestion
- updated and corrected function header documentation for various functions

@larsonmars larsonmars left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the detection improvements! This will make many people happy.
I made some comments for your consideration.

Unfortunately, I cannot just approve as is, because the tests fail due to breaking change with $CPU and $FPU. I also made some comments there. If we want to keep it the way it is now, we would have to adapt the test (the startup-sequence).

Also, we must not forget to create the Aminet release, where we mention your contribution in the .readme (I can do that in an extra commit when the PR is complete).

Comment thread source/sysvars.S Outdated
************************************************************
* *
* SYSVARS V.0.18 *
* SYSVARS V.0.23 *

@larsonmars larsonmars Apr 27, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use v.0.19?

EDIT: I understand that you did some versions in your fork. I suggest we use a versioning scheme, such as 0.20a1 or 0.20b1 for the next changes if you intent to merge it, so we keep one branch with the major versions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, no problem. I reverted the version back to 0.19
For further versions, I'll follow your suggestion using current version +a1/b1

Comment thread source/sysvars.S Outdated

PROGVER: macro
dc.b "$VER: SYSVARS 0.18",0
dc.b "$VER: SYSVARS 0.23",0

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above, would be good to have 0.19

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, no problem. I reverted the version back to 0.19
For further versions, I'll follow your suggested naming scheme

Comment thread source/sysvars.S Outdated
MC68060_ID EQU $0430

; constants for detection of 24bit addressing
KICK_VER equ $00F8000C

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

equ => EQU (for consistency)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed that, too.

Comment thread source/sysvars.S Outdated
endc

movea.l EXEC_BASE,a6 ; get exec base in A6
movea.l EXEC_BASE.w,a6 ; get exec base in A6

@larsonmars larsonmars Apr 27, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate the benefit of using EXEC_BASE.w instead of just EXEC_BASE? I would expect assemblers to do it right either way, but the added .w is noisier.

@0xecc0-devices 0xecc0-devices Apr 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because vasm will complain with optimization abs.l -> abs.w

How about a simple macro?

;-----------------------------------------------------------
; get's exec.library base address to passed address register
;-----------------------------------------------------------
; Macro Arguments:
; 1: address register to store the exec.library address in
;-----------------------------------------------------------
EXECBASE macro
	movea.l EXEC_BASE.w,\1
  endm

Comment thread source/sysvars.S Outdated
.cpuName:
dc.b "68000",0,0,0
dc.b "68010",0,0,0
dc.b "68EC020",0

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I very much appreciate that we can now distinguish EC versions of a CPU. However, putting it into the name like this we loose the ability to use inequality operators (less/greater than) in scripts, which is quite common to enable certain tools only for certain CPU generations or newer (see also the test that must we must adapt so it works again).

Maybe we can split the EC/LC as separate $CPUVariant variable, or we could create variables for the actual CPU feature (or the lack thereof), such as $MMU. As we already have $FPU, which can be 68881, 68882 and internal, the information in $CPU, $FPU, $MMU would be sufficient to determine whether it is an LC/EC CPU.

What would you prefer?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think much about that. But you're right..for a script tool the $CPU variable denotes the integer compatibility, which doesn't differ between the XC/EC/LC variants.
I'd go with your suggestion to keep $CPU, $FPU and $MMU separated and clean from variants. I'm not even convinced that the $CPUVariant variable would be necessary.

Comment thread README.md Outdated
| **``$CPU``** | always | installed CPU, for example ``68030`` (68080 is supported, but see [limitations](#Kickstart-13-and-below))
| **``$FPU``** | if&nbsp;CPU&nbsp;≥&nbsp;68020 | installed FPU, one of ``68881``, ``68882``, ``internal``, or empty for LC/EC 040 and 060 CPUs where no FPU is available (see [limitations](#Kickstart-13-and-below))
| **``$CPU``** | always | installed CPU, for example ``68030``
| **``$FPU``** | always | installed FPU, one of ``68881``, ``68882``, ``internal``, or ``none`` for LC/EC 040 and 060 CPUs where no FPU is available

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like with the CPU, this is a breaking change. Is there a reason why you changed the FPU to be always available again? The inital sysvars version also had this defined always. I had this later changed to be not defined for CPUs below MC68020 so it is consistent with other properties that are only defined when they can technically be available. AFAIK, there can never be any FPU with anything below MC68020, but maybe I'm wrong. Also, why is 'none' better then just empty?

@0xecc0-devices 0xecc0-devices Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible to have an FPU with the 68000 as a peripheral (see Motorola AN947). But it's rather impractical.
In Amiga DOS scripts you would probably go for IF EXISTS checking for the availability of the environment variable and then compare the value with IF $FPU EQ or something similar.
I think script-wise there's no real difference between checking for existance of the variable or getting it's value evaluated.

I'll just revoke the change that sets the variable when there's no FPU detected.

- removed detection of MC68EC020/MC68LC040/MC68EC040/MC68LC060/MC68EC060 which makes $CPU showing the integer unit's capabilities
- refactored CPU string output to use digit replacement again
- added macro for getting exec.library base pointer to improve readability avoiding assembler optimization output
@0xecc0-devices

Copy link
Copy Markdown
Contributor Author

Any thoughts on the changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants