From 03831a7394591b3a3aaefd77627538b2a8208ba5 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Thu, 18 Jan 2024 19:30:18 +0100 Subject: [PATCH] added cx16.cpu_is_65816() --- compiler/res/prog8lib/cx16/syslib.p8 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index 456a305cc..6f1b7f69e 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -1156,6 +1156,20 @@ sub search_x16edit() -> ubyte { return 255 } + asmsub cpu_is_65816() -> bool @A { + ; Returns true if you have a 65816 cpu, false if it's a 6502. + ; for Prog8 with the 64tass assembler, call in 8 bit mode only + %asm {{ + .cpu '65816' ; let 64tass use the xba opcode + lda #1 ; set up for a <> b exchange + xba ; exchange will be a nop on a 65C02 + lda #0 ; set up for second exchange + xba ; exchange will be a nop on the 65C02 + rts + .cpu 'w65c02' + }} + } + } sys {