I am trying to add an existing function call to old code, it was working then I changed the registers I was using to r0, maybe that is why? I also added NOP to replace a earlier line of code, NOP should
be ignored and just carry on the to pop the registers and program counter off the stack and return? I also modified the data I was using OR on, so one of these 3 things caused it to brick it's self, not I need a new board.
Here is the C code I am trying to write, by hand in hex.
void FUN_00017600(){
byte *pbVar1;
pbVar1 = DAT_00017700;
DAT_00017700[0x35] = (*DAT_00017700 & 1) << 1 | DAT_00017700[0x35] & 0xfd; // the data in memory location at address 0x800 0C25 = ((data at location 8000bf0) & 1) << 1 | data at location 0x800 0C25 &0xfd
pbVar1[0x31] = pbVar1[0x35] | 2; //data at location 0x8000 C21 = data at location 0x8000 C21 | 0x2
return 0;
}
I see I messed this up should have been 31 not 35, but that shouldn't brick it?
And here is a disassembly of the bad code:
*************************************************************
* FUNCTION *
*************************************************************
undefined FUN_00017600 ()
assume LRset = 0x0
assume TMode = 0x1
undefined r0:1 <RETURN>
FUN_00017600 XREF[1]: FUN_0000fc3e:0000fd54 (c)
00017600 b5 9f push { r0, r1, r2, r3, r4, r7, lr } ;maybe it is bad practice to use register r0?
00017602 49 3f ldr r1,[DAT_00017700 ] = 08000BF0h
00017604 4f 3e ldr r7,[DAT_00017700 ] = 08000BF0h
00017606 37 30 adds r7,#0x30
00017608 e0 05 b LAB_00017616
LAB_00017616 XREF[1]: 00017608 (j)
00017616 23 02 movs r3,#0x2
00017618 79 7a ldrb r2,[r7,#0x5 ]=>DAT_08000c25
0001761a 43 9a bics r2,r3
0001761c 78 09 ldrb r1,[r1,#0x0 ]=>DAT_08000bf0
0001761e 00 4b lsls r3,r1,#0x1
00017620 21 02 movs r1,#0x2
00017622 40 19 ands r1,r3
00017624 43 11 orrs r1,r2
00017626 71 79 strb r1,[r7,#0x5 ]=>DAT_08000c25
00017628 37 01 adds r7,#0x1
0001762a 20 02 movs r0,#0x2
0001762c 79 39 ldrb r1,[r7,#0x4 ]=>DAT_08000c25 ;should have been 0
0001762e 43 08 orrs r0,r1
00017630 70 38 strb r0,[r7,#0x0 ]=>DAT_08000c21
00017632 bf 00 nop ;NOP should be ok, should go on to return
00017634 bd 9f pop { r0, r1, r2, r3, r4, r7, pc }
DAT_00017700 XREF[2]: FUN_00017600:00017602 (R) ,
FUN_00017600:00017604 (R)
00017700 08 00 0b f0 undefine 08000BF0h ; 4 byte address to be loaded from memory