Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .data
- firstNumber:
- .long 0x00043000, 0x00000000, 0x00000000, 0x20000001
- firstNumberSize = . - firstNumber
- secondNumber:
- .long 0x00002000, 0x00000000, 0x05000001#, 0x00000002
- secondNumberSize = . - secondNumber
- newLine: .ascii "\n\0"
- format_string:
- .ascii "%08x \0"
- printingCounter:
- .long 0
- .text
- .global main
- main:
- movl $firstNumberSize, %edi
- movl $secondNumberSize, %esi
- shrl $2, %edi # przesunięcie o 2 reprezentuje dzielenie przez 4 (4 bajty to 32 bity czyli long)
- shrl $2, %esi # edi i esi są naszymi iteratorami dla liczb 1 i 2
- cmpl %esi, %edi # jeśli edi większe niż esi, to
- ja next # ja jumps if CF = 0 & ZF = 0
- # jeśli edi NIE większe niz esi, to edi --> ecx
- movl %edi, %ecx
- movl %edi, %edx
- jmp next2
- # jeśli edi wieksze niz esi, to esi --> ecx
- next:
- movl %esi, %ecx
- movl %esi, %edx
- next2:
- clc
- while:
- decl %edi
- decl %esi
- movl firstNumber(, %edi, 4), %eax
- movl secondNumber(, %esi, 4), %ebx
- sbbl %ebx, %eax
- pushl %eax
- loop while
- jc carr # skok jeśli carry po ostatnim dodawaniu
- # nie ma przeniesienia po ostatnim dodawaniu to sprawdzamy czy nic juz nie zostalo do dodania
- cmpl %edi, %esi
- je systemExit
- jb toEdi # gdy esi mniejsze niż edi
- # esi większe
- movl %esi, %ecx
- clc
- while1:
- decl %esi
- movl secondNumber(, %esi, 4), %eax
- sbb $0, %eax
- pushl %eax
- loop while1
- jmp end
- toEdi:
- # edi większe
- movl %edi, %ecx
- clc
- while2:
- decl %edi
- movl firstNumber(, %edi, 4), %eax
- sbb $0, %eax
- pushl %eax
- loop while2
- jmp end
- jmp end
- carr:
- # jest carry po ostatnim dodawaniu
- cmpl %edi, %esi
- je carry # jeśli nic nie zostało
- jb toEdi2 # jeśli esi mniejsze niż edi
- # esi większe
- movl %esi, %ecx
- stc # set carry
- while3:
- decl %esi
- movl secondNumber(, %esi, 4), %eax
- sbbl $0, %eax
- pushl %eax
- loop while3
- jmp end
- toEdi2:
- #edi większe
- movl %edi, %ecx
- stc
- while4:
- decl %edi
- movl firstNumber(, %edi, 4), %eax
- sbbl $0, %eax
- pushl %eax
- loop while4
- jmp end
- carry:
- pushl $0x00000001
- incl %edx
- jmp systemExit
- end:
- jnc systemExit
- incl %edx
- pushl $0x00000001
- systemExit:
- addl $2, %edx
- movl %edx, printingCounter
- printLoop:
- decl printingCounter
- cmpl $0, printingCounter
- je exitCall
- pushl $format_string
- call printf
- addl $8, %esp
- jmp printLoop
- exitCall:
- pushl $newLine
- call printf
- call exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement