Update contrib.
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\common\arm\cdes16.cia
19 #include "../common.h"
21 #if defined(__DES16_MACHINE_CODED__) || defined(__EABI__)
23 GLREF_C void Des16PanicBadDesType();
24 GLREF_C void Des16PanicPosOutOfRange();
28 #ifdef __DES16_MACHINE_CODED__
30 GLREF_C void Des16PanicLengthNegative();
31 GLREF_C void Des16PanicMaxLengthNegative();
32 GLREF_C void Des16PanicLengthOutOfRange();
33 GLREF_C void Des16PanicDesOverflow();
34 GLREF_C void Des16PanicDesIndexOutOfRange();
36 __NAKED__ EXPORT_C const TUint16 *TDesC16::Ptr() const
38 // Return a pointer to the buffer.
41 asm("ldr r1, [r0], #4 ");
42 asm("cmp r1, #0x50000000 ");
43 asm("bcs " CSM_Z20Des16PanicBadDesTypev);
44 asm("eor r1, r1, r1, lsr #1 ");
45 asm("msr cpsr_flg, r1 ");
46 asm("addcs r0, r0, #4 ");
47 asm("ldrle r0, [r0] ");
48 asm("addeq r0, r0, #4 ");
52 #ifndef __EABI_CTORS__
53 __NAKED__ EXPORT_C TPtrC16::TPtrC16()
55 // Default constructor
58 asm("mov r1, #0x10000000 "); // type=EPtrC, length=0
59 asm("mov r2, #0 "); // ptr=NULL
60 asm("stmia r0, {r1,r2} ");
64 __NAKED__ EXPORT_C TPtrC16::TPtrC16(const TDesC16& /*aDes*/)
69 asm("ldr r2, [r1], #4 "); // r2 = type/length
70 asm("bic r3, r2, #0xF0000000"); // r3 = length
71 asm("orr r3, r3, #0x10000000"); // r3 = EPtrC + length
72 asm("cmp r2, #0x50000000 ");
73 asm("bcs " CSM_Z20Des16PanicBadDesTypev);
74 asm("eor r2, r2, r2, lsr #1 ");
75 asm("msr cpsr_flg, r2 ");
76 asm("addcs r1, r1, #4 ");
77 asm("ldrle r1, [r1] ");
78 asm("addeq r1, r1, #4 "); // r1 = aDes.Ptr()
80 asm("str r1, [r0, #4] ");
84 #ifdef __DES16_MACHINE_CODED_HWORD__
85 __NAKED__ EXPORT_C TPtrC16::TPtrC16(const TUint16* /*aString*/)
90 asm("mov r2, r1 "); // save aString address
92 asm("ldrh r3, [r1], #2 ");
94 asm("bne 1b "); // loop until we reach zero terminator
95 asm("rsb r1, r2, r1 "); // r1 = 2*length + 2
96 asm("sub r1, r1, #2 "); // r1 = 2*length
97 asm("mov r1, r1, lsr #1 "); // r1 = length
98 asm("orr r1, r1, #0x10000000 "); // r1=EPtrC + length
99 asm("stmia r0, {r1, r2} "); // store type/length and ptr fields
104 __NAKED__ EXPORT_C TPtrC16::TPtrC16(const TUint16* /*aBuf*/,TInt /*aLength*/)
109 asm("orrs r2, r2, #0x10000000 ");
110 asm("strpl r2, [r0] ");
111 asm("strpl r1, [r0, #4] ");
113 asm("b " CSM_Z24Des16PanicLengthNegativev);
116 __NAKED__ EXPORT_C TPtr16::TPtr16(TUint16* /*aBuf*/,TInt /*aMaxLength*/)
122 asm("movpl r3, r1 ");
123 asm("movpl r1, #0x20000000 "); // length=0, EPtr
124 asm("stmplia r0, {r1,r2,r3} ");
126 asm("b " CSM_Z27Des16PanicMaxLengthNegativev);
129 __NAKED__ EXPORT_C TPtr16::TPtr16(TUint16* /*aBuf*/,TInt /*aLength*/,TInt /*aMaxLength*/)
134 asm("cmp r2, #0 "); // check length>=0
135 asm("cmpge r3, r2 "); // if so, check maxlength>=length
136 asm("movge r12, r1 ");
137 asm("orrge r2, r2, #0x20000000 "); // r2 = length + EPtr
138 asm("stmgeia r0, {r2,r3,r12} ");
141 asm("bmi " CSM_Z24Des16PanicLengthNegativev);
143 asm("bmi " CSM_Z27Des16PanicMaxLengthNegativev);
144 asm("b " CSM_Z26Des16PanicLengthOutOfRangev);
147 __NAKED__ EXPORT_C TPtr16::TPtr16(TBufCBase16& /*aLcb*/,TInt /*aMaxLength*/)
153 asm("ldr r1, [r3] ");
154 asm("bic r1, r1, #0xF0000000 "); // r1=aLcb.Length()
155 asm("cmp r1, r2 "); // check against maxlength
156 asm("orrle r1, r1, #0x40000000 "); // r1=aLcb.Length() + EBufCPtr
157 asm("stmleia r0, {r1,r2,r3} ");
159 asm("b " CSM_Z26Des16PanicLengthOutOfRangev);
162 __NAKED__ EXPORT_C TBufCBase16::TBufCBase16()
168 asm("str r1, [r0] ");
172 #ifdef __DES16_MACHINE_CODED_HWORD__
173 __NAKED__ EXPORT_C TBufCBase16::TBufCBase16(const TUint16* /*aString*/,TInt /*aMaxLength*/)
178 asm("sub r3, r1, #2 "); // r3=aString address-2
180 asm("ldrh r12, [r3, #2]! ");
182 asm("bne 1b "); // loop until we reach zero terminator
183 asm("sub r3, r3, r1 "); // r3 = 2*length
184 asm("mov r3, r3, lsr #1 "); // r3 = length (+EBufC)
185 asm("cmp r3, r2 "); // check against max length
186 asm("bgt Des16PanicLengthOutOfRange__Fv ");
187 asm("stmfd sp!, {r0,lr} "); // save registers for function call
188 asm("str r3, [r0], #4 "); // save length/type field, r0->buffer
189 asm("add r2, r3, r3 "); // size=2*length into r2 for function call
190 asm("bl memmove "); // call memmove
195 __NAKED__ EXPORT_C TBufCBase16::TBufCBase16(const TDesC16& /*aDes*/,TInt /*aMaxLength*/)
200 asm("ldr r3, [r1], #4 "); // r3 = type/length
201 asm("bic r12, r3, #0xF0000000"); // r12 = length
202 asm("cmp r12, r2 "); // compare with maxlength
203 asm("bgt " CSM_Z26Des16PanicLengthOutOfRangev);
204 asm("cmp r3, #0x50000000 ");
205 asm("bcs " CSM_Z20Des16PanicBadDesTypev);
206 asm("eor r3, r3, r3, lsr #1 ");
207 asm("msr cpsr_flg, r3 ");
208 asm("addcs r1, r1, #4 ");
209 asm("ldrle r1, [r1] ");
210 asm("addeq r1, r1, #4 "); // r1 = aDes.Ptr()
211 asm("stmfd sp!, {r0,lr} "); // save registers for function call
212 asm("str r12, [r0], #4 "); // store length/type, r0->buffer
213 asm("add r2, r12, r12 "); // size=2*length into r2 for function call
214 asm("bl memmove "); // call memmove
219 #ifdef __DES16_MACHINE_CODED_HWORD__
220 __NAKED__ EXPORT_C void TBufCBase16::Copy(const TUint16* /*aString*/,TInt /*aMaxLength*/)
222 // Copy from a string.
225 asm("sub r3, r1, #2 "); // r3=aString address-2
227 asm("ldrh r12, [r3, #2]! ");
229 asm("bne 1b "); // loop until we reach zero terminator
230 asm("sub r3, r3, r1 "); // r3 = 2*length
231 asm("mov r3, r3, lsr #1 "); // r3 = length (+EBufC)
232 asm("cmp r3, r2 "); // check against max length
233 asm("bgt Des16PanicLengthOutOfRange__Fv ");
234 asm("str r3, [r0], #4 "); // save length/type field, r0->buffer
235 asm("add r2, r3, r3 "); // size=2*length into r2 for function call
236 asm("b memmove "); // call memmove
240 __NAKED__ EXPORT_C void TBufCBase16::Copy(const TDesC16& /*aDes*/,TInt /*aMaxLength*/)
242 // Copy from a descriptor.
245 asm("ldr r3, [r1], #4 "); // r3 = type/length
246 asm("bic r12, r3, #0xF0000000"); // r12 = length
247 asm("cmp r12, r2 "); // compare with maxlength
248 asm("bgt " CSM_Z21Des16PanicDesOverflowv);
249 asm("cmp r3, #0x50000000 ");
250 asm("bcs " CSM_Z20Des16PanicBadDesTypev);
251 asm("eor r3, r3, r3, lsr #1 ");
252 asm("msr cpsr_flg, r3 ");
253 asm("addcs r1, r1, #4 ");
254 asm("ldrle r1, [r1] ");
255 asm("addeq r1, r1, #4 "); // r1 = aDes.Ptr()
256 asm("str r12, [r0], #4 "); // store length/type, r0->buffer
257 asm("add r2, r12, r12 "); // size=2*length into r2 for function call
258 asm("b memmove "); // call memmove
261 #ifndef __EABI_CTORS__
262 __NAKED__ EXPORT_C TBufBase16::TBufBase16(TInt /*aMaxLength*/)
264 asm("mov r2, #0x30000000 "); // EBuf + zero length
265 asm("str r2, [r0] ");
266 asm("str r1, [r0, #4] ");
270 __NAKED__ EXPORT_C TBufBase16::TBufBase16(TInt /*aLength*/, TInt /*aMaxLength*/)
272 asm("cmp r1, #0 "); // check length>=0
273 asm("cmpge r2, r1 "); // if so, check maxlength>=length
274 asm("orrge r1, r1, #0x30000000 "); // r1=length + EBuf
275 asm("stmgeia r0, {r1,r2} "); // store length/type and maxlength fields
278 asm("bmi " CSM_Z27Des16PanicMaxLengthNegativev);
279 asm("b " CSM_Z26Des16PanicLengthOutOfRangev);
282 #ifdef __DES16_MACHINE_CODED_HWORD__
283 __NAKED__ EXPORT_C TBufBase16::TBufBase16(const TUint16* /*aString*/, TInt /*aMaxLength*/)
285 asm("mov r12, r1, lsr #1 "); // save aString pointer (lose bottom bit which should be 0)
287 asm("ldrh r3, [r1], #2 ");
289 asm("bne 1b "); // loop until we reach zero terminator
290 asm("rsb r3, r12, r1, lsr #1 "); // r3 = length + 1
291 asm("sub r3, r3, #1 "); // r3 = length
292 asm("cmp r3, r2 "); // compare to max length
293 asm("bgt Des16PanicLengthOutOfRange__Fv "); // length too big, so panic
294 asm("orr r1, r3, #0x30000000 "); // if length<=max, r1=EBuf + length
295 asm("stmfd sp!, {r0, lr} "); // save registers for function call
296 asm("stmia r0!, {r1, r2} "); // store type/length and max length fields, r0->buffer
297 asm("mov r2, r3, lsl #1 "); // r2=Size()
298 asm("mov r1, r12, lsl #1 "); // r1=aString
299 asm("bl memmove "); // call memmove
304 __NAKED__ EXPORT_C TBufBase16::TBufBase16(const TDesC16& /*aDes*/, TInt /*aMaxLength*/)
306 asm("ldr r3, [r1], #4 "); // r3 = type/length
307 asm("bic r12, r3, #0xF0000000"); // r12 = length
308 asm("cmp r12, r2 "); // compare with maxlength
309 asm("bgt " CSM_Z26Des16PanicLengthOutOfRangev);
310 asm("cmp r3, #0x50000000 ");
311 asm("bcs " CSM_Z20Des16PanicBadDesTypev);
312 asm("eor r3, r3, r3, lsr #1 ");
313 asm("msr cpsr_flg, r3 ");
314 asm("addcs r1, r1, #4 ");
315 asm("ldrle r1, [r1] ");
316 asm("addeq r1, r1, #4 "); // r1 = aDes.Ptr()
317 asm("stmfd sp!, {r0,lr} "); // save registers for function call
318 asm("orr r3, r12, #0x30000000 "); // add EBuf type field
319 asm("str r3, [r0], #4 "); // store length/type, r0->max length
320 asm("str r2, [r0], #4 "); // store max length, r0->buffer
321 asm("mov r2, r12, lsl #1 "); // Size() into r2 for function call
322 asm("bl memmove "); // call memmove
327 __NAKED__ EXPORT_C void TDes16::SetLength(TInt /*aLength*/)
329 // Set the length of the descriptor, checking the length is O.K.
332 asm("ldmia r0, {r2,r3} "); // r2=length/type, r3=maxlength
333 asm("cmp r1, r3 "); // check aLength against maxlength and for -ve values
334 asm("bhi " CSM_Z21Des16PanicDesOverflowv);
335 asm("and r2, r2, #0xF0000000 "); // r2=type field
336 asm("cmp r2, #0x40000000 "); // check for EBufCPtr
337 asm("orr r2, r2, r1 "); // r2=type + new length
338 asm("str r2, [r0] "); // store new length
340 asm("ldr r2, [r0, #8] "); // r2=pointer to TBufCBase
341 asm("str r1, [r2] "); // update length of TBufCBase
345 __NAKED__ EXPORT_C void TDes16::SetMax()
347 // Set the length to MaxLength().
350 asm("ldmia r0, {r1,r2} "); // r1=length/type, r2=maxlength
351 asm("and r1, r1, #0xF0000000 "); // r1=type field
352 asm("cmp r1, #0x40000000 "); // check for EBufCPtr
353 asm("orr r1, r1, r2 "); // r1=type field + maxlength
354 asm("str r1, [r0] "); // store new length
356 asm("ldr r1, [r0, #8] "); // r1 = pointer to TBufCBase
357 asm("str r2, [r1] "); // update length of TBufCBase
361 #ifdef __DES16_MACHINE_CODED_HWORD__
362 __NAKED__ EXPORT_C void TDes16::Copy(const TUint16* /*aString*/)
364 // Copy a string to this descriptor.
367 asm("sub r2, r1, #2 "); // r2=aString-2
369 asm("ldrh r3, [r2, #2]! ");
371 asm("bne 1b "); // loop until zero terminator reached
372 asm("sub r2, r2, r1 "); // r2=2*length of string
373 asm("mov r2, r2, lsr #1 "); // r2=length of string
374 asm("ldmia r0, {r3,r12} "); // r3=type/length of this, r12=maxlength
375 asm("cmp r2, r12 "); // compare new length against maxlength
376 asm("bgt Des16PanicDesOverflow__Fv ");
377 asm("cmp r3, #0x50000000 ");
378 asm("bcs Des16PanicBadDesType__Fv ");
379 asm("and r3, r3, #0xF0000000 "); // r3=type of this
380 asm("orr r3, r3, r2 "); // r3=new type/length
381 asm("str r3, [r0], #4 "); // store it
382 asm("eor r3, r3, r3, lsr #1 ");
383 asm("msr cpsr_flg, r3 ");
384 asm("addcs r0, r0, #4 ");
385 asm("ldrle r0, [r0] ");
386 asm("streq r2, [r0], #4 "); // if EBufCPtr, update length of TBufCBase, r0=Ptr()
387 asm("add r2, r2, r2 "); // r2=size=2*length
388 asm("b memmove "); // call memmove
392 __NAKED__ EXPORT_C void TDes16::Copy(const TUint16* /*aBuf*/,TInt /*aLength*/)
394 // Copy the aLength characters to the descriptor.
397 asm("ldmia r0, {r3,r12} "); // r3=type/length of this, r12=maxlength
398 asm("cmp r2, r12 "); // compare new length against maxlength
399 asm("bhi " CSM_Z21Des16PanicDesOverflowv); // Des16Panic if >MaxLength or -ve
400 asm("cmp r3, #0x50000000 ");
401 asm("bcs " CSM_Z20Des16PanicBadDesTypev);
402 asm("and r3, r3, #0xF0000000 "); // r3=type of this
403 asm("orr r3, r3, r2 "); // r3=new type/length
404 asm("str r3, [r0], #4 "); // store it
405 asm("eor r3, r3, r3, lsr #1 ");
406 asm("msr cpsr_flg, r3 ");
407 asm("addcs r0, r0, #4 ");
408 asm("ldrle r0, [r0] ");
409 asm("streq r2, [r0], #4 "); // if EBufCPtr, update length of TBufCBase, r0=Ptr()
410 asm("add r2, r2, r2 "); // r2=size=2*length
411 asm("b memmove "); // call memmove
414 __NAKED__ EXPORT_C void TDes16::Copy(const TDesC16& /*aDes*/)
416 // Copy a descriptor to this descriptor.
419 asm("ldr r3, [r1], #4 "); // r3 = type/length of aDes
420 asm("bic r12, r3, #0xF0000000"); // r12 = aDes.length
421 asm("ldr r2, [r0, #4] "); // r2=this.maxlength
422 asm("cmp r12, r2 "); // compare with maxlength
423 asm("bgt " CSM_Z21Des16PanicDesOverflowv);
424 asm("ldr r2, [r0] "); // get type of this
425 asm("cmp r2, #0x50000000 "); // check both descriptor types
426 asm("cmpcc r3, #0x50000000 ");
427 asm("bcs " CSM_Z20Des16PanicBadDesTypev);
428 asm("and r2, r2, #0xF0000000 ");
429 asm("orr r2, r12, r2 "); // r2=new type/length of this
430 asm("str r2, [r0], #4 "); // store it
431 asm("eor r3, r3, r3, lsr #1 ");
432 asm("msr cpsr_flg, r3 ");
433 asm("addcs r1, r1, #4 ");
434 asm("ldrle r1, [r1] ");
435 asm("addeq r1, r1, #4 "); // r1 = aDes.Ptr()
436 asm("eor r2, r2, r2, lsr #1 ");
437 asm("msr cpsr_flg, r2 ");
438 asm("addcs r0, r0, #4 ");
439 asm("ldrle r0, [r0] ");
440 asm("streq r12, [r0], #4 "); // if EBufCPtr, update length of TBufCBase, r0=Ptr()
441 asm("add r2, r12, r12 "); // size=2*length into r2 for function call
442 asm("b memmove "); // call memmove
445 __NAKED__ EXPORT_C TPtr16 TDes16::LeftTPtr(TInt /*aLength*/) const
447 // Extract the left portion of the descriptor.
450 // On entry r0=return store ptr, r1=this, r2=aLength
451 // Return TPtr8 ([r0]=length/type,[r0,#4]=maxLength,[r0,#8]=Ptr)
452 asm("ldr r3, [r1], #4 "); // r3=this.length/type
453 asm("cmp r2, #0 "); // check aLength>=0
454 asm("blt Des16PanicPosOutOfRange__Fv "); // if not, panic
455 asm("bic r12, r3, #0xF0000000 "); // r12=this.Length()
456 asm("cmp r2, r12 "); // else limit aLength to Length()
457 asm("movgt r2, r12 ");
458 asm("cmp r3, #0x50000000 ");
459 asm("bcs Des16PanicBadDesType__Fv ");
460 asm("eor r3, r3, r3, lsr #1 ");
461 asm("msr cpsr_flg, r3 ");
462 asm("addcs r1, r1, #4 ");
463 asm("ldrle r1, [r1] ");
464 asm("addeq r1, r1, #4 "); // r1=this.Ptr()
465 asm("mov r3, r1 "); // r3=this.Ptr()
466 asm("orr r1, r2, #0x20000000 "); // r1=aLength + EPtr
467 asm("stmia r0, {r1-r3} ");
471 __NAKED__ EXPORT_C TPtr16 TDes16::RightTPtr(TInt /*aLength*/) const
473 // Extract the right portion of the descriptor.
476 // On entry r0=return store ptr, r1=this, r2=aLength
477 // Return TPtr8 ([r0]=length/type,[r0,#4]=maxLength,[r0,#8]=Ptr)
478 asm("ldr r3, [r1], #4 "); // r3=this.length/type
479 asm("cmp r2, #0 "); // check aLength>=0
480 asm("blt Des16PanicPosOutOfRange__Fv "); // if not, panic
481 asm("bic r12, r3, #0xF0000000 "); // r12=this.Length()
482 asm("cmp r2, r12 "); // else limit aLength to Length()
483 asm("movgt r2, r12 ");
484 asm("cmp r3, #0x50000000 ");
485 asm("bcs Des16PanicBadDesType__Fv ");
486 asm("eor r3, r3, r3, lsr #1 ");
487 asm("msr cpsr_flg, r3 ");
488 asm("addcs r1, r1, #4 ");
489 asm("ldrle r1, [r1] ");
490 asm("addeq r1, r1, #4 "); // r0=this.Ptr()
491 asm("add r3, r1, r12, lsl #1 "); // r3=this.Ptr()+len*2
492 asm("orr r1, r2, #0x20000000 "); // r1=aLength + EPtr
493 asm("sub r3, r3, r2, lsl #1 "); // r2=Ptr()+len*2-aLength*2
494 asm("stmia r0, {r1-r3} ");
498 __NAKED__ EXPORT_C TPtr16 TDes16::MidTPtr(TInt /*aPos*/) const
500 // Extract the middle portion of the descriptor.
503 // On entry r0=return store ptr, r1=this, r2=aPos
504 // Return TPtr8 ([r0]=length/type,[r0,#4]=maxLength,[r0,#8]=Ptr)
505 asm("ldr r3, [r1], #4 "); // r3=this.length/type
506 asm("bic r12, r3, #0xF0000000 "); // r12=this.Length()
507 asm("cmp r2, #0 "); // check aPos>=0
508 asm("cmpge r12, r2 "); // if so check Length()>=aPos
509 asm("blt Des16PanicPosOutOfRange__Fv ");
510 asm("cmp r3, #0x50000000 ");
511 asm("bcs Des16PanicBadDesType__Fv ");
512 asm("eor r3, r3, r3, lsr #1 ");
513 asm("msr cpsr_flg, r3 ");
514 asm("addcs r1, r1, #4 ");
515 asm("ldrle r1, [r1] ");
516 asm("addeq r1, r1, #4 "); // r0=this.Ptr()
517 asm("add r3, r1, r2, lsl #1 "); // r3=this.Ptr()+aPos*2
518 asm("sub r2, r12, r2 "); // r2=len-aPos (=newMaxLen)
519 asm("orr r1, r2, #0x20000000 "); // r1=len-aPos + EPtr (=newLen/Type)
520 asm("stmia r0, {r1-r3} ");
524 __NAKED__ EXPORT_C TPtr16 TDes16::MidTPtr(TInt /*aPos*/,TInt /*aLength*/) const
526 // Extract the middle portion of the descriptor.
529 // On entry r0=return store ptr, r1=this, r2=aPos, r3=aLength
530 // Return TPtr8 ([r0]=length/type,[r0,#4]=maxLength,[r0,#8]=Ptr)
531 asm("str r4, [sp, #-4]! "); // save r4
532 asm("ldr r12, [r1], #4 "); // r12=this.length/type
534 asm("cmp r12, #0x50000000 "); // check valid descriptor type
535 asm("bcs Des16PanicBadDesType__Fv ");
536 asm("eor r12, r12, r12, lsr #1 ");
537 asm("msr cpsr_flg, r12 ");
538 asm("ldr r12, [r1, #-4] ");
539 asm("addcs r4, r4, #4 ");
540 asm("ldrle r4, [r4] ");
541 asm("bic r12, r12, #0xF0000000 "); // r12=Length()
542 asm("addeq r4, r4, #4 "); // r4=this.Ptr()
543 asm("cmp r2, #0 "); // check aPos>=0
544 asm("subge r12, r12, r2 "); // if so, r12=Length()-aPos
545 asm("cmpge r12, r3 "); // and check Length()-aPos>=aLength
546 asm("orrge r1, r3, #0x20000000 "); // if so, r0 = aLength + EPtr
547 asm("addge r3, r4, r2, lsl #1 "); // and r2=this.Ptr()+aPos*2
548 asm("bicge r2, r1, #0xF0000000 "); // and r1=aLength
549 asm("stmgeia r0, {r1-r3} ");
550 asm("ldrge r4, [sp], #4 ");
552 asm("b Des16PanicPosOutOfRange__Fv ");
555 __NAKED__ EXPORT_C const TUint16& TDesC16::AtC(TInt /*anIndex*/) const
557 // Return a reference to the character in the buffer.
560 asm("ldr r2, [r0], #4 "); // r2=length/type
561 asm("bic r3, r2, #0xF0000000 "); // r3=length
562 asm("cmp r2, #0x50000000 ");
563 asm("bcs " CSM_Z20Des16PanicBadDesTypev);
564 asm("eor r2, r2, r2, lsr #1 ");
565 asm("msr cpsr_flg, r2 ");
566 asm("addcs r0, r0, #4 ");
567 asm("ldrle r0, [r0] ");
568 asm("addeq r0, r0, #4 "); // r0=this.Ptr()
569 asm("cmp r1, #0 "); // check index>=0
570 asm("cmpge r3, r1 "); // if so, check Length()>index
571 asm("addgt r0, r0, r1, lsl #1 "); // return value = this.Ptr()+index*2
573 asm("b " CSM_Z28Des16PanicDesIndexOutOfRangev);
576 #ifdef __DES16_MACHINE_CODED_HWORD__
577 __NAKED__ EXPORT_C TInt TDesC16::Locate(TChar /*aChar*/) const
579 // Locate character aChar in the descriptor.
582 asm("ldr r2, [r0], #4 "); // r2=length/type
583 asm("cmp r2, #0x50000000 ");
584 asm("bcs Des16PanicBadDesType__Fv ");
585 asm("bics r3, r2, #0xF0000000 "); // r3=length
586 asm("mvneq r0, #0 "); // if length=0, not found
588 asm("eor r2, r2, r2, lsr #1 ");
589 asm("msr cpsr_flg, r2 ");
590 asm("addcs r0, r0, #4 ");
591 asm("ldrle r0, [r0] ");
592 asm("addeq r0, r0, #4 "); // r0=this.Ptr()
593 asm("add r3, r0, r3, lsl #1 "); // r3=ptr+length*2 (end of string pointer)
594 asm("add r12, r0, #2 "); // r12=ptr+2
596 asm("ldrh r2, [r0], #2 "); // r2=*r0++
597 asm("cmp r1, r2 "); // is r1=match char?
598 asm("cmpne r0, r3 "); // if not, is r0=r3 (end pointer)
600 asm("cmp r1, r2 "); // did we find char?
601 asm("subeq r0, r0, r12 "); // if we did, return value = r0-ptr-2
602 asm("moveq r0, r0, lsr #1 "); // divide by 2 to get index
603 asm("mvnne r0, #0 "); // else return value =-1
607 __NAKED__ EXPORT_C TInt TDesC16::LocateReverse(TChar /*aChar*/) const
609 // Locate character aChar in the descriptor in reverse.
612 asm("ldr r2, [r0], #4 "); // r2=length/type
613 asm("cmp r2, #0x50000000 ");
614 asm("bcs Des16PanicBadDesType__Fv ");
615 asm("bics r3, r2, #0xF0000000 "); // r3=length
616 asm("mvneq r0, #0 "); // if length=0, not found
618 asm("eor r2, r2, r2, lsr #1 ");
619 asm("msr cpsr_flg, r2 ");
620 asm("addcs r0, r0, #4 ");
621 asm("ldrle r0, [r0] ");
622 asm("addeq r0, r0, #4 "); // r0=this.Ptr()
623 asm("add r3, r0, r3, lsl #1 "); // r3=Ptr()+Length()
625 asm("ldrh r2, [r3, #-2]! "); // r2=*--r3
626 asm("cmp r1, r2 "); // is r1=match char?
627 asm("cmpne r3, r0 "); // if not, have we reached beginning of string?
628 asm("bne 1b "); // loop if neither
629 asm("cmp r1, r2 "); // did we find match char?
630 asm("subeq r0, r3, r0 "); // if we did, return value = (r3-r0)/2
631 asm("moveq r0, r0, lsr #1 ");
632 asm("mvnne r0, #0 "); // else return value =-1
637 #ifndef __KERNEL_MODE__
638 __NAKED__ EXPORT_C TInt TDesC16::CompareF(const TDesC16& /*aDes*/) const
640 // Compare a descriptor to this descriptor folded.
644 asm("b comparebody ");
646 asm(".word " CSM_ZN3Mem8CompareFEPKtiS0_i);
649 __NAKED__ EXPORT_C TInt TDesC16::CompareC(const TDesC16& /*aDes*/) const
651 // Compare a descriptor to this descriptor collated.
655 asm("b comparebody ");
657 asm(".word " CSM_ZN3Mem8CompareCEPKtiS0_i);
661 __NAKED__ EXPORT_C TInt TDesC16::Compare(const TDesC16& /*aDes*/) const
663 // Compare a descriptor to this descriptor.
667 asm("comparebody: ");
668 asm("mov r2, r1 "); // r2=&aDes
669 asm("ldr r3, [r0], #4 "); // r3=this.length/type
670 asm("cmp r3, #0x50000000 ");
671 asm("bcs " CSM_Z20Des16PanicBadDesTypev);
672 asm("bic r1, r3, #0xF0000000 "); // r1=this.Length()
673 asm("eor r3, r3, r3, lsr #1 ");
674 asm("msr cpsr_flg, r3 ");
675 asm("addcs r0, r0, #4 ");
676 asm("ldrle r0, [r0] ");
677 asm("addeq r0, r0, #4 "); // r0=this.Ptr()
678 asm("ldr r3, [r2], #4 "); // r3=aDes.length/type
679 asm("cmp r3, #0x50000000 ");
680 asm("bcs " CSM_Z20Des16PanicBadDesTypev);
681 asm("eor r3, r3, r3, lsr #1 ");
682 asm("msr cpsr_flg, r3 ");
683 asm("ldr r3, [r2, #-4] ");
684 asm("bic r3, r3, #0xF0000000 "); // r3=aDes.Length()
685 asm("addcs r2, r2, #4 ");
686 asm("ldrle r2, [r2] ");
687 asm("addeq r2, r2, #4 "); // r2=aDes.Ptr()
688 #ifdef __KERNEL_MODE__
689 asm("add r1, r1, r1 ");
690 asm("add r3, r3, r3 ");
695 #ifdef __KERNEL_MODE__
696 asm(".word memcompare ");
698 asm(".word " CSM_ZN3Mem7CompareEPKtiS0_i);
701 #endif // __DES16_MACHINE_CODED__
704 #if defined(__DES16_MACHINE_CODED__) && !defined(__EABI__)
705 __NAKED__ EXPORT_C TPtrC16 TDesC16::Left(TInt /*aLength*/) const
707 // Extract the left portion of the descriptor.
710 // On entry r0=this, r1=aLength
711 // Return TPtrC16 in r0,r1
712 asm("ldr r3, [r0], #4 "); // r3=this.length/type
713 asm("bic r12, r3, #0xF0000000 "); // r12=this.Length()
714 asm("cmp r1, #0 "); // check aLength>=0
715 asm("blt " CSM_Z23Des16PanicPosOutOfRangev); // if not, panic
716 asm("cmp r1, r12 "); // else limit aLength to Length()
717 asm("movgt r1, r12 ");
718 asm("cmp r3, #0x50000000 ");
719 asm("bcs " CSM_Z20Des16PanicBadDesTypev);
720 asm("eor r3, r3, r3, lsr #1 ");
721 asm("msr cpsr_flg, r3 ");
722 asm("addcs r0, r0, #4 ");
723 asm("ldrle r0, [r0] ");
724 asm("addeq r0, r0, #4 "); // r0=this.Ptr()
725 asm("orr r2, r1, #0x10000000 "); // r2=aLength + EPtrC
726 asm("mov r1, r0 "); // r1=result ptr
727 asm("mov r0, r2 "); // r0=result type/length
731 __NAKED__ EXPORT_C TPtrC16 TDesC16::Right(TInt /*aLength*/) const
733 // Extract the right portion of the descriptor.
736 // On entry r0=this, r1=aLength
737 // Return TPtrC16 in r0,r1
738 asm("ldr r3, [r0], #4 "); // r3=this.length/type
739 asm("bic r12, r3, #0xF0000000 "); // r12=this.Length()
740 asm("cmp r1, #0 "); // check aLength>=0
741 asm("blt " CSM_Z23Des16PanicPosOutOfRangev); // if not, panic
742 asm("cmp r1, r12 "); // else limit aLength to Length()
743 asm("movgt r1, r12 ");
744 asm("cmp r3, #0x50000000 ");
745 asm("bcs " CSM_Z20Des16PanicBadDesTypev);
746 asm("eor r3, r3, r3, lsr #1 ");
747 asm("msr cpsr_flg, r3 ");
748 asm("addcs r0, r0, #4 ");
749 asm("ldrle r0, [r0] ");
750 asm("addeq r0, r0, #4 "); // r0=this.Ptr()
751 asm("add r3, r0, r12, lsl #1 "); // r3=this.Ptr()+len*2
752 asm("orr r0, r1, #0x10000000 "); // r0=aLength + EPtrC
753 asm("sub r1, r3, r1, lsl #1 "); // r1=Ptr()+len*2-aLength*2
757 __NAKED__ EXPORT_C TPtrC16 TDesC16::Mid(TInt /*aPos*/) const
759 // Extract the middle portion of the descriptor.
762 // On entry r0=this, r1=aPos
763 // Return TPtrC16 in r0,r1
764 asm("ldr r3, [r0], #4 "); // r3=this.length/type
765 asm("bic r12, r3, #0xF0000000 "); // r12=this.Length()
766 asm("cmp r1, #0 "); // check aPos>=0
767 asm("cmpge r12, r1 "); // if so check Length()>=aPos
768 asm("blt " CSM_Z23Des16PanicPosOutOfRangev);
769 asm("cmp r3, #0x50000000 ");
770 asm("bcs " CSM_Z20Des16PanicBadDesTypev);
771 asm("eor r3, r3, r3, lsr #1 ");
772 asm("msr cpsr_flg, r3 ");
773 asm("addcs r0, r0, #4 ");
774 asm("ldrle r0, [r0] ");
775 asm("addeq r0, r0, #4 "); // r0=this.Ptr()
776 asm("sub r2, r12, r1 "); // r2=len-aPos
777 asm("add r1, r0, r1, lsl #1 "); // r1=this.Ptr()+aPos*2
778 asm("orr r0, r2, #0x10000000 "); // r0=result length + EPtrC
782 __NAKED__ EXPORT_C TPtrC16 TDesC16::Mid(TInt /*aPos*/,TInt /*aLength*/) const
784 // Extract the middle portion of the descriptor.
787 // On entry r0=this, r1=aPos, r2=aLength
788 // Return TPtrC16 in r0,r1
789 asm("ldr r12, [r0], #4 "); // r12=this.length/type
790 asm("cmp r12, #0x50000000 "); // check valid descriptor type
791 asm("bcs " CSM_Z20Des16PanicBadDesTypev);
792 asm("eor r12, r12, r12, lsr #1 ");
793 asm("msr cpsr_flg, r12 ");
794 asm("ldr r12, [r0, #-4] ");
795 asm("bic r12, r12, #0xF0000000 "); // r12=Length()
796 asm("addcs r0, r0, #4 ");
797 asm("ldrle r0, [r0] ");
798 asm("addeq r0, r0, #4 "); // r0=this.Ptr()
799 asm("cmp r1, #0 "); // check aPos>=0
800 asm("subge r12, r12, r1 "); // if so, r12=Length()-aPos
801 asm("cmpge r12, r2 "); // and check Length()-aPos>=aLength
802 asm("addge r1, r0, r1, lsl #1 "); // if so, r1=Ptr()+aPos*2
803 asm("orrge r0, r2, #0x10000000 "); // and r0 = aLength + EPtrC
805 asm("b " CSM_Z23Des16PanicPosOutOfRangev);
807 #endif // defined(__DES16_MACHINE_CODED__) && !defined(__EABI__)
810 #ifdef __DES16_MACHINE_CODED__
812 // Here are the __EABI__ compliant versions of the above
814 __NAKED__ EXPORT_C TPtrC16 TDesC16::Left(TInt /*aLength*/) const
816 // Extract the left portion of the descriptor.
819 // On entry r0=return store ptr, r1=this, r2=aLength
820 // Return TPtr16 ([r0]=length/type,[r0,#4]=Ptr)
821 asm("ldr r3, [r1], #4 "); // r3=this.length/type
822 asm("cmp r2, #0 "); // check aLength>=0
823 asm("blt Des16PanicPosOutOfRange__Fv "); // if not, panic
824 asm("bic r12, r3, #0xF0000000 "); // r12=this.Length()
825 asm("cmp r2, r12 "); // else limit aLength to Length()
826 asm("movgt r2, r12 ");
827 asm("cmp r3, #0x50000000 ");
828 asm("bcs Des16PanicBadDesType__Fv ");
829 asm("eor r3, r3, r3, lsr #1 ");
830 asm("msr cpsr_flg, r3 ");
831 asm("addcs r1, r1, #4 ");
832 asm("ldrle r1, [r1] ");
833 asm("addeq r1, r1, #4 "); // r1=this.Ptr()
834 asm("mov r3, r1"); // r3=this.Ptr()
835 asm("orr r1, r2, #0x10000000 "); // r1=aLength + EPtrC
836 asm("stmia r0, {r1,r3} ");
840 __NAKED__ EXPORT_C TPtrC16 TDesC16::Right(TInt /*aLength*/) const
842 // Extract the right portion of the descriptor.
845 // On entry r0=return store ptr, r1=this, r2=aLength
846 // Return TPtr16 ([r0]=length/type,[r0,#4]=Ptr)
847 asm("ldr r3, [r1], #4 "); // r3=this.length/type
848 asm("cmp r2, #0 "); // check aLength>=0
849 asm("blt Des16PanicPosOutOfRange__Fv "); // if not, panic
850 asm("bic r12, r3, #0xF0000000 "); // r12=this.Length()
851 asm("cmp r2, r12 "); // else limit aLength to Length()
852 asm("movgt r2, r12 ");
853 asm("cmp r3, #0x50000000 ");
854 asm("bcs Des16PanicBadDesType__Fv ");
855 asm("eor r3, r3, r3, lsr #1 ");
856 asm("msr cpsr_flg, r3 ");
857 asm("addcs r1, r1, #4 ");
858 asm("ldrle r1, [r1] ");
859 asm("addeq r1, r1, #4 "); // r1=this.Ptr()
860 asm("add r3, r1, r12, lsl #1 "); // r3=this.Ptr()+len*2
861 asm("orr r1, r2, #0x10000000 "); // r1=aLength + EPtrC
862 asm("sub r3, r3, r2, lsl #1 "); // r2=Ptr()+len*2-aLength*2
863 asm("stmia r0, {r1,r3} ");
867 __NAKED__ EXPORT_C TPtrC16 TDesC16::Mid(TInt /*aPos*/) const
869 // Extract the middle portion of the descriptor.
872 // On entry r0=return store ptr, r1=this, r2=aPos
873 // Return TPtr16 ([r0]=length/type,[r0,#4]=Ptr)
874 asm("ldr r3, [r1], #4 "); // r3=this.length/type
875 asm("bic r12, r3, #0xF0000000 "); // r12=this.Length()
876 asm("cmp r2, #0 "); // check aPos>=0
877 asm("cmpge r12, r2 "); // if so check Length()>=aPos
878 asm("blt Des16PanicPosOutOfRange__Fv ");
879 asm("cmp r3, #0x50000000 ");
880 asm("bcs Des16PanicBadDesType__Fv ");
881 asm("eor r3, r3, r3, lsr #1 ");
882 asm("msr cpsr_flg, r3 ");
883 asm("addcs r1, r1, #4 ");
884 asm("ldrle r1, [r1] ");
885 asm("addeq r1, r1, #4 "); // r3=this.Ptr()
886 asm("add r3, r1, r2, lsl #1 "); // r3=this.Ptr()+aPos*2
887 asm("sub r2, r12, r2 "); // r2=len-aPos (=newMaxLen)
888 asm("orr r1, r2, #0x10000000 "); // r1=len-aPos + EPtrC (=newLen/Type)
889 asm("stmia r0, {r1,r3} ");
893 __NAKED__ EXPORT_C TPtrC16 TDesC16::Mid(TInt /*aPos*/,TInt /*aLength*/) const
895 // Extract the middle portion of the descriptor.
898 // On entry r0=return store ptr, r1=this, r2=aPos, r3=aLength
899 // Return TPtr16 ([r0]=length/type,[r0,#4]=Ptr)
900 asm("ldr r12, [r1], #4 "); // r12=this.length/type
901 asm("cmp r12, #0x50000000 "); // check valid descriptor type
902 asm("bcs Des16PanicBadDesType__Fv ");
903 asm("eor r12, r12, r12, lsr #1 ");
904 asm("msr cpsr_flg, r12 ");
905 asm("ldr r12, [r1, #-4] ");
906 asm("addcs r1, r1, #4 ");
907 asm("ldrle r1, [r1] ");
908 asm("bic r12, r12, #0xF0000000 "); // r12=Length()
909 asm("addeq r1, r1, #4 "); // r1=this.Ptr()
910 asm("cmp r2, #0 "); // check aPos>=0
911 asm("subge r12, r12, r2 "); // if so, r12=Length()-aPos
912 asm("cmpge r12, r3 "); // and check Length()-aPos>=aLength
913 asm("addge r2, r1, r2, lsl #1 "); // if so r2=this.Ptr()+aPos*2
914 asm("orrge r1, r3, #0x10000000 "); // and r1 = aLength + EPtrC
915 asm("stmgeia r0, {r1,r2} ");
917 asm("b Des16PanicPosOutOfRange__Fv ");
922 __NAKED__ EXPORT_C void TDes16::Zero()
927 asm("ldr r1, [r0] "); // r1=length/type
928 asm("and r1, r1, #0xF0000000 "); // r1=type field, zero length
929 asm("cmp r1, #0x40000000 "); // check for EBufCPtr
930 asm("str r1, [r0] "); // store zero length
932 asm("ldr r2, [r0, #8] "); // r2 = pointer to TBufCBase
934 asm("str r1, [r2] "); // update length of TBufCBase
938 #ifdef __DES16_MACHINE_CODED_HWORD__
939 #ifndef __KERNEL_MODE__
940 __NAKED__ EXPORT_C void TDes16::ZeroTerminate()
942 // Zero terminate at Length().
945 // Fall though to PtrZ below...
948 __NAKED__ EXPORT_C const TUint16* TDes16::PtrZ()
950 // Return a pointer to a 0 terminated string.
953 asm("ldmia r0, {r1,r2} "); // r1=length/type, r2=maxlength
954 asm("bic r3, r1, #0xF0000000 "); // r3=Length();
955 asm("cmp r3, r2 "); // check Length()<MaxLength()
956 asm("bge Des16PanicDesOverflow__Fv ");
957 asm("cmp r1, #0x50000000 ");
958 asm("bcs Des16PanicBadDesType__Fv ");
959 asm("eor r1, r1, r1, lsr #1 ");
960 asm("msr cpsr_flg, r1 ");
961 asm("add r0, r0, #4 ");
962 asm("addcs r0, r0, #4 ");
963 asm("ldrle r0, [r0] ");
964 asm("addeq r0, r0, #4 "); // r0=Ptr()
965 asm("add r1, r0, r3, lsl #1 "); // r1=Ptr()+Length()
967 asm("strh r2, [r1] "); // Ptr()[Length()]=0;
970 #endif // __KERNEL_MODE__
972 __NAKED__ EXPORT_C void TDes16::Append(TChar /*aChar*/)
974 // Add a character at the end of the string.
977 asm("ldmia r0, {r2,r3} "); // r2=length/type, r3=maxlength
978 asm("bic r12, r2, #0xF0000000 "); // r12=Length();
979 asm("cmp r12, r3 "); // check Length()<MaxLength()
980 asm("bge Des16PanicDesOverflow__Fv ");
981 asm("cmp r2, #0x50000000 ");
982 asm("bcs Des16PanicBadDesType__Fv ");
983 asm("add r2, r2, #1 "); // increment length by 1
984 asm("str r2, [r0] "); // store new length
985 asm("eor r2, r2, r2, lsr #1 ");
986 asm("msr cpsr_flg, r2 ");
987 asm("add r2, r0, #4 "); // r2=this+4
988 asm("addcs r2, r2, #4 ");
989 asm("ldrle r2, [r2] ");
990 asm("addeq r3, r12, #1 "); // if EBufCPtr, r3=Length()+1
991 asm("streq r3, [r2], #4 "); // and update length of TBufCBase, r2=Ptr()
992 asm("add r2, r2, r12, lsl #1 "); // r2=Ptr()+Length()
993 asm("strh r1, [r2] "); // Ptr()[Length()]=aChar;
998 __NAKED__ EXPORT_C void TDes16::Append(const TDesC16& /*aDes*/)
1000 // Append a descriptor to this descriptor.
1003 asm("ldr r3, [r1], #4 "); // r3=aDes.length/type
1004 asm("cmp r3, #0x50000000 ");
1005 asm("bcs " CSM_Z20Des16PanicBadDesTypev);
1006 asm("bics r2, r3, #0xF0000000 "); // r2=aDes.Length()
1008 asm("eor r3, r3, r3, lsr #1 ");
1009 asm("msr cpsr_flg, r3 ");
1010 asm("addcs r1, r1, #4 ");
1011 asm("ldrle r1, [r1] ");
1012 asm("addeq r1, r1, #4 "); // r1=aDes.Ptr()
1013 asm("b appendbody "); // use following routine for rest of job
1016 __NAKED__ EXPORT_C void TDes16::Append(const TUint16* /*aBuf*/,TInt /*aLength*/)
1018 // Append aLength from aBuf characters to the descriptor.
1021 asm("cmp r2, #0 "); // check aLength>=0
1023 asm("blt " CSM_Z24Des16PanicLengthNegativev);
1024 asm("appendbody: ");
1025 asm("ldmia r0, {r3,r12} "); // r3=type/length, r12=maxlength
1026 asm("cmp r3, #0x50000000 ");
1027 asm("bcs " CSM_Z20Des16PanicBadDesTypev);
1028 asm("bic r3, r3, #0xF0000000 "); // r3=Length()
1029 asm("sub r12, r12, r3 "); // r12=MaxLength-Length
1030 asm("cmp r2, r12 "); // check aLength<=(MaxLength-Length)
1031 asm("bgt " CSM_Z21Des16PanicDesOverflowv);
1032 asm("ldr r12, [r0] ");
1033 asm("add r12, r12, r2 "); // new length/type field
1034 asm("str r12, [r0], #4 "); // store it
1035 asm("eor r12, r12, r12, lsr #1 ");
1036 asm("msr cpsr_flg, r12 ");
1037 asm("addcs r0, r0, #4 ");
1038 asm("ldrle r0, [r0] ");
1039 asm("ldreq r12, [r0] "); // fetch length from TBufCBase
1040 asm("addeq r12, r12, r2 "); // add aLength
1041 asm("streq r12, [r0], #4 "); // update length of TBufCBase, r0=Ptr()
1042 asm("add r0, r0, r3, lsl #1 "); // r0=Ptr()+Length()*2
1043 asm("add r2, r2, r2 "); // r2=aLength*2
1044 asm("b memmove "); // call memmove
1047 __NAKED__ EXPORT_C void TDes16::FillZ()
1049 // Fill the descriptor with 0.
1052 asm("ldr r2, [r0] "); // r2=length/type
1053 asm("cmp r2, #0x50000000 ");
1054 asm("bcs " CSM_Z20Des16PanicBadDesTypev);
1055 asm("bic r1, r2, #0xF0000000 "); // r1=Length()
1056 asm("eor r2, r2, r2, lsr #1 ");
1057 asm("msr cpsr_flg, r2 ");
1058 asm("add r0, r0, #4 ");
1059 asm("addcs r0, r0, #4 ");
1060 asm("ldrle r0, [r0] ");
1061 asm("addeq r0, r0, #4 "); // r0=Ptr()
1062 asm("add r1, r1, r1 "); // r1=2*Length()
1063 asm("b memclr "); // call memclr
1066 #ifdef __DES16_MACHINE_CODED_HWORD__
1067 __NAKED__ EXPORT_C void TDes16::Fill(TChar /*aChar*/)
1069 // Fill the descriptor with aChar.
1072 // on entry r0=this, r1=fill char
1073 asm("ldr r3, [r0] "); // r3=length/type
1074 asm("cmp r3, #0x50000000 ");
1075 asm("bcs Des16PanicBadDesType__Fv ");
1076 asm("bics r2, r3, #0xF0000000 "); // r2=Length()
1077 __JUMP(eq,lr); // if length is zero, finished
1078 asm("stmfd sp!, {r0,lr} "); // save registers for function call
1079 asm("eor r3, r3, r3, lsr #1 ");
1080 asm("msr cpsr_flg, r3 ");
1081 asm("add r0, r0, #4 ");
1082 asm("addcs r0, r0, #4 ");
1083 asm("ldrle r0, [r0] ");
1084 asm("addeq r0, r0, #4 "); // r0=Ptr()
1085 asm("tst r0, #2 "); // check alignment of Ptr()
1086 asm("strneh r1, [r0], #2 "); // if not aligned, fill first location
1087 asm("subne r2, r2, #1 "); // and decrement length
1088 asm("mov r1, r1, lsl #16 ");
1089 asm("orr r1, r1, r1, lsr #16 "); // r1=fill char repeated
1091 asm("mov r12, r1 ");
1092 asm("mov r14, r1 "); // r1=r3=r12=r14=fill char repeated
1093 asm("b 2f "); // branch to check for 16-char blocks
1095 asm("stmia r0!, {r1,r3,r12,r14} "); // fill a block of 16 bytes
1096 asm("stmia r0!, {r1,r3,r12,r14} "); // fill a block of 16 bytes
1098 asm("subs r2, r2, #16 "); // check for more blocks of 16
1099 asm("bge 1b "); // loop if more
1100 asm("add r2, r2, #16 "); // now r1=number of chars remaining, 0<=r1<16
1101 asm("mov r2, r2, lsl #28 "); // move into bits 28-31
1102 asm("msr cpsr_flg, r2 "); // and into NZCV flags
1103 asm("stmmiia r0!, {r1,r3,r12,r14} "); // fill a block of 16 bytes if needed
1104 asm("stmeqia r0!, {r1,r3} "); // fill a block of 8 bytes if needed
1105 asm("stmcsia r0!, {r1} "); // fill a block of 4 bytes if needed
1106 asm("strvsh r1, [r0], #2 "); // fill last char if needed
1111 #endif // __DES16_MACHINE_CODED__