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
bloom: | |
mov cx, 63680 ; we average every pixel except the top row | |
mov di, 320 ; we start at the 2nd row | |
next_avg: | |
xor ax, ax ; clear out our accumulator | |
mov al, es:[di] ; get the current pixel | |
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
#include <stdio.h> | |
/** Forward declaration for our add function */ | |
int add(int, int); | |
int main() { | |
/* add some numbers */ | |
int x = add(5, 4); |
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
global add | |
section .text | |
add: | |
mov eax, [esp+4] ; get the 1st param | |
mov ecx, [esp+8] ; get the 2nd param | |
add eax, ecx ; add them together | |
; leaving the return value in eax |
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
gcc -m32 -c -g add.c -o add.o | |
nasm -felf32 maths.asm -o maths.o | |
gcc -m32 add.o maths.o -o add |
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
$ gcc -g test.c -o test |
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
$ gdb test |
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
; copies data from one memory location to another | |
m2m MACRO M1, M2 | |
push M2 | |
pop M1 | |
ENDM | |
; syntactic sugar for returning a value | |
return MACRO arg | |
mov eax, arg | |
ret |
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
LOCAL wc :WNDCLASSEX | |
szText szClassName, "SimpleWindow32" | |
; fill out the WNDCLASSEX structure here | |
mov wc.cbSize, sizeof WNDCLASSEX | |
mov wc.style, CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW | |
mov wc.lpfnWndProc, offset WndProc | |
mov wc.cbClsExtra, NULL | |
mov wc.cbWndExtra, NULL |
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
; create the window | |
invoke CreateWindowEx, WS_EX_OVERLAPPEDWINDOW, | |
ADDR szClassName, | |
ADDR szDisplayName, | |
WS_OVERLAPPEDWINDOW, | |
CW_USEDEFAULT, CW_USEDEFAULT, | |
CW_USEDEFAULT, CW_USEDEFAULT, | |
NULL, NULL, hInst, NULL | |
; save off the window handle |
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
WndProc PROC hWin :DWORD, | |
uMsg :DWORD, | |
wParam :DWORD, | |
lParam :DWORD | |
.if uMsg == WM_CLOSE | |
.elseif uMsg == WM_DESTROY | |
invoke PostQuitMessage, NULL | |
return 0 |