Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////////
- // Ниже смотрите код для FASM !!!
- //////////////////////////////////
- #include <stdio.h>
- #include <windows.h>
- extern "C"
- {
- int __stdcall _RGB( int, int, int);
- int* __stdcall _decomposition_RGB(int);
- }
- ///////////////////////////////////////////////////////
- int main() //
- {
- int n = RGB(11, 22, 33);
- printf("_RGB = %d \n", _RGB(11, 22, 33));
- printf(" RGB = %d \n", n);
- int *pn = _decomposition_RGB(n);
- printf(" arr[0] = %3d \n", pn[0]); // Не используется, но можно посмотреть и...
- printf(" Red = %3d \n", pn[1]); // ...хранить там 1 байт
- printf(" Green = %3d \n", pn[2]);
- printf(" Blue = %3d \n", pn[3]);
- printf(" \nPause: ");
- for(int i = 5; i >= 0; i--) { printf("%d, ", i); Sleep(999); }
- return 0;
- }
- //////////////////////////////////
- // Код для FASM !!!
- //////////////////////////////////
- include 'win32a.inc'
- format MS COFF
- public _RGB as '__RGB@12'
- public _decomposition_RGB as '__decomposition_RGB@4'
- section '.text' code readable executable
- ;/////////////////////////////////////////////////////////////
- proc _RGB red, green, blue ;//
- ;//
- push ebx
- mov eax , [green]
- mov ebx , [blue]
- shl eax , 8
- shl ebx , 16
- add eax , ebx
- add eax , [red]
- pop ebx
- ret
- endp
- ;/////////////////////////////////////////////////////////////
- proc _decomposition_RGB color ;//
- push ebx
- mov ebx, [color]
- mov eax, 0
- mov al, bl
- mov [arr + 4], eax ; Red
- shr ebx, 8
- mov al, bl
- mov [arr + 8], eax ; Green
- shr ebx, 8
- mov al , bl
- mov [arr + 12], eax ; Blue
- shr ebx, 8
- mov [arr], ebx ; То, что хранится в неиспользуемом байте.
- mov eax , arr
- pop ebx
- ret
- endp
- section '.data' data readable writeable
- ;------------------------------------------------------------- Создание переменных:
- arr dd 4 dup(333)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement