Advertisement
dllbridge

Untitled

Apr 2nd, 2024 (edited)
646
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.58 KB | None | 0 0
  1. //////////////////////////////////
  2. //  Ниже смотрите код для FASM !!!
  3. //////////////////////////////////
  4.  
  5. #include     <stdio.h>
  6. #include   <windows.h>
  7.  
  8.  
  9. extern "C"
  10. {                          
  11.        
  12.     int   __stdcall _RGB(  int, int, int); 
  13.     int*  __stdcall _decomposition_RGB(int);           
  14. }
  15.  
  16.  
  17. ///////////////////////////////////////////////////////
  18. int main()                                           //
  19. {
  20.    
  21.     int n = RGB(11, 22, 33);
  22.  
  23.     printf("_RGB = %d \n", _RGB(11, 22, 33));
  24.     printf(" RGB = %d \n",  n);
  25.  
  26.     int  *pn = _decomposition_RGB(n);
  27.  
  28.     printf(" arr[0]  = %3d \n",  pn[0]);             // Не используется, но можно посмотреть и...
  29.     printf(" Red     = %3d \n",  pn[1]);             // ...хранить там 1 байт
  30.     printf(" Green   = %3d \n",  pn[2]);    
  31.     printf(" Blue    = %3d \n",  pn[3]);  
  32.     printf(" \nPause: ");
  33.     for(int i = 5; i >= 0; i--) { printf("%d, ", i); Sleep(999); } 
  34.    
  35. return 0;      
  36. }
  37.  
  38.  
  39.  
  40.  
  41. //////////////////////////////////
  42. //        Код для FASM         !!!
  43. //////////////////////////////////
  44.  
  45.  
  46. include    'win32a.inc'
  47.  
  48.  
  49. format      MS COFF
  50.  
  51.  
  52. public     _RGB                     as '__RGB@12'
  53. public     _decomposition_RGB       as '__decomposition_RGB@4'
  54.  
  55.  
  56.  
  57. section   '.text' code readable executable
  58. ;/////////////////////////////////////////////////////////////
  59. proc   _RGB   red, green, blue                             ;//
  60. ;//
  61.         push  ebx
  62.         mov   eax  , [green]
  63.         mov   ebx  ,  [blue]
  64.  
  65.         shl   eax  ,      8
  66.         shl   ebx  ,     16
  67.         add   eax  ,    ebx
  68.         add   eax  ,   [red]
  69.         pop   ebx
  70.         ret
  71. endp
  72.  
  73.  
  74.  
  75. ;/////////////////////////////////////////////////////////////
  76. proc   _decomposition_RGB   color                          ;//
  77.  
  78.         push  ebx
  79.         mov   ebx,    [color]
  80.         mov   eax,         0
  81.         mov    al,        bl
  82.         mov  [arr +  4], eax   ; Red
  83.         shr   ebx,         8
  84.         mov    al,        bl
  85.         mov  [arr +  8], eax   ; Green
  86.         shr   ebx,         8
  87.         mov    al       , bl
  88.         mov  [arr + 12], eax   ; Blue
  89.  
  90.         shr   ebx,         8
  91.         mov  [arr],      ebx   ;  То, что хранится в неиспользуемом байте.  
  92.         mov   eax ,      arr
  93.         pop   ebx
  94.         ret
  95. endp
  96.  
  97.  
  98. section '.data' data readable writeable
  99. ;-------------------------------------------------------------      Создание переменных:  
  100.    arr   dd   4 dup(333)
  101.  
  102.              
  103.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement