|
| 1 | +//***************************************************************************** |
| 2 | +// aeabi_romdiv_patch.s |
| 3 | +// - Provides "patch" versions of the aeabi integer divide functions to |
| 4 | +// replace the standard ones pulled in from the C library, which vector |
| 5 | +// integer divides onto the rom division functions contained in |
| 6 | +// specific NXP MCUs such as LPC11Uxx and LPC12xx. |
| 7 | +// - Note that this patching will only occur if "__USE_ROMDIVIDE" is |
| 8 | +// defined for the project build for both the compiler and assembler. |
| 9 | +//***************************************************************************** |
| 10 | +// |
| 11 | +// Copyright(C) NXP Semiconductors, 2013 |
| 12 | +// All rights reserved. |
| 13 | +// |
| 14 | +// Software that is described herein is for illustrative purposes only |
| 15 | +// which provides customers with programming information regarding the |
| 16 | +// LPC products. This software is supplied "AS IS" without any warranties of |
| 17 | +// any kind, and NXP Semiconductors and its licensor disclaim any and |
| 18 | +// all warranties, express or implied, including all implied warranties of |
| 19 | +// merchantability, fitness for a particular purpose and non-infringement of |
| 20 | +// intellectual property rights. NXP Semiconductors assumes no responsibility |
| 21 | +// or liability for the use of the software, conveys no license or rights under any |
| 22 | +// patent, copyright, mask work right, or any other intellectual property rights in |
| 23 | +// or to any products. NXP Semiconductors reserves the right to make changes |
| 24 | +// in the software without notification. NXP Semiconductors also makes no |
| 25 | +// representation or warranty that such application will be suitable for the |
| 26 | +// specified use without further testing or modification. |
| 27 | +// |
| 28 | +// Permission to use, copy, modify, and distribute this software and its |
| 29 | +// documentation is hereby granted, under NXP Semiconductors' and its |
| 30 | +// licensor's relevant copyrights in the software, without fee, provided that it |
| 31 | +// is used in conjunction with NXP Semiconductors microcontrollers. This |
| 32 | +// copyright, permission, and disclaimer notice must appear in all copies of |
| 33 | +// this code. |
| 34 | +//***************************************************************************** |
| 35 | +#if defined(__USE_ROMDIVIDE) |
| 36 | + |
| 37 | +// Note that the romdivide "divmod" functions are not actually called from |
| 38 | +// the below code, as these functions are actually just wrappers to the |
| 39 | +// main romdivide "div" functions which push the quotient and remainder onto |
| 40 | +// the stack, so as to be compatible with the way that C returns structures. |
| 41 | +// |
| 42 | +// This is not needed for the aeabi "divmod" functions, as the compiler |
| 43 | +// automatically generates code that handles the return values being passed |
| 44 | +// back in registers when it generates inline calls to __aeabi_idivmod and |
| 45 | +// __aeabi_uidivmod routines. |
| 46 | + |
| 47 | + .syntax unified |
| 48 | + .text |
| 49 | + |
| 50 | +// ========= __aeabi_idiv & __aeabi_idivmod ========= |
| 51 | + .align 2 |
| 52 | + .section .text.__aeabi_idiv |
| 53 | + |
| 54 | + .global __aeabi_idiv |
| 55 | + .set __aeabi_idivmod, __aeabi_idiv // make __aeabi_uidivmod an alias |
| 56 | + .global __aeabi_idivmod |
| 57 | + .global pDivRom_idiv // pointer to the romdivide 'idiv' functione |
| 58 | + .func |
| 59 | + .thumb_func |
| 60 | + .type __aeabi_idiv, %function |
| 61 | + |
| 62 | +__aeabi_idiv: |
| 63 | + push {r4, lr} |
| 64 | + ldr r3, =pDivRom_idiv |
| 65 | + ldr r3, [r3, #0] // Load address of function |
| 66 | + blx r3 // Call divide function |
| 67 | + pop {r4, pc} |
| 68 | + |
| 69 | + .endfunc |
| 70 | + |
| 71 | +// ======== __aeabi_uidiv & __aeabi_uidivmod ======== |
| 72 | + .align 2 |
| 73 | + |
| 74 | + .section .text.__aeabi_uidiv |
| 75 | + |
| 76 | + .global __aeabi_uidiv |
| 77 | + .set __aeabi_uidivmod, __aeabi_uidiv // make __aeabi_uidivmod an alias |
| 78 | + .global __aeabi_uidivmod |
| 79 | + .global pDivRom_uidiv // pointer to the romdivide 'uidiv' function |
| 80 | + .func |
| 81 | + .thumb_func |
| 82 | + .type __aeabi_uidiv, %function |
| 83 | + |
| 84 | +__aeabi_uidiv: |
| 85 | + push {r4, lr} |
| 86 | + ldr r3, =pDivRom_uidiv |
| 87 | + ldr r3, [r3, #0] // Load address of function |
| 88 | + blx r3 // Call divide function |
| 89 | + pop {r4, pc} |
| 90 | + |
| 91 | + .endfunc |
| 92 | + |
| 93 | +#endif // (__USE_ROMDIVIDE) |
0 commit comments