Skip to content

Instantly share code, notes, and snippets.

@pamaury
Created September 20, 2017 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pamaury/0011c653a8d2dae5fd16116a8fb4d536 to your computer and use it in GitHub Desktop.
Save pamaury/0011c653a8d2dae5fd16116a8fb4d536 to your computer and use it in GitHub Desktop.
extern int rand(void);
typedef long int32_t;
typedef unsigned long uint32_t;
typedef int32_t mad_fixed64hi_t;
typedef uint32_t mad_fixed64lo_t;
typedef int32_t mad_fixed_t;
int main()
{
int requantized = rand();
int D = rand();
int C = rand();
int output = ({
register mad_fixed64hi_t __hi;
register mad_fixed64lo_t __lo;
asm ("mult %2,%3" : "=l" (__lo), "=h" (__hi) : "%r" ((requantized + D)), "r" ((C)));
((mad_fixed_t) (((__hi) << (32 - 28)) | ((__lo) >> 28)));
});
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment