Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4198
  • Last Modified:

Modulo in assembly

How to implement modulo in ARM assembly???
0
Tom3333
Asked:
Tom3333
  • 3
  • 2
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
0
 
Tom3333Author Commented:
Hello DaveBaldwin i  mean to implement modulo with out use command MOD. Do you have any resources about this ?
0
 
Dave BaldwinFixer of ProblemsCommented:
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
 
Tom3333Author Commented:
Hello DaveBaldwin,
can you give the code or the pseudo-code for this???
0
 
Dave BaldwinFixer of ProblemsCommented:
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now