Created
October 1, 2015 10:08
-
-
Save giuscri/363e8865038825318ad5 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
.text | |
.global _start | |
_start: | |
xorl %ebx, %ebx | |
movl $buf, %ecx | |
movl %ebx, (%ecx) | |
movl $buf_length, %edx | |
movl $buf, %ecx | |
movl $0, %ebx | |
movl $3, %eax | |
int $0x80 | |
movl $buf, %ecx | |
forloop_1: | |
xorl %ebx, %ebx | |
movb (%ecx), %bl | |
cmpl $0x30, %ebx | |
jl endforloop_1 | |
cmpl $0x39, %ebx | |
jg endforloop_1 | |
movl $number_1, %eax | |
movl (%eax), %eax | |
movl $10, %edx | |
mull %edx | |
subl $0x30, %ebx | |
addl %ebx, %eax | |
movl $number_1, %ebx | |
movl %eax, (%ebx) | |
incl %ecx | |
jmp forloop_1 | |
endforloop_1: | |
xorl %ebx, %ebx | |
movl $buf, %ecx | |
movl %ebx, (%ecx) | |
movl $buf_length, %edx | |
movl $buf, %ecx | |
movl $0, %ebx | |
movl $3, %eax | |
int $0x80 | |
movl $buf, %ecx | |
forloop_2: | |
xorl %ebx, %ebx | |
movb (%ecx), %bl | |
cmpl $0x30, %ebx | |
jl endforloop_2 | |
cmpl $0x39, %ebx | |
jg endforloop_2 | |
movl $number_2, %eax | |
movl (%eax), %eax | |
movl $10, %edx | |
mull %edx | |
subl $0x30, %ebx | |
addl %ebx, %eax | |
movl $number_2, %ebx | |
movl %eax, (%ebx) | |
incl %ecx | |
jmp forloop_2 | |
endforloop_2: | |
xorl %ebx, %ebx | |
movl $buf, %ecx | |
movl %ebx, (%ecx) | |
movl $number_1, %ebx | |
movl (%ebx), %ebx | |
movl $number_2, %edx | |
movl (%edx), %edx | |
subl %edx, %ebx | |
movl $result, %edx | |
movl %ebx, (%edx) | |
movl $result, %ebx | |
movl (%ebx), %ebx | |
forloop_3: | |
cmpl $0, %ebx | |
jle endforloop_3 | |
xorl %eax, %eax | |
xorl %edx, %edx | |
movl $result, %eax | |
movl (%eax), %eax | |
movl $10, %ebx | |
divl %ebx | |
movl $result, %ebx | |
movl %eax, (%ebx) | |
movl $buf, %ebx | |
movl (%ebx), %ebx | |
shl $8, %ebx | |
movl $buf, %ecx | |
movl %ebx, (%ecx) | |
addl $0x30, %edx | |
orl %edx, %ebx | |
movl %ebx, (%ecx) | |
movl $result, %ebx | |
movl (%ebx), %ebx | |
jmp forloop_3 | |
endforloop_3: | |
movl $buf_length, %edx | |
movl $buf, %ecx | |
movl $1, %ebx | |
movl $4, %eax | |
int $0x80 | |
exit: | |
movl $0, %ebx | |
movl $1, %eax | |
int $0x80 | |
.data | |
buf: | |
.byte 0x0, 0x0, 0x0, 0x0 | |
buf_length = . - buf | |
number_1: | |
.long 0x0 | |
number_2: | |
.long 0x0 | |
result: | |
.long 0x0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment