Solved

Modulo in assembly

Posted on 2011-03-03
5
3,050 Views
Last Modified: 2012-05-11
How to implement modulo in ARM assembly???
0
Comment
Question by:Tom3333
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 35034037
0
 

Author Comment

by:Tom3333
ID: 35034124
Hello DaveBaldwin i  mean to implement modulo with out use command MOD. Do you have any resources about this ?
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 35034185
The last time I saw a routine for that, they just subtracted the divisor until the result went negative and then they added it back once.
1
 

Author Comment

by:Tom3333
ID: 35089095
Hello DaveBaldwin,
can you give the code or the pseudo-code for this???
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 50 total points
ID: 35089609
Here's a little pseudo code.  This does not account for negative numbers as input.
; psuedo code...
mov a,dividend  ; the number to be divided
mov b,divisor   ; the number to divide by

loop:
sub a,b   ;subtract b from a
jmp positive, loop  ; do it again until the result is not positive

; if negative result, add it back Once
add a,b  ; and we're done

Open in new window

1

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Invest in your employees with these five simple steps to improve employee engagement and retention.
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question