Login

Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.

ARM Community: Thumb mode, Thumb2 MRS insturction issue. - ARM Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Thumb mode, Thumb2 MRS insturction issue. Thumb2, MRS, Thumb Rate Topic: -----

#1 User is offline   Zaire 

  • Member
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 28-July 11

Posted 28 July 2011 - 08:07 AM

Dear All

I have find a strange behavior on cortexA9/R4,

My mode data code as below

0x0 0x8100F3EF MRS R1,CPSR (current CPSR value is 0x1F3)

However when I execute the line, the value in R1 is 0x1D3, Isn't it should be 0x1F3?

Is it a chip bug? or there is some other reason?

If anyone knows the answer, please let me know.
0

#2 User is offline   ttfn 

  • Super Contributor
  • PipPipPipPip
  • Group: Members
  • Posts: 576
  • Joined: 29-September 06

Posted 28 July 2011 - 11:46 AM

Bit 5 is the T bit (ARM or Thumb state). The value you're getting back implies you are in fact in ARM state. How do you know what the value should be? Are you using a debugger?
1

#3 User is offline   sim 

  • Regular Contributor
  • PipPipPip
  • Group: Members.
  • Posts: 419
  • Joined: 04-October 06

Posted 28 July 2011 - 09:35 PM

The T-bit is not readable via MRS. The least significant byte of the CPSR is masked with 0xDF when read.

hth
s.
0

#4 User is offline   Zaire 

  • Member
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 28-July 11

Posted 29 July 2011 - 04:08 AM

 ttfn, on 28 July 2011 - 11:46 AM, said:

Bit 5 is the T bit (ARM or Thumb state). The value you're getting back implies you are in fact in ARM state. How do you know what the value should be? Are you using a debugger?



I'm using a debugger

data in 0x0700000C is MRS r1,cpsr[0x8100F3EF] , start program at 0x07000002 [thumb mode] and stop at Bp 0x0700001A, but the R1 value is not 0x1F3, it shown as 0x1D3

Attached File  MRS_Before.jpg (207.04K)
Number of downloads: 4

Attached File  MRS_After.jpg (207.75K)
Number of downloads: 4
0

#5 User is offline   Christophe31 

  • Member
  • Pip
  • Group: Members
  • Posts: 17
  • Joined: 06-July 11

Posted 01 August 2011 - 02:24 PM

Hi,

Answer is in DDI0406B (ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition), §B1.3.3 :
The execution state bits are the IT[7:0], J, E, and T bits. In exception modes you can read or write these bits
in the current SPSR.
In the CPSR, unless the processor is in Debug state:
• The execution state bits, other than the E bit, are RAZ when read by an MRS instruction
.

Regards

Christophe
1

#6 User is offline   Christophe31 

  • Member
  • Pip
  • Group: Members
  • Posts: 17
  • Joined: 06-July 11

Posted 02 August 2011 - 07:03 AM

Hi again,

I think the solution is with software interrupt (also called "system call") :
- add a dedicated entry in your intvecs table :

b _c_int00
undefEntry
b undefEntry
svcEntry
b ISR_SWI ; SOFTWARE INTERRUPT
...

- that you can call with :
svc 0x01


- and which contains something like :
ISR_SWI
; here, cpsr is copied into spsr_svc
mrs r1,spsr
movs pc, lr ; Return

Regards

Christophe
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic