Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .macro division number
- mov $0, %ecx
- loop_getremainders:
- mov $0, %edx
- mov number, %eax
- mov dividers(,%ecx,4), %ebx
- div %ebx
- mov %edx, remainders(,%ecx,4)
- inc %ecx
- cmp $5, %ecx
- jne loop_getremainders
- int $0x80
- .endm
- .section .data
- number: .long 158
- remainders: .long 0,0,0,0,0
- dividers: .long 7,15,31,127,8192
- .section .text
- .global _start
- _start:
- division number
- mov $1, %eax
- mov $0, %ebx
- int $0x80
- xor %eax, %eax # accumulator
- movl $5, %edx # counter
- loop_shift:
- movb shifts(%edx), %cl # the shift amount
- movl remainders(, %edx, 4), %ebx # next remainder
- shrd %cl, %ebx, %eax # shift in the bits
- subl $1, %edx
- jnc loop_shift
- .data
- shifts: .byte 3, 4, 5, 7, 13
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement