Ask help for assembly language in S32DS

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ask help for assembly language in S32DS

2,666 Views
fyw
Contributor IV

162503_162503.PNG捕获.PNG

 

the highlight line (line 65) will cause compile err, i want help for how to resolve this?  Thank you very much!

 

PS: the enviroment is S32DS

Labels (1)
Tags (3)
4 Replies

1,797 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

you have to use kregs instead of r.

__asm__ ("se_or %0, %1 \n\t" : "=kregs"(reg0) : "kregs"(reg1));

According to EABI standard, compiler places reg0 and reg1 to GPR8 and GPR9 register, but instruction se_or is limited to registers GPR0-GPR7 and GPR24-GPR31. This kregs tells to compiler about this limitation.

Simplest solution is to use se_bseti instead of your code.

pastedImage_1.png

Regards,

Martin

1,797 Views
fyw
Contributor IV

Thank you MArtin Kovar!

The compile err is disappeared.  But i see the disassemble language, i find that it's not what i hope to(the red part)

i wander do i write wrong? If yes, what is the right way? Thank you very much!

 unsigned int reg0, reg1;
 /*  MSR |= 0x2000    --->  This is what i hope */

 __asm__("mfmsr %0 \n\t" : "=kregs"(reg0));
   8: 7c e0 00 a6  mfmsr   r7
   c: 02 71        se_mtar r9,r7
   e: 55 3f 00 08  e_stw   r9,8(r31)

 __asm__("e_lis  %0,0x0000 \n\t" : "=kregs"(reg1));
  12: 70 e0 e0 00  e_lis   r7,0
  16: 02 71        se_mtar r9,r7
  18: 55 3f 00 0c  e_stw   r9,12(r31)
 __asm__("e_add16i %0, %0,0x2000 \n\t" : "=kregs"(reg1));
  1c: 1c e7 20 00  e_add16i r7,r7,8192
  20: 02 71        se_mtar r9,r7
  22: 55 3f 00 0c  e_stw   r9,12(r31)

 __asm__("se_or  %0, %1 \n\t" : "=kregs"(reg0) : "kregs"(reg1));   /* not reg0 |= reg1 ? */
  26: 51 3f 00 0c  e_lwz   r9,12(r31)
  2a: 03 17        se_mfar r7,r9
  2c: 44 77        se_or   r7,r7
  2e: 02 71        se_mtar r9,r7
  30: 55 3f 00 08  e_stw   r9,8(r31)

 __asm__("mtmsr %0 \n\t" : "=kregs" (reg0));
  34: 7c e0 01 24  mtmsr   r7
  38: 02 71        se_mtar r9,r7
  3a: 55 3f 00 08  e_stw   r9,8(r31)

0 Kudos
Reply

1,797 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

I am afraid it is not possible to use the construction you want. I tested it also with MPC5775K (not only disassemble), but the behavior is not correct.

This following line is not compiled the way I want exactly as you mentioned in your previous post.

 __asm__("se_or  %0, %1 \n\t" : "=kregs"(reg0) : "kregs"(reg1));   /* not reg0 |= reg1 ? */

I tested your code without extended assembler and this works correct.

__asm__("mfmsr %r6");

__asm__("e_lis    %r7,0x0000");
__asm__("e_add16i    %r7,%r7,0x1000");

__asm__ ("se_or %r6, %r7");

__asm__("mtmsr %r6");

So from my point of view the best way is to use se_bseti instruction as I mentioned in my previous post, or you can invent more complex construction using extended assembler, but remember about restriction for some instructions (not all instruction could be placed to all GPR registers).

Regards,

Martin

1,797 Views
fyw
Contributor IV

Thank you very much!

0 Kudos
Reply