AnsweredAssumed Answered

[KEAZN64] Writing in WDOG_CNTL by assembly

Question asked by Mohammed Aboelnasr on May 15, 2019
Latest reply on May 16, 2019 by Mohammed Aboelnasr

Hello,

 

I am trying to write in register WDOG_CNTL by the following:

 

1. Saving address of register WDOG_CNTL in register r3

2. Writing needed value "A6" in register r2

3. Storing r2 value inside address of r3

 

asm ("MOVS r2,#0x40"); /* 40 */
asm ("LSLS r3,r2,#24");
asm ("MOVS r2,#0");
asm ("MOVS r2,#0x05"); /* 05 */
asm ("LSLS r2,r2,#16");
asm ("ADD r3,r2,r3");
asm ("MOVS r2,#0");
asm ("MOVS r2,#0x20"); /* 20 */
asm ("LSLS r2,r2,#8");
asm ("ADD r3,r2,r3");
asm ("MOVS r2,#0");
asm ("MOVS r2,#0x03"); /* 03 */
asm ("ADD r3,r2,r3");
asm ("MOVS r2,#0");

 

asm("MOVS r2,#0xA6");
asm("STRH r2,[r3]");

 

At the last assembly line, assembler jumps to "Hard_Fault" exception.

 

Would you help please ?

Outcomes