Can anyone help with how to do a division and get a remainder in ASSEMBLY language not C using kwikstik K40? I try to use the instruction

.external div

BL div

I can not find any info on what registers are to be used to hold what values if using in assembly, so it crashes when it runs the function, but it does compile and call the function.

All i need to do is calculate a remainder after division like the following:

A0 = D1/10 // D1 being some number

D0 = D1 mod 10

but there is no modulo operation in the ARM K40 kwikstik so the only thing i found was to use the div() external function

It seems you are in a terrible rush, so let's start again (sorry):

First, from Wikipedia:

"In computing, the

modulooperation finds the remainder of division of one number by another."If you read carefully the second function written, (it is messy as resulted from listing):

udiv r3, r0, r1

mlsr0, r3, r1, r0

In two asm instruction you have the remainder: first instruction computes the quotient and the second (

nice, very powerful Cortex, thanks ARM) is multiply with subtract (a-nq, see the Wikipedia page) so the result in r0 is theremainder.This holds true if you really use unsigned parameters.ipa