Last active
August 29, 2015 13:59
-
-
Save halit/10540198 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
segment .text | |
global _start | |
_start: | |
XOR R5, R5 ; clear r5 | |
XOR R6, R6 ; clear r6 | |
INC R6 ; increment r6 | |
SRC R1 ; shift right with carry | |
JC _carry ; if carry jump _carry | |
INC R6 ; now r6 is 2 | |
SRC R1 ; shift right with carry | |
JC _carry ; if carry jump _carry | |
XOR R6, R6 | |
INC R6 | |
SRC R2 | |
JC _carry | |
INC R6 | |
SRC R2 | |
JC _carry | |
XOR R6, R6 | |
INC R6 | |
SRC R3 | |
JC _carry | |
INC R6 | |
SRC R3 | |
JC _carry | |
XOR R6, R6 | |
INC R6 | |
SRC R4 | |
JC _carry | |
INC R6 | |
SRC R4 | |
JC _carry | |
MOV R5, R6 ; R6 = R5 | |
XOR R5, R5 ; clear r5 | |
ADD R1, R5 ; R5 += R1 | |
ADD R2, R5 ; R5 += R2 | |
ADD R3, R5 ; R5 += R3 | |
ADD R4, R5 ; R5 += R4 | |
; now R5 hold integer part, R6 hold lost precision | |
_carry: | |
ADD R6, R5 ; R5 = R6+R5 | |
CLC ; clear carry flag | |
ret ; return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment