Created
April 25, 2016 07:16
-
-
Save cahirwpz/19c6ea0033a1685f72f03025874530fc to your computer and use it in GitHub Desktop.
m68k GCC assembly inline for abs function without jump instruction
This file contains 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
static inline int absl(int x) { | |
int t; | |
asm("move.l %0,%1\n\t" | |
"add.l %1,%1\n\t" | |
"subx.l %1,%1\n\t" | |
"eor.l %1,%0\n\t" | |
"sub.l %1,%0\n\t" | |
: "+r" (x), "=r" (t)); | |
return x; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should be exactly five cycles on M68060, however simplier version with asr.l will take two cycles. On M68000 version with jump will be slightly faster, so again - this trick is not very useful :(