jserv / amacc

Small C Compiler generating ELF executable Arm architecture, supporting JIT execution
Other
1.01k stars 160 forks source link

Fix incorrect usage of modulo ABI #62

Closed lecopzer closed 4 years ago

lecopzer commented 4 years ago

Fixed #61

In AMaCC, we always assume r0 is where the return argument stored, however, the functions __aeabi_idivmod and __aeabi_uidivmod are 2-value-returning functions.

According to 'Run-time ABI for the ARM Architecture' with version 2.09 and section 4.3.1: The division functions take the numerator and denominator in that order, and produce the quotient in r0 or the quotient and the remainder in {r0, r1} respectively.

Hack the first instruction where the function returns with mov r1 to r0.