This file contains hidden or 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
void write_bmp(unsigned char *img, int width, int height) { | |
bmpfile_t *bmp; | |
int i, j; | |
rgb_pixel_t palette[PALETE_NUM_COLORS] = {0}; | |
if ((bmp = bmp_create(width, height, 32)) == NULL) { | |
printf("Could not create bitmap"); | |
exit(-1); | |
} |
This file contains hidden or 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
; Mandelbrot fractal constant, play with it to generate cool images | |
@MAXITER = internal constant i32 200 | |
@ESCAPE = internal constant double 4.0 | |
@XC = internal constant double -0.10894500736830963 ; center point x | |
@YC = internal constant double -0.8955496975621973 ; center point y | |
@ZOOM = internal constant double 0.1 ; zoom into the fractal | |
@W = internal constant i32 2048 ; image width | |
@H = internal constant i32 2048 ; image height |
This file contains hidden or 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
<result> = add i32 4, %var ; yields {i32}:result = 4 + %var | |
<result> = fadd float 4.0, %var ; yields {float}:result = 4.0 + %var | |
<result> = sub i32 0, %val ; yields {i32}:result = -%var | |
<result> = fsub float 4.0, %var ; yields {float}:result = 4.0 - %var | |
<result> = mul i32 4, %var ; yields {i32}:result = 4 * %var | |
<result> = fmul float 4.0, %var ; yields {float}:result = 4.0 * %var | |
<result> = udiv i32 4, %var ; yields {i32}:result = 4 / %var | |
<result> = sdiv i32 4, %var ; yields {i32}:result = 4 / %var | |
<result> = fdiv float 4.0, %var ; yields {float}:result = 4.0 / %var | |
<result> = urem i32 4, %var ; yields {i32}:result = 4 % %var |
This file contains hidden or 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
For each pixel on the screen do: | |
{ | |
x0 = scaled x co-ordinate of pixel (must be scaled to lie somewhere in the interval (-2.5 to 1) | |
y0 = scaled y co-ordinate of pixel (must be scaled to lie somewhere in the interval (-1, 1) | |
ESCAPE = 2*2 | |
x = 0 | |
y = 0 | |
iteration = 0 |
This file contains hidden or 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
; LOOP for(t=0; t<max, t++) | |
store i32 0, i32* %t.addr | |
br label %loop_over_t | |
loop_over_t: | |
%t = load i32* %t.addr ; %t contains the loop counter current value | |
; ... DO SOME WORK ... | |
; increment t and loop | |
%t_plus_1 = add i32 1, %t |
NewerOlder