6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Wed Oct 02, 2024 4:32 am

All times are UTC




Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Thu Jun 27, 2019 2:36 am 
Offline
User avatar

Joined: Thu Mar 11, 2004 7:42 am
Posts: 362
A solution that switches to native mode (6 bytes):

Code:
; copy e flag to carry
;
; no flags (other than c) or registers affected
;
   clc     ; switch to native mode
   xce
   bcc =.1 ; if we were already in native mode, carry will be clear and we're done
   xce     ; restore emulation mode
   sec     ; set carry
.1


Without switching modes (13 bytes):

Code:
; copy e flag to carry
;
; no registers affected
; flags affected: z (and c, of course)
;
   clc
   bit ## $3800 ; this is BIT #$00 SEC if we're in 8-bit accumulator mode
   bcc =.1      ; if we're in 16-bit accumulator mode, then we must be in native mode, so we're done
   rep # $21    ; clear carry and (try to) switch to 16-bit accumulator mode
   bit ## $3800 ; this is BIT #$00 SEC if we're still in 8-bit mode (and thus in emulation mode)
   sep # $20    ; restore 8-bit accumulator mode
.1


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 27, 2019 2:47 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1948
Location: Sacramento, CA, USA
Quod erat demonstrandum. Thank you, kind sir.

_________________
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: