Last active
July 9, 2018 15:38
-
-
Save dasmithii/9586834 to your computer and use it in GitHub Desktop.
Implementation of unsigned integer addition in Brainfuck. Assumes pointer placement to be at byte zero, and the following eight bytes to represent two four-byte integers.
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
===================================================================================================== | |
===================================================================================================== | |
===================================| Perform Addition: |======================================== | |
===================================================================================================== | |
===================================================================================================== | |
FOR EACH UNIT IN BYTE 5: | |
>>>>[-<<<< | |
INCREMENT BYTE 1: | |
+ B1 | |
[->>>>>>>>+>+<<<<<<<<<]>>>>>>>>>[-<<<<<<<<<+>>>>>>>>>] B10 | |
+<[- >[-]<]>[- <<<<<<<<<[-]> B2 | |
+ B2 | |
[->>>>>>>+>+<<<<<<<<]>>>>>>>>[-<<<<<<<<+>>>>>>>>] B10 | |
+<[- >[-]<]>[- <<<<<<<<[-]> B3 | |
+ B3 | |
[->>>>>>+>+<<<<<<<]>>>>>>>[-<<<<<<<+>>>>>>>] B10 | |
+<[- >[-]<]>[- <<<<<<<[-]>+ B4 | |
[->>>>>+>+<<<<<<]>>>>>>[-<<<<<<+>>>>>>] B10 | |
+<[- >[-]<]>[- <<<<<<<<<[-]>[-]>[-]>[-]>>>>>>] B10 | |
] | |
] | |
] | |
<<<<<<<<< | |
>>>>] | |
FOR EACH UNIT IN BYTE 6: | |
>[-<<<<< | |
INCREMENT BYTE 2: | |
>+ B2 | |
[->>>>>>>+>+<<<<<<<<]>>>>>>>>[-<<<<<<<<+>>>>>>>>] B10 | |
+<[- >[-]<]>[- <<<<<<<<[-]> B3 | |
+ B3 | |
[->>>>>>+>+<<<<<<<]>>>>>>>[-<<<<<<<+>>>>>>>] B10 | |
+<[- >[-]<]>[- <<<<<<<[-]>+ B4 | |
[->>>>>+>+<<<<<<]>>>>>>[-<<<<<<+>>>>>>] B10 | |
+<[- >[-]<]>[- <<<<<<<<<[-]>[-]>[-]>[-]>>>>>>] B10 | |
] | |
] B10 | |
<<<<<<<<< | |
>>>>>] | |
FOR EACH UNIT IN BYTE 7 | |
>[-<<<<<< | |
>>+ B3 | |
[->>>>>>+>+<<<<<<<]>>>>>>>[-<<<<<<<+>>>>>>>] B10 | |
+<[- >[-]<]>[- <<<<<<<[-]>+ B4 | |
[->>>>>+>+<<<<<<]>>>>>>[-<<<<<<+>>>>>>] B10 | |
+<[- >[-]<]>[- <<<<<<<<<[-]>[-]>[-]>[-]>>>>>>] B10 | |
] B10 | |
<<<<<<<<< | |
>>>>>>] | |
FOR EACH UNIT IN BYTE 8 | |
>[-<<<<<<< | |
>>>+ B4 | |
[->>>>>+>+<<<<<<]>>>>>>[-<<<<<<+>>>>>>] B10 | |
+<[- >[-]<]>[- <<<<<<<<<[-]>[-]>[-]>[-]>>>>>>] B10 | |
<<<<<<<<< | |
>>>>>>>] | |
RETURN POINTER TO ORIGIN | |
<<<<<<< |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment