flat assembler
Message board for the users of flat assembler.

 Index > Non-x86 architectures > [ARM] Math primitive SW needed for m0 from m3 UDIV and MLS
Author
cwpjr

Joined: 03 Jul 2012
Posts: 45
cwpjr
I completed a M3 project with much help from this forum. Thanks again.

Now I am tasked with porting to the M0 (NXP 1114).

So upfront I suck at math. That is what got me in microprocessors!

My port is stalled at commented out UDIV and MLS opcodes that don't exist in MO...

Any help including equivalent code to tutorials on how to do the math would be appreciated by me.

P.S. I hope Revolution is in good health and spirits and I am still scared to solve your puzzle!

_________________
Developing ARM Electronic Hobby Bench Stuff!
19 Feb 2013, 23:50
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 17666
revolution
For UDIV you could modify this ARM code for THUMB. Be careful about the size of the repeat loop, with thumb code you might need to check the output to see that you get what is expected with regard to instruction lengths:
Code:
divide_unsigned:
numerator equ r0
denominator equ r1
cmp     denominator,0
beq     .divide_by_0
subs    ip,numerator,denominator
blo     .smaller_than_1
cmp     ip,denominator
blo     .is_1
mov     r3,numerator
clz     ip,numerator
clz     r2,denominator
sub     ip,r2,ip
rsbs    ip,ip,31
addne   ip,ip,ip,lsl 1                  ;ip * 3
mov     r0,0
nop
.rotate = 32
while .rotate>0
.rotate = .rotate - 1
cmp     r3,denominator,lsl .rotate
subcs   r3,r3,denominator,lsl .rotate
end while
mov     r1,r3                           ;remainder
mov     pc,lr
.smaller_than_1:
mov     r1,numerator                    ;remainder
mov     r0,0                            ;result
mov     pc,lr
.is_1:
sub     r1,numerator,denominator        ;remainder
mov     r0,1                            ;result
mov     pc,lr
.divide_by_0:
mov     r1,numerator                    ;remainder
mov     r0,-1                           ;result = infinity
mov     pc,lr
For MLS it should be no difficulty to use two instructions; MUL then SUB. I can't see how that is causing a problem unless I misunderstand your description.
22 Feb 2013, 06:04
cwpjr

Joined: 03 Jul 2012
Posts: 45
cwpjr
This gets put in an interpreter wrapper so I should be able to test effectively. I also am blessed to have a black box model to check against.

Thanks so much!

Clyde
22 Feb 2013, 22:02
cwpjr

Joined: 03 Jul 2012
Posts: 45
cwpjr
I'm not familiar with what the ip is.
22 Feb 2013, 22:07
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum