When I try to get privileged mode,I get a system error Confused
..and what have you tried that fails?

Code:
.global _start
.align 4

_start:
   mov.l   .configure, r1
   stc   sr, r0
   or   r1, r0
   ldc   r0, sr
   rts
.zero 2
.configure:
   .long 0x40000000

System ERROR:INTERRUPT
Yup, that's the behavior I'd expect based on the processor manual.

Quote:
General Illegal Instruction Exception:

Sources:
...
Decoding in user mode of a privileged instruction not in a delay slot
Privileged instructions: : LDC, STC, RTE, LDTLB, SLEEP, but excluding LDC/STC instructions that access GBR

So yes, attempting to std the status register will cause an exception.

As the status register description says:
Quote:
Bit 30, MD
Processing Mode
0: User mode
1: Privileged mode
This bit is set to 1 by an exception or interrupt.


It would hardly be a secure design if any code could simply update its own operating mode to be in privileged mode! An interrupt is required because it is assumed that the privileged code maintains control over interrupts so it cannot be subverted by malicious user-mode code. Whether that's true on the Prizm, I don't know; but what you've tried simply cannot work.
I find a way to get privileged mode,should set BL bit to 1 to avoid interruption

Code:

.global _start

_start:
! SR.MD = 1      
! SR.BL = 1
! SR.RB = 1
! SR.IMASK = 0b1111
   mov.l   SR_Configure, r1
   ldc   r1, sr
! set stack from RS
   mov.l   RS_Address, r15
.stop:
    sleep
    bra .stop
    nop

RS_Address:
   .long 0xfd8001d0
SR_Configure:
   .long 0x700000f0
There is no need to enable privileged mode. The calculator already runs in privileged mode all the time, this is why gint and Vhex are even possible.

If the add-in started in user mode, it would be impossible to get elevated privileges on your own, that is exactly what user/privileged separation is for. Fortunately, it's not used in the fx-CG 50.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
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 vote in polls in this forum

 

Advertisement