Created
September 16, 2011 23:32
-
-
Save keiya/1223400 to your computer and use it in GitHub Desktop.
Multiplying without MUL
This file contains 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
.data | |
.align 4 | |
varx: .long 12 | |
vary: .long 3 | |
.text | |
.globl main | |
main: | |
mov (varx),%eax | |
mov (vary),%ebx | |
mov $0,%ecx | |
#; loop { | |
L1: | |
cmp $0,%ebx | |
jz END | |
#; if (LSb == 1) | |
#; then ONE1 | |
#; else ZER0 | |
shr $1,%ebx | |
jc ONE1 | |
jmp ZER0 | |
ZER0: | |
jmp LE1 | |
ONE1: | |
add %eax,%ecx | |
jmp LE1 | |
#; } end | |
LE1: | |
shl $1,%eax | |
jmp L1 | |
END: | |
call stop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment