Reply
Highlighted
Posts: 7
Registered: ‎07-13-2014
Accepted Solution

Problem with save and restore APSR

I have some problem for asm-program. I need to save and restore
carry or borrow flag in Application Program Status Register (APSR)
in my program for subtract.very long degits. I used next commands:

        .thumb_func
        .type   LFIX_sub, %function
        .global LFIX_sub
LFIX_sub:
        .fnstart
        .cantunwind

         push    {r3-r6}
         ldr     r3,[r0],#4
         ldr     r4,[r1],#4
         subs    r3,r4     
         mrs     r6,APSR   // save MCU flags
         str     r3,[r2],#4
         mov     r5,#count
.L1_sub:
         ldr     r3,[r0],#4
         ldr     r4,[r1],#4
         msr     APSR, r6  // restore MCU flags
         sbcs    r3,r4     
         mrs     r6,psr    
         str     r3,[r2],#4
         subs    r5,#0x1   
         bgt.N   .L1_sub   
         pop     {r3-r6}
         BX      LR        

        .fnend
        .size   LFIX_sub, .-LFIX_sub

    I have error for command "msr APSR, r6":
<writing to APSR without specifying a bitmask is deprecated>

   I look all examples and manuals carefully . I can not find syntax to
write bitmask in my command. How I must write my command without mistake.

Posts: 394
Registered: ‎12-05-2016

Re: Problem with save and restore APSR

[ Edited ]

Hi @Kalaxara,

 

Please try changing the command from

msr     APSR, r6  // restore MCU flags

 

to 

msr     APSR_nzcvq, r6  // restore MCU flags

 

Apparently the bitmask that is desired consists of specifying which of the status bits are to be written back to the APSR register.

 

Thank you,

jpitt

Posts: 7
Registered: ‎07-13-2014

Re: Problem with save and restore APSR

It's really help me. Мany thanks.