Created
February 28, 2013 05:21
-
-
Save Blecki/5054404 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
| #ifndef DCPUB_LIB_FIXED | |
| #define DCPUC_LIB_FIXED | |
| #define fix_to_int(a) ((a) >> 8) | |
| #define fix_from_int(a) ((a) << 8) | |
| #define fix_add(a, b) ((a) + (b)) | |
| #define fix_sub(a, b) ((a) - (b)) | |
| function fix_mul(a, b) | |
| { | |
| asm (A = a; B = b, C = &a) | |
| { | |
| MLI A, B | |
| SET B, EX | |
| SHR A, 0x0008 | |
| SHL B, 0x0008 | |
| ADD A, B | |
| SET [C], A | |
| } | |
| return a; | |
| } | |
| function fix_div(a, b) | |
| { | |
| asm (A = a; B = b, C = &a) | |
| { | |
| DVI A, B | |
| SET B, EX | |
| SHL A, 0x0008 | |
| SHR B, 0x0008 | |
| ADD A, B | |
| SET [C], A | |
| } | |
| return a; | |
| } | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment