Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. typedef void (*void_fct_void) (void);
  2. typedef void (*void_fct_int16) (int16);
  3. typedef void (*void_fct_int32) (int32);
  4. typedef void (*void_fct_2int32) (int32, int32);
  5.  
  6. ...
  7.  
  8. Uint32 address;
  9. Uint16 sizeIn;
  10.  
  11. address = HW_Usb_Read_4Bytes();
  12. sizeIn = HW_Usb_Read_1Byte();
  13.  
  14. switch(sizeIn) {
  15. case 0:
  16. ((void_fct_void) address)();
  17. break;
  18. case 2:
  19. ((void_fct_int16) address)(HW_Usb_Read_2Bytes());
  20. break;
  21. case 4:
  22. ((void_fct_int32) address)(HW_Usb_Read_4Bytes());
  23. break;
  24. case 8:
  25. ((void_fct_2int32) address)(HW_Usb_Read_4Bytes(), HW_Usb_Read_4Bytes());
  26. break;
  27. }
  28.  
  29. Uint32 address;
  30. Uint16 sizeIn;
  31.  
  32. address = HW_Usb_Read_4Bytes();
  33. sizeIn = HW_Usb_Read_1Byte();
  34.  
  35. putNbytesOnCallStack(sizeIn); // magic function
  36. ((void_fct_void) address)();
  37.  
  38. __asm {
  39. push sizeIn
  40. ; You can also call your fp using asm:
  41. call address
  42. ; But it's not very safe because your compiler may not
  43. ; have saved its registries before the call
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement