Created
November 11, 2018 15:38
-
-
Save tuankiet65/319a3203a9af6839e5dcdf6c4c488405 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; eax = x / y | |
divide proc x: SDWORD, y: SDWORD | |
mov eax, x | |
cdq | |
idiv y | |
ret | |
divide endp | |
; eax = x % y | |
modulo proc x: SDWORD, y: SDWORD | |
invoke divide, x, y ; eax = (x // y) | |
mov edx, eax ; edx = (x // y) | |
imul edx, y ; edx = (x // y) * y | |
mov eax, x ; eax = x | |
sub eax, edx ; eax = x - ((x // y) * y) | |
ret | |
modulo endp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment