Chaos game: Difference between revisions
Content added Content deleted
(Added XPL0 example.) |
(Added X86 Assembly example using 60 bytes.) |
||
Line 2,787: | Line 2,787: | ||
XXX |
XXX |
||
</pre> |
</pre> |
||
=={{header|X86 Assembly}}== |
|||
Sixty bytes handles it. |
|||
<lang asm> 1 ;Assemble with: tasm, tlink /t |
|||
2 0000 .model tiny |
|||
3 0000 .code |
|||
4 .386 |
|||
5 org 100h |
|||
6 ;assume: ax=0, bx=0, cx=00FFh, dx=cs, si=0100h |
|||
7 |
|||
8 0100 B0 12 start: mov al, 12h ;set 640x480x4 graphic screen |
|||
9 0102 CD 10 int 10h |
|||
10 |
|||
11 0104 69 04 4E35 cha10: imul ax, [si], 4E35h ;generate random number |
|||
12 0108 40 inc ax |
|||
13 0109 89 04 mov [si], ax ;save seed |
|||
14 010B 8A C4 mov al, ah ;use high byte |
|||
15 010D D4 03 aam 3 ;al:= rem(al/3) |
|||
16 010F 8A D8 mov bl, al |
|||
17 0111 02 DB add bl, bl ;double to index words |
|||
18 |
|||
19 0113 03 8F 0130r add cx, [bx+Tx] ;X:= (X+Tx(R)) /2 |
|||
20 0117 D1 E9 shr cx, 1 |
|||
21 |
|||
22 0119 03 97 0136r add dx, [bx+Ty] ;Y:= (Y+Ty(R)) /2 |
|||
23 011D D1 EA shr dx, 1 |
|||
24 |
|||
25 011F B8 0C02 mov ax, 0C02h ;write green (2) graphics pixel |
|||
26 0122 CD 10 int 10h ;(bh=0) |
|||
27 |
|||
28 0124 B4 01 mov ah, 01h ;loop until keystroke |
|||
29 0126 CD 16 int 16h |
|||
30 0128 74 DA jz cha10 |
|||
31 |
|||
32 012A B8 0003 mov ax, 0003h ;restore normal text-mode screen |
|||
33 012D CD 10 int 10h |
|||
34 012F C3 ret ;return to DOS |
|||
35 |
|||
36 0130 0140 002B 0255 Tx dw 320, 320-277, 320+277 ;equilateral triangle |
|||
37 0136 0000 01DF 01DF Ty dw 0, 479, 479 |
|||
38 end start</lang> |
|||
=={{header|XPL0}}== |
=={{header|XPL0}}== |