99 asm("streq r3, [r1, #4] "); // if not, pC->next=NULL |
99 asm("streq r3, [r1, #4] "); // if not, pC->next=NULL |
100 asm("beq 2f "); // and skip next section |
100 asm("beq 2f "); // and skip next section |
101 asm("add r5, r1, r4 "); // r5=pN=pC + pC->len (cell after pC) |
101 asm("add r5, r1, r4 "); // r5=pN=pC + pC->len (cell after pC) |
102 asm("cmp r5, r3 "); // compare pN with pE |
102 asm("cmp r5, r3 "); // compare pN with pE |
103 asm("ldmeqia r3, {r5, r12} "); // if pN==pE, r5=pE->len, r12=pE->next |
103 asm("ldmeqia r3, {r5, r12} "); // if pN==pE, r5=pE->len, r12=pE->next |
104 asm("bhi " CSM_Z22RHeap_PanicBadNextCellv ); // if pN>pE, panic |
104 asm("blhi " CSM_Z22RHeap_PanicBadNextCellv ); // if pN>pE, panic |
105 asm("strne r3, [r1, #4] "); // if pN<pE, pC->next=pE |
105 asm("strne r3, [r1, #4] "); // if pN<pE, pC->next=pE |
106 asm("addeq r4, r4, r5 "); // if pN==pE r4 = pC->len + pE->len |
106 asm("addeq r4, r4, r5 "); // if pN==pE r4 = pC->len + pE->len |
107 asm("stmeqia r1, {r4,r12} "); // if pN==pE pC->len+=pE->len, pC->next=pE->next |
107 asm("stmeqia r1, {r4,r12} "); // if pN==pE pC->len+=pE->len, pC->next=pE->next |
108 asm("2: "); |
108 asm("2: "); |
109 asm("ldr r3, [r2, #0] "); // r3=pP->len |
109 asm("ldr r3, [r2, #0] "); // r3=pP->len |
110 asm("sub r5, r1, r2 "); // r5=pC-pP (gap between preceding free cell and this one) |
110 asm("sub r5, r1, r2 "); // r5=pC-pP (gap between preceding free cell and this one) |
111 asm("cmp r5, r3 "); // compare gap with predecessor length |
111 asm("cmp r5, r3 "); // compare gap with predecessor length |
112 asm("ldreq r12, [r1, #4] "); // if predecessor is adjacent, r12=pC->next |
112 asm("ldreq r12, [r1, #4] "); // if predecessor is adjacent, r12=pC->next |
113 asm("blo RHeap_PanicBadPrevCell__Fv "); // if predecessor overlaps, panic |
113 asm("bllo RHeap_PanicBadPrevCell__Fv "); // if predecessor overlaps, panic |
114 asm("addeq r4, r4, r3 "); // if predecessor is adjacent, r4=pC->len + pP->len |
114 asm("addeq r4, r4, r3 "); // if predecessor is adjacent, r4=pC->len + pP->len |
115 asm("stmeqia r2, {r4,r12} "); // if predecessor is adjacent, pP->len+=pC->len, pP->next=pC->next |
115 asm("stmeqia r2, {r4,r12} "); // if predecessor is adjacent, pP->len+=pC->len, pP->next=pC->next |
116 asm("strne r1, [r2, #4] "); // else pP->next = pC |
116 asm("strne r1, [r2, #4] "); // else pP->next = pC |
117 asm("moveq r1, r2 "); // if predecessor is adjacent, pC=pP (final amalgamated free cell) |
117 asm("moveq r1, r2 "); // if predecessor is adjacent, pC=pP (final amalgamated free cell) |
118 asm("3: "); |
118 asm("3: "); |