Compare commits
11 Commits
9ecb520b5c
...
master
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7a9bd95804 | ||
![]() |
9f5df0a65c | ||
![]() |
2598b444f8 | ||
![]() |
d59671e54c | ||
![]() |
0785e7ccd0 | ||
![]() |
5db47a3fcc | ||
![]() |
3362719e79 | ||
![]() |
d1478ac425 | ||
![]() |
ae34c01c77 | ||
![]() |
83f5ba9fae | ||
![]() |
45fc62c759 |
3
16/Makefile
Normal file
3
16/Makefile
Normal file
@@ -0,0 +1,3 @@
|
||||
all:
|
||||
nasm -g -felf32 main.s && ld -melf_i386 -g main.o
|
||||
|
110
16/input
Normal file
110
16/input
Normal file
@@ -0,0 +1,110 @@
|
||||
\....|...-...../.....|....................-./............|/.....................-........./.....-.............
|
||||
\..........-.....................-......................................|....................\..../.....-.....
|
||||
....\......-...../../../...\......................\.........................-.............|.............|.....
|
||||
.........../..../...........|/\.............\........\.......|.........|..|../............/.........|.........
|
||||
\./...\........\..........\......./....../...............................|....|........|................/.....
|
||||
|-.....|............/...............|...\...|...../......../.....|............|..\..|..../.......-.........\..
|
||||
........-.............||../..........|.........../..................../.|.....|\..-/......./...\...\....-.....
|
||||
....................//........................./..........\.......|...|.........../......\-......-...\........
|
||||
....../..........\......\.....................\................\......\..\..|.................................
|
||||
.................\...............-....../........./....-./..........|..../..-..|../................\..........
|
||||
.............-...............-......|.../.....-.....//.\................../..........-......-...........-.....
|
||||
.........../.\.....................\............-..........|.......\..................\.......................
|
||||
...............\............/.|...\........../....\.............|...........\...............|.../........\....
|
||||
./..............\................-\.../\.......-....................-..............-|.............\.-.........
|
||||
../....../.........|..../......\...\.\.................|......./.......|...............-.........-............
|
||||
-...-............................\.............-.\........-.....|.........././-......|......-..../...|........
|
||||
................-.....................|..|...\.././.............|..........................-.............-....
|
||||
.......|...............................|.......................................-......../.............|-...-..
|
||||
.\|............................\................|.....-.....-................................./...-..\...../..
|
||||
.......\......-....\|......|........................................./...||...............\...................
|
||||
.................../......../.......-......\..............|..\...........-.........-.............../..........
|
||||
........................\......................../.................-........................\.....\...........
|
||||
..........|......|........................|.|\...............\...|.............-...-....-............--.......
|
||||
............|........../....\..........\........../..-..|...........-...\........................./..-........
|
||||
.............||../..../.......................-/.......\.....\............./|..-...............|.....|........
|
||||
................................|..\.........-......./...........-../-............\................\....-../..
|
||||
.............-.............................|.\...............................\\...............................
|
||||
..|.......-................................\.......|.......\.....................|../\..........\..........-..
|
||||
......-..\..........-.................\.-..../\......./......./..-.......................\.....-........\.....
|
||||
............................../.....................\.................\................|..../\.............\..
|
||||
..............................-.......\.........-..........\....../............./.....-........\...-.........|
|
||||
/..................\...||..|...........\...............-............\..........|./.....-.-./.............../..
|
||||
.....|......./...............\.......-................-...........................................\...........
|
||||
.|.................../.....\............./.....\.................-.../.......-..............\..-..............
|
||||
......\........|...|...........//..........|\.\..............................-..../...-............|..........
|
||||
|......\....|\......|........../.........../........-.........|.-\//................/..\....|.../........|....
|
||||
.-....-......................./.........\.........-.../............................-..|........|.....|...|....
|
||||
.........-..................-..........-....-....................-....-./.......................|.../......\..
|
||||
..-../......................-\.....|...\........./.-...............-.................../../............|......
|
||||
.-/.......-../.......-...|\...../..........-...\.......\.........-....\-................-......|........-.....
|
||||
.............................\\\............-..............|........../...................-......../....../../
|
||||
.....-....\....\......................-..\...............-..|...............-................-.......\......|.
|
||||
..-...\.............................../.../.............................--.......-..|.|\...../...............\
|
||||
......\.../...-.....|....|......\.../|...................................-................-................./.
|
||||
.......-......-.../..................|../..................\..........................\-..........-\..........
|
||||
.-.......\.........|....|\/./-\.-.....|..................-...................................-|...\...........
|
||||
...........-........../\..................\./..........................\...../...........-...\...../..\....-..
|
||||
..-.|...../|......\..\........|.............-.....|..........\...-...-../......................../.......|....
|
||||
......../................/..\.......\..-...|.....\.......|\..........................-..\../..........\./.....
|
||||
........\.-......|......|..........|........-...................-..\.....-./..............-.\......\..........
|
||||
........|./..................\........|......................\............................./.-\....\........-.
|
||||
........\.|......\................/..\....-/.\.....-.....|............................\..\.|............|...-.
|
||||
...-.....-|..................|...............-./.....................\..\............|.....-..................
|
||||
..........|\./.....\..................|.........|.....................-\./..\........\........................
|
||||
../........\..............|....-...............................................|..........-......../..........
|
||||
..\..............|...../../....................-....\.....................|........\...\\.....................
|
||||
...........................-...\......\......./../..........\-...../.......................-...........\......
|
||||
-.|........................../.....|...............\..........-.............\...-................-.......-....
|
||||
/../.........\........./......-.../..-..................-.......................\............--...............
|
||||
\...............|......-..../......................................-........./|......................\|....../
|
||||
.....\.......................................-...................-.../...........\.......|../.............|...
|
||||
....-....||......\..\.......-.........-......../..../............\..................................-.........
|
||||
...-..|.......\..\..|..........-../-..........\............../...............|..../........./....../.......|./
|
||||
.......................\.......././.............\..................-..........|................../....|.......
|
||||
-.|.....................\\.........../......./.|................/................|./......./....-.............
|
||||
......-...............-....-................|./\..\-/...../......../....-....\....|.-.................../...\.
|
||||
...............\......-...\...\....-....-/....................\./....../..................-|........\./...../.
|
||||
.\......................./..\.........\.........|............|.......-../..\.-..|.-..........................|
|
||||
..|../.....................|/......................./......../.../.........-.../.|./.|.-..............|....-..
|
||||
...-.-/............/............|..........|....../\...\./.....|..................|....\............/.........
|
||||
.....|........./.........\.............../......./../../...................|.......//.......\..\..........\...
|
||||
......./.............\...........\.\..............................................\...................|.......
|
||||
...............-|...../..-............................\.....-.............../\.........-....................\.
|
||||
.........-.....................-...\...................-..../.................||....\.........-.......-..-....
|
||||
.|../..\...\......|..\./.........\..............|..\/......../...............-..-....................-.....\..
|
||||
..................|........\.-.....|.......\............../................................/...-....|...../...
|
||||
...........-......./........-...--........\.../..-...../.|............|......./...............|....../\......\
|
||||
.../.....\...................-..../....................................-......................|.............-.
|
||||
.\.....|....-.....|.....-...................................................|../....\..................\.....-
|
||||
....-........../\......../.......-....\............................./-.............-..........................
|
||||
....\.........-........./......../....|..............\........\../.................\.|...............\........
|
||||
.........-..............|./............-.......................\.......\......-\......\......../..............
|
||||
-.|...|./-..........\..........-...-............|...-......................\..\.............................-.
|
||||
............/......................../.........................................\/..........|.....|.-........|/
|
||||
....../..|./..././.....-......................../....|................../..|........-.....................|./.
|
||||
.......................\....................../......./......\/........\......./....../\|.....\...............
|
||||
\...........\/.|../..................../...............\\...\..../..................\......./.................
|
||||
.../................/...............\./....-./........../........./\..-.................................\.....
|
||||
........-.......-...........\........-.......\............|............|.....-........|..|..../...............
|
||||
.............|...|............/....\............................................-..\......./.../..........\...
|
||||
...................../-..|...........-................../.\...|.....\.....|/.................|................
|
||||
..|................\.....-...........|.\............-.........|....../...................\......-.|.......\...
|
||||
........\......../.....-...\..\...........\........|/.............../......|.......|.\..|........|............
|
||||
..........\.....................-..|/.....\............-............../.......................|./........\....
|
||||
.......\........|...........\......\.......-..-.....|............./......|\..............................|....
|
||||
.........\.......................-............-/.................................\............|...............
|
||||
.........\................/.............................../..........\................-../../......|......-...
|
||||
....\...-./...............\...............|.....\|....|/...............-...........................-..........
|
||||
.|.......\.......-............./.......\............./....................|......|../......-...........\......
|
||||
.....\.....-.....\...\................/......\...\../.\...\....\-....-././...............................|./..
|
||||
.....................-.\.\.........../......./...-......./-.........................\.......|../....\..|..../.
|
||||
|..\......./-......-...../..-....../.................../..-.....................-..../...........\...../......
|
||||
......................................./................|....\/....\............/....../......................
|
||||
......................../..........|........-............|.........................|.\................|....../
|
||||
-.............-...|...........-....-..-.|\.......|......\..........-......|-...-......\.......................
|
||||
...........\.\\.../.................\..........\..-......-......|.-............................-.||...|....../
|
||||
....|................--........|.|..........|......\.............................................-............
|
||||
.-..|................/../..-.........................../...../.....\.../....-.....\-..................../.....
|
||||
............./|..........................\...................................-..-..........|....\..|..........
|
||||
....|...../........./.-....-..................../.........../....................-................\./.........
|
10
16/input_test
Normal file
10
16/input_test
Normal file
@@ -0,0 +1,10 @@
|
||||
.|...\....
|
||||
|.-.\.....
|
||||
.....|-...
|
||||
........|.
|
||||
..........
|
||||
.........\
|
||||
..../.\\..
|
||||
.-.-/..|..
|
||||
.|....-|.\
|
||||
..//.|....
|
511
16/main.s
Normal file
511
16/main.s
Normal file
@@ -0,0 +1,511 @@
|
||||
%include "utils.s"
|
||||
|
||||
global _start
|
||||
[bits 32]
|
||||
[section .text]
|
||||
|
||||
%define LINE_LEN 111 ; real
|
||||
%define FILENAME "input"
|
||||
;%define LINE_LEN 11 ; test
|
||||
;%define FILENAME "input_test"
|
||||
|
||||
;%define ITER_PRINT
|
||||
;%define FINAL_PRINT
|
||||
|
||||
_start:
|
||||
|
||||
; bit 3 bit 2 bit 1 bit 0
|
||||
; up down left right
|
||||
|
||||
; start top left going right
|
||||
mov dword [test_edge_line], 0
|
||||
mov dword [test_edge_col], 0
|
||||
mov byte [test_edge_dir], 1
|
||||
mov byte [energized], 1
|
||||
jmp next_iteration
|
||||
next_edge_tile:
|
||||
; clear energized
|
||||
mov edi, energized
|
||||
xor eax, eax
|
||||
mov ecx, (128*128)/4
|
||||
rep stosd
|
||||
|
||||
mov eax, [test_edge_line]
|
||||
mov ecx, [test_edge_col]
|
||||
mov bl, [test_edge_dir]
|
||||
cmp bl, 1 ; we're testing going right
|
||||
jne .maybe_2
|
||||
; we're going down first col
|
||||
cmp eax, LINE_LEN-2 ; check if last line
|
||||
je .bl_corner
|
||||
inc eax
|
||||
jmp start_iterations
|
||||
.bl_corner:
|
||||
mov bl, 8 ; try going up
|
||||
jmp start_iterations
|
||||
.maybe_2:
|
||||
cmp bl, 2 ; we're testing going left
|
||||
jne .maybe_4
|
||||
; we're going up the last col
|
||||
cmp eax, 0 ; check if first line
|
||||
je .tr_corner
|
||||
dec eax
|
||||
jmp start_iterations
|
||||
.tr_corner:
|
||||
mov bl, 4 ; try going down
|
||||
jmp start_iterations
|
||||
.maybe_4:
|
||||
cmp bl, 4 ; we're testing going down
|
||||
jne .maybe_8
|
||||
; we're going along the top line backward
|
||||
cmp ecx, 0 ; check if first col
|
||||
je .tl_corner
|
||||
dec ecx
|
||||
jmp start_iterations
|
||||
.tl_corner:
|
||||
jmp game_over ; nothing to do! jump to exit
|
||||
.maybe_8: ; we're testing going up
|
||||
; we're going along the bottom line
|
||||
cmp ecx, LINE_LEN-2 ; check if last col
|
||||
je .br_corner
|
||||
inc ecx
|
||||
jmp start_iterations
|
||||
.br_corner:
|
||||
mov bl, 2 ; try going left
|
||||
jmp start_iterations
|
||||
|
||||
start_iterations:
|
||||
mov [test_edge_line], eax
|
||||
mov [test_edge_col], ecx
|
||||
mov [test_edge_dir], bl
|
||||
mov edx, LINE_LEN
|
||||
mul edx
|
||||
add eax, ecx
|
||||
mov byte [energized+eax], bl
|
||||
|
||||
next_iteration:
|
||||
|
||||
%ifdef ITER_PRINT
|
||||
; debug printing
|
||||
dbg:
|
||||
xor esi, esi ; top line
|
||||
.for_lines:
|
||||
xor ecx, ecx ; leftmost char
|
||||
.for_chars:
|
||||
movzx eax, byte [esi+ecx+energized]
|
||||
movzx ebx, byte [esi+ecx+file]
|
||||
pushad
|
||||
test al, al
|
||||
jz .prnt_char
|
||||
p_string ansi_color_highbold_green
|
||||
cmp bl, '.'
|
||||
jne .prnt_char
|
||||
popcnt ecx, eax
|
||||
cmp ecx, 1
|
||||
jg .prnt_num
|
||||
cmp al, 1
|
||||
je .prnt_right
|
||||
cmp al, 2
|
||||
je .prnt_left
|
||||
cmp al, 4
|
||||
je .prnt_down
|
||||
.prnt_up: mov al, '^'
|
||||
call print_char
|
||||
jmp .prnt_done
|
||||
.prnt_down: mov al, 'v'
|
||||
call print_char
|
||||
jmp .prnt_done
|
||||
.prnt_left: mov al, '<'
|
||||
call print_char
|
||||
jmp .prnt_done
|
||||
.prnt_right: mov al, '>'
|
||||
call print_char
|
||||
jmp .prnt_done
|
||||
.prnt_num:
|
||||
mov eax, ecx
|
||||
call print_dec
|
||||
jmp .prnt_done
|
||||
.prnt_char:
|
||||
mov al, [esi+ecx+file]
|
||||
call print_char
|
||||
.prnt_done:
|
||||
p_string ansi_color_reset
|
||||
popad
|
||||
.for_chars_cont:
|
||||
inc ecx
|
||||
cmp ecx, LINE_LEN-2
|
||||
jbe .for_chars
|
||||
.for_chars_done:
|
||||
.for_lines_cont:
|
||||
call newline
|
||||
add esi, LINE_LEN
|
||||
cmp esi, len(file)
|
||||
jb .for_lines
|
||||
call newline
|
||||
; debug printing end
|
||||
%endif
|
||||
|
||||
xor esi, esi ; top line
|
||||
for_lines:
|
||||
xor ecx, ecx ; leftmost char
|
||||
for_chars:
|
||||
movzx eax, byte [esi+ecx+energized]
|
||||
movzx ebx, byte [esi+ecx+file]
|
||||
; skip if not energized
|
||||
test eax, eax
|
||||
jz for_chars_cont
|
||||
; select thing
|
||||
cmp bl, '.'
|
||||
je empty
|
||||
cmp bl, '/'
|
||||
je mirror_one
|
||||
cmp bl, '\'
|
||||
je mirror_two
|
||||
cmp bl, '-'
|
||||
je horz_split
|
||||
cmp bl, '|'
|
||||
je vert_split
|
||||
p_string what_the_fuck
|
||||
jmp exit
|
||||
empty: ; .
|
||||
; propagate
|
||||
; test right
|
||||
bt eax, 0
|
||||
jnc .t_left
|
||||
or byte [esi+ecx+energized+1], 1<<0
|
||||
.t_left:
|
||||
bt eax, 1
|
||||
jnc .t_down
|
||||
or byte [esi+ecx+energized-1], 1<<1
|
||||
.t_down:
|
||||
bt eax, 2
|
||||
jnc .t_up
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2
|
||||
.t_up:
|
||||
bt eax, 3
|
||||
jnc .done
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3
|
||||
.done:
|
||||
jmp for_chars_cont
|
||||
mirror_one: ; /
|
||||
; our energized is what hits us
|
||||
; test right >/
|
||||
bt eax, 0
|
||||
jnc .t_left
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3 ; up char going up
|
||||
.t_left: ; /<
|
||||
bt eax, 1
|
||||
jnc .t_down
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2 ; down going down
|
||||
.t_down:
|
||||
bt eax, 2 ; v
|
||||
jnc .t_up ; /
|
||||
or byte [esi+ecx+energized-1], 1<<1 ; left going left
|
||||
.t_up:
|
||||
bt eax, 3 ; /
|
||||
jnc .done ; ^
|
||||
or byte [esi+ecx+energized+1], 1<<0 ; right going right
|
||||
.done:
|
||||
jmp for_chars_cont
|
||||
mirror_two: ; \
|
||||
; our energized is what hits us
|
||||
; test right >\
|
||||
bt eax, 0
|
||||
jnc .t_left
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2 ; down char going down
|
||||
.t_left: ; \<
|
||||
bt eax, 1
|
||||
jnc .t_down
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3 ; up going up
|
||||
.t_down:
|
||||
bt eax, 2 ; v
|
||||
jnc .t_up ; \
|
||||
or byte [esi+ecx+energized+1], 1<<0 ; right going right
|
||||
.t_up:
|
||||
bt eax, 3 ; \
|
||||
jnc .done ; ^
|
||||
or byte [esi+ecx+energized-1], 1<<1 ; left going left
|
||||
.done:
|
||||
jmp for_chars_cont
|
||||
horz_split: ; -
|
||||
; our energized is what hits us
|
||||
; right and left propagate
|
||||
; test right
|
||||
bt eax, 0
|
||||
jnc .t_left
|
||||
or byte [esi+ecx+energized+1], 1<<0
|
||||
.t_left:
|
||||
bt eax, 1
|
||||
jnc .t_vert
|
||||
or byte [esi+ecx+energized-1], 1<<1
|
||||
; down and up go both left and right
|
||||
.t_vert:
|
||||
and eax, 1<<2 | 1<<3
|
||||
jz .done
|
||||
or byte [esi+ecx+energized+1], 1<<0 ; right going right
|
||||
or byte [esi+ecx+energized-1], 1<<1 ; left going left
|
||||
.done:
|
||||
jmp for_chars_cont
|
||||
vert_split: ; |
|
||||
; our energized is what hits us
|
||||
; down and up propagate
|
||||
; test down
|
||||
bt eax, 2
|
||||
jnc .t_up
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2
|
||||
.t_up:
|
||||
bt eax, 3
|
||||
jnc .t_vert
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3
|
||||
; left and right go both down and up
|
||||
.t_vert:
|
||||
and eax, 1<<0 | 1<<1
|
||||
jz .done
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2 ; down going down
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3 ; up going up
|
||||
.done:
|
||||
for_chars_cont:
|
||||
inc ecx
|
||||
cmp ecx, LINE_LEN-2
|
||||
jbe for_chars
|
||||
for_chars_done:
|
||||
for_lines_cont:
|
||||
add esi, LINE_LEN
|
||||
cmp esi, len(file)
|
||||
jb for_lines
|
||||
|
||||
xor ebp, ebp ; energized count
|
||||
sub esi, LINE_LEN ; last line
|
||||
; now go through backward
|
||||
bkwd_for_lines:
|
||||
mov ecx, LINE_LEN-2 ; rightmost char
|
||||
bkwd_for_chars:
|
||||
movzx eax, byte [esi+ecx+energized]
|
||||
movzx ebx, byte [esi+ecx+file]
|
||||
; skip if not energized
|
||||
test eax, eax
|
||||
jz bkwd_for_chars_cont
|
||||
inc ebp ; energized count
|
||||
; select thing
|
||||
cmp bl, '.'
|
||||
je bkwd_empty
|
||||
cmp bl, '/'
|
||||
je bkwd_mirror_one
|
||||
cmp bl, '\'
|
||||
je bkwd_mirror_two
|
||||
cmp bl, '-'
|
||||
je bkwd_horz_split
|
||||
cmp bl, '|'
|
||||
je bkwd_vert_split
|
||||
p_string what_the_fuck
|
||||
jmp exit
|
||||
bkwd_empty: ; .
|
||||
; propagate
|
||||
; test right
|
||||
bt eax, 0
|
||||
jnc .t_left
|
||||
or byte [esi+ecx+energized+1], 1<<0
|
||||
.t_left:
|
||||
bt eax, 1
|
||||
jnc .t_down
|
||||
or byte [esi+ecx+energized-1], 1<<1
|
||||
.t_down:
|
||||
bt eax, 2
|
||||
jnc .t_up
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2
|
||||
.t_up:
|
||||
bt eax, 3
|
||||
jnc .done
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3
|
||||
.done:
|
||||
jmp bkwd_for_chars_cont
|
||||
bkwd_mirror_one: ; /
|
||||
; our energized is what hits us
|
||||
; test right >/
|
||||
bt eax, 0
|
||||
jnc .t_left
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3 ; up char going up
|
||||
.t_left: ; /<
|
||||
bt eax, 1
|
||||
jnc .t_down
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2 ; down going down
|
||||
.t_down:
|
||||
bt eax, 2 ; v
|
||||
jnc .t_up ; /
|
||||
or byte [esi+ecx+energized-1], 1<<1 ; left going left
|
||||
.t_up:
|
||||
bt eax, 3 ; /
|
||||
jnc .done ; ^
|
||||
or byte [esi+ecx+energized+1], 1<<0 ; right going right
|
||||
.done:
|
||||
jmp bkwd_for_chars_cont
|
||||
bkwd_mirror_two: ; \
|
||||
; our energized is what hits us
|
||||
; test right >\
|
||||
bt eax, 0
|
||||
jnc .t_left
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2 ; down char going down
|
||||
.t_left: ; \<
|
||||
bt eax, 1
|
||||
jnc .t_down
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3 ; up going up
|
||||
.t_down:
|
||||
bt eax, 2 ; v
|
||||
jnc .t_up ; \
|
||||
or byte [esi+ecx+energized+1], 1<<0 ; right going right
|
||||
.t_up:
|
||||
bt eax, 3 ; \
|
||||
jnc .done ; ^
|
||||
or byte [esi+ecx+energized-1], 1<<1 ; left going left
|
||||
.done:
|
||||
jmp bkwd_for_chars_cont
|
||||
bkwd_horz_split: ; -
|
||||
; our energized is what hits us
|
||||
; right and left propagate
|
||||
; test right
|
||||
bt eax, 0
|
||||
jnc .t_left
|
||||
or byte [esi+ecx+energized+1], 1<<0
|
||||
.t_left:
|
||||
bt eax, 1
|
||||
jnc .t_vert
|
||||
or byte [esi+ecx+energized-1], 1<<1
|
||||
; down and up go both left and right
|
||||
.t_vert:
|
||||
and eax, 1<<2 | 1<<3
|
||||
jz .done
|
||||
or byte [esi+ecx+energized+1], 1<<0 ; right going right
|
||||
or byte [esi+ecx+energized-1], 1<<1 ; left going left
|
||||
.done:
|
||||
jmp bkwd_for_chars_cont
|
||||
bkwd_vert_split: ; |
|
||||
; our energized is what hits us
|
||||
; down and up propagate
|
||||
; test down
|
||||
bt eax, 2
|
||||
jnc .t_up
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2
|
||||
.t_up:
|
||||
bt eax, 3
|
||||
jnc .t_vert
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3
|
||||
; left and right go both down and up
|
||||
.t_vert:
|
||||
and eax, 1<<0 | 1<<1
|
||||
jz .done
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2 ; down going down
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3 ; up going up
|
||||
.done:
|
||||
bkwd_for_chars_cont:
|
||||
dec ecx
|
||||
jnz bkwd_for_chars
|
||||
bkwd_for_chars_done:
|
||||
bkwd_for_lines_cont:
|
||||
sub esi, LINE_LEN
|
||||
jns bkwd_for_lines
|
||||
|
||||
cmp ebp, [last_energized]
|
||||
mov [last_energized], ebp
|
||||
jne next_iteration
|
||||
|
||||
|
||||
; print final
|
||||
xor ebp, ebp
|
||||
print_final:
|
||||
xor esi, esi ; top line
|
||||
.for_lines:
|
||||
xor ecx, ecx ; leftmost char
|
||||
.for_chars:
|
||||
movzx eax, byte [esi+ecx+energized]
|
||||
movzx ebx, byte [esi+ecx+file]
|
||||
test al, al
|
||||
jz .prnt_char
|
||||
inc ebp
|
||||
%ifdef FINAL_PRINT
|
||||
p_string ansi_color_highbold_green
|
||||
cmp bl, '.'
|
||||
jne .prnt_char
|
||||
popcnt edx, eax
|
||||
cmp edx, 1
|
||||
jg .prnt_num
|
||||
cmp al, 1
|
||||
je .prnt_right
|
||||
cmp al, 2
|
||||
je .prnt_left
|
||||
cmp al, 4
|
||||
je .prnt_down
|
||||
.prnt_up: mov al, '^'
|
||||
call print_char
|
||||
jmp .prnt_done
|
||||
.prnt_down: mov al, 'v'
|
||||
call print_char
|
||||
jmp .prnt_done
|
||||
.prnt_left: mov al, '<'
|
||||
call print_char
|
||||
jmp .prnt_done
|
||||
.prnt_right: mov al, '>'
|
||||
call print_char
|
||||
jmp .prnt_done
|
||||
.prnt_num:
|
||||
mov eax, edx
|
||||
call print_dec
|
||||
jmp .prnt_done
|
||||
%endif
|
||||
.prnt_char:
|
||||
%ifdef FINAL_PRINT
|
||||
mov al, [esi+ecx+file]
|
||||
call print_char
|
||||
.prnt_done:
|
||||
p_string ansi_color_reset
|
||||
%endif
|
||||
.for_chars_cont:
|
||||
inc ecx
|
||||
cmp ecx, LINE_LEN-2
|
||||
jbe .for_chars
|
||||
.for_chars_done:
|
||||
.for_lines_cont:
|
||||
%ifdef FINAL_PRINT
|
||||
call newline
|
||||
%endif
|
||||
add esi, LINE_LEN
|
||||
cmp esi, len(file)
|
||||
jb .for_lines
|
||||
%ifdef FINAL_PRINT
|
||||
mov eax, ebp
|
||||
call print_dec
|
||||
call newline
|
||||
call newline
|
||||
%endif
|
||||
cmp [final_value], ebp
|
||||
cmova ebp, [final_value]
|
||||
mov [final_value], ebp
|
||||
jmp next_edge_tile
|
||||
|
||||
game_over:
|
||||
mov eax, [final_value]
|
||||
call print_dec
|
||||
call newline
|
||||
jmp exit
|
||||
|
||||
[section .data]
|
||||
final_value: dd 0
|
||||
last_energized: dd 0
|
||||
test_edge_line: dd 0
|
||||
test_edge_col: dd 0
|
||||
test_edge_dir: dd 0
|
||||
file: incbin FILENAME
|
||||
.over:
|
||||
|
||||
[section .bss]
|
||||
padding: resb 128
|
||||
energized: resb 128*128
|
||||
|
||||
[section .rodata]
|
||||
what_the_fuck: db "Something is terribly wrong in this world."
|
||||
.over:
|
||||
ansi_color_reset: db `\e[0m`
|
||||
.over:
|
||||
ansi_color_green: db `\e[0;32m`
|
||||
.over:
|
||||
ansi_color_highbold_green: db `\e[1;92m`
|
||||
.over:
|
429
16/main_part1.s
Normal file
429
16/main_part1.s
Normal file
@@ -0,0 +1,429 @@
|
||||
%include "utils.s"
|
||||
|
||||
global _start
|
||||
[bits 32]
|
||||
[section .text]
|
||||
|
||||
%define LINE_LEN 111 ; real
|
||||
%define FILENAME "input"
|
||||
;%define LINE_LEN 11 ; test
|
||||
;%define FILENAME "input_test"
|
||||
|
||||
;%define ITER_PRINT
|
||||
|
||||
_start:
|
||||
|
||||
; bit 3 bit 2 bit 1 bit 0
|
||||
; up down left right
|
||||
|
||||
; top left starts going right
|
||||
mov byte [energized], 1
|
||||
|
||||
next_iteration:
|
||||
|
||||
%ifdef ITER_PRINT
|
||||
; debug printing
|
||||
dbg:
|
||||
xor esi, esi ; top line
|
||||
.for_lines:
|
||||
xor ecx, ecx ; leftmost char
|
||||
.for_chars:
|
||||
movzx eax, byte [esi+ecx+energized]
|
||||
movzx ebx, byte [esi+ecx+file]
|
||||
pushad
|
||||
test al, al
|
||||
jz .prnt_char
|
||||
p_string ansi_color_highbold_green
|
||||
cmp bl, '.'
|
||||
jne .prnt_char
|
||||
popcnt ecx, eax
|
||||
cmp ecx, 1
|
||||
jg .prnt_num
|
||||
cmp al, 1
|
||||
je .prnt_right
|
||||
cmp al, 2
|
||||
je .prnt_left
|
||||
cmp al, 4
|
||||
je .prnt_down
|
||||
.prnt_up: mov al, '^'
|
||||
call print_char
|
||||
jmp .prnt_done
|
||||
.prnt_down: mov al, 'v'
|
||||
call print_char
|
||||
jmp .prnt_done
|
||||
.prnt_left: mov al, '<'
|
||||
call print_char
|
||||
jmp .prnt_done
|
||||
.prnt_right: mov al, '>'
|
||||
call print_char
|
||||
jmp .prnt_done
|
||||
.prnt_num:
|
||||
mov eax, ecx
|
||||
call print_dec
|
||||
jmp .prnt_done
|
||||
.prnt_char:
|
||||
mov al, [esi+ecx+file]
|
||||
call print_char
|
||||
.prnt_done:
|
||||
p_string ansi_color_reset
|
||||
popad
|
||||
.for_chars_cont:
|
||||
inc ecx
|
||||
cmp ecx, LINE_LEN-2
|
||||
jbe .for_chars
|
||||
.for_chars_done:
|
||||
.for_lines_cont:
|
||||
call newline
|
||||
add esi, LINE_LEN
|
||||
cmp esi, len(file)
|
||||
jb .for_lines
|
||||
call newline
|
||||
; debug printing end
|
||||
%endif
|
||||
|
||||
xor esi, esi ; top line
|
||||
for_lines:
|
||||
xor ecx, ecx ; leftmost char
|
||||
for_chars:
|
||||
movzx eax, byte [esi+ecx+energized]
|
||||
movzx ebx, byte [esi+ecx+file]
|
||||
; skip if not energized
|
||||
test eax, eax
|
||||
jz for_chars_cont
|
||||
; select thing
|
||||
cmp bl, '.'
|
||||
je empty
|
||||
cmp bl, '/'
|
||||
je mirror_one
|
||||
cmp bl, '\'
|
||||
je mirror_two
|
||||
cmp bl, '-'
|
||||
je horz_split
|
||||
cmp bl, '|'
|
||||
je vert_split
|
||||
p_string what_the_fuck
|
||||
jmp exit
|
||||
empty: ; .
|
||||
; propagate
|
||||
; test right
|
||||
bt eax, 0
|
||||
jnc .t_left
|
||||
or byte [esi+ecx+energized+1], 1<<0
|
||||
.t_left:
|
||||
bt eax, 1
|
||||
jnc .t_down
|
||||
or byte [esi+ecx+energized-1], 1<<1
|
||||
.t_down:
|
||||
bt eax, 2
|
||||
jnc .t_up
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2
|
||||
.t_up:
|
||||
bt eax, 3
|
||||
jnc .done
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3
|
||||
.done:
|
||||
jmp for_chars_cont
|
||||
mirror_one: ; /
|
||||
; our energized is what hits us
|
||||
; test right >/
|
||||
bt eax, 0
|
||||
jnc .t_left
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3 ; up char going up
|
||||
.t_left: ; /<
|
||||
bt eax, 1
|
||||
jnc .t_down
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2 ; down going down
|
||||
.t_down:
|
||||
bt eax, 2 ; v
|
||||
jnc .t_up ; /
|
||||
or byte [esi+ecx+energized-1], 1<<1 ; left going left
|
||||
.t_up:
|
||||
bt eax, 3 ; /
|
||||
jnc .done ; ^
|
||||
or byte [esi+ecx+energized+1], 1<<0 ; right going right
|
||||
.done:
|
||||
jmp for_chars_cont
|
||||
mirror_two: ; \
|
||||
; our energized is what hits us
|
||||
; test right >\
|
||||
bt eax, 0
|
||||
jnc .t_left
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2 ; down char going down
|
||||
.t_left: ; \<
|
||||
bt eax, 1
|
||||
jnc .t_down
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3 ; up going up
|
||||
.t_down:
|
||||
bt eax, 2 ; v
|
||||
jnc .t_up ; \
|
||||
or byte [esi+ecx+energized+1], 1<<0 ; right going right
|
||||
.t_up:
|
||||
bt eax, 3 ; \
|
||||
jnc .done ; ^
|
||||
or byte [esi+ecx+energized-1], 1<<1 ; left going left
|
||||
.done:
|
||||
jmp for_chars_cont
|
||||
horz_split: ; -
|
||||
; our energized is what hits us
|
||||
; right and left propagate
|
||||
; test right
|
||||
bt eax, 0
|
||||
jnc .t_left
|
||||
or byte [esi+ecx+energized+1], 1<<0
|
||||
.t_left:
|
||||
bt eax, 1
|
||||
jnc .t_vert
|
||||
or byte [esi+ecx+energized-1], 1<<1
|
||||
; down and up go both left and right
|
||||
.t_vert:
|
||||
and eax, 1<<2 | 1<<3
|
||||
jz .done
|
||||
or byte [esi+ecx+energized+1], 1<<0 ; right going right
|
||||
or byte [esi+ecx+energized-1], 1<<1 ; left going left
|
||||
.done:
|
||||
jmp for_chars_cont
|
||||
vert_split: ; |
|
||||
; our energized is what hits us
|
||||
; down and up propagate
|
||||
; test down
|
||||
bt eax, 2
|
||||
jnc .t_up
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2
|
||||
.t_up:
|
||||
bt eax, 3
|
||||
jnc .t_vert
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3
|
||||
; left and right go both down and up
|
||||
.t_vert:
|
||||
and eax, 1<<0 | 1<<1
|
||||
jz .done
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2 ; down going down
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3 ; up going up
|
||||
.done:
|
||||
for_chars_cont:
|
||||
inc ecx
|
||||
cmp ecx, LINE_LEN-2
|
||||
jbe for_chars
|
||||
for_chars_done:
|
||||
for_lines_cont:
|
||||
add esi, LINE_LEN
|
||||
cmp esi, len(file)
|
||||
jb for_lines
|
||||
|
||||
xor ebp, ebp ; energized count
|
||||
sub esi, LINE_LEN ; last line
|
||||
; now go through backward
|
||||
bkwd_for_lines:
|
||||
mov ecx, LINE_LEN-2 ; rightmost char
|
||||
bkwd_for_chars:
|
||||
movzx eax, byte [esi+ecx+energized]
|
||||
movzx ebx, byte [esi+ecx+file]
|
||||
; skip if not energized
|
||||
test eax, eax
|
||||
jz bkwd_for_chars_cont
|
||||
inc ebp ; energized count
|
||||
; select thing
|
||||
cmp bl, '.'
|
||||
je bkwd_empty
|
||||
cmp bl, '/'
|
||||
je bkwd_mirror_one
|
||||
cmp bl, '\'
|
||||
je bkwd_mirror_two
|
||||
cmp bl, '-'
|
||||
je bkwd_horz_split
|
||||
cmp bl, '|'
|
||||
je bkwd_vert_split
|
||||
p_string what_the_fuck
|
||||
jmp exit
|
||||
bkwd_empty: ; .
|
||||
; propagate
|
||||
; test right
|
||||
bt eax, 0
|
||||
jnc .t_left
|
||||
or byte [esi+ecx+energized+1], 1<<0
|
||||
.t_left:
|
||||
bt eax, 1
|
||||
jnc .t_down
|
||||
or byte [esi+ecx+energized-1], 1<<1
|
||||
.t_down:
|
||||
bt eax, 2
|
||||
jnc .t_up
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2
|
||||
.t_up:
|
||||
bt eax, 3
|
||||
jnc .done
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3
|
||||
.done:
|
||||
jmp bkwd_for_chars_cont
|
||||
bkwd_mirror_one: ; /
|
||||
; our energized is what hits us
|
||||
; test right >/
|
||||
bt eax, 0
|
||||
jnc .t_left
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3 ; up char going up
|
||||
.t_left: ; /<
|
||||
bt eax, 1
|
||||
jnc .t_down
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2 ; down going down
|
||||
.t_down:
|
||||
bt eax, 2 ; v
|
||||
jnc .t_up ; /
|
||||
or byte [esi+ecx+energized-1], 1<<1 ; left going left
|
||||
.t_up:
|
||||
bt eax, 3 ; /
|
||||
jnc .done ; ^
|
||||
or byte [esi+ecx+energized+1], 1<<0 ; right going right
|
||||
.done:
|
||||
jmp bkwd_for_chars_cont
|
||||
bkwd_mirror_two: ; \
|
||||
; our energized is what hits us
|
||||
; test right >\
|
||||
bt eax, 0
|
||||
jnc .t_left
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2 ; down char going down
|
||||
.t_left: ; \<
|
||||
bt eax, 1
|
||||
jnc .t_down
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3 ; up going up
|
||||
.t_down:
|
||||
bt eax, 2 ; v
|
||||
jnc .t_up ; \
|
||||
or byte [esi+ecx+energized+1], 1<<0 ; right going right
|
||||
.t_up:
|
||||
bt eax, 3 ; \
|
||||
jnc .done ; ^
|
||||
or byte [esi+ecx+energized-1], 1<<1 ; left going left
|
||||
.done:
|
||||
jmp bkwd_for_chars_cont
|
||||
bkwd_horz_split: ; -
|
||||
; our energized is what hits us
|
||||
; right and left propagate
|
||||
; test right
|
||||
bt eax, 0
|
||||
jnc .t_left
|
||||
or byte [esi+ecx+energized+1], 1<<0
|
||||
.t_left:
|
||||
bt eax, 1
|
||||
jnc .t_vert
|
||||
or byte [esi+ecx+energized-1], 1<<1
|
||||
; down and up go both left and right
|
||||
.t_vert:
|
||||
and eax, 1<<2 | 1<<3
|
||||
jz .done
|
||||
or byte [esi+ecx+energized+1], 1<<0 ; right going right
|
||||
or byte [esi+ecx+energized-1], 1<<1 ; left going left
|
||||
.done:
|
||||
jmp bkwd_for_chars_cont
|
||||
bkwd_vert_split: ; |
|
||||
; our energized is what hits us
|
||||
; down and up propagate
|
||||
; test down
|
||||
bt eax, 2
|
||||
jnc .t_up
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2
|
||||
.t_up:
|
||||
bt eax, 3
|
||||
jnc .t_vert
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3
|
||||
; left and right go both down and up
|
||||
.t_vert:
|
||||
and eax, 1<<0 | 1<<1
|
||||
jz .done
|
||||
or byte [esi+ecx+energized+LINE_LEN], 1<<2 ; down going down
|
||||
or byte [esi+ecx+energized-LINE_LEN], 1<<3 ; up going up
|
||||
.done:
|
||||
bkwd_for_chars_cont:
|
||||
dec ecx
|
||||
jnz bkwd_for_chars
|
||||
bkwd_for_chars_done:
|
||||
bkwd_for_lines_cont:
|
||||
sub esi, LINE_LEN
|
||||
jns bkwd_for_lines
|
||||
|
||||
cmp ebp, [last_energized]
|
||||
mov [last_energized], ebp
|
||||
jne next_iteration
|
||||
|
||||
|
||||
; print final
|
||||
xor ebp, ebp
|
||||
print_final:
|
||||
xor esi, esi ; top line
|
||||
.for_lines:
|
||||
xor ecx, ecx ; leftmost char
|
||||
.for_chars:
|
||||
movzx eax, byte [esi+ecx+energized]
|
||||
movzx ebx, byte [esi+ecx+file]
|
||||
test al, al
|
||||
jz .prnt_char
|
||||
inc ebp
|
||||
p_string ansi_color_highbold_green
|
||||
cmp bl, '.'
|
||||
jne .prnt_char
|
||||
popcnt edx, eax
|
||||
cmp edx, 1
|
||||
jg .prnt_num
|
||||
cmp al, 1
|
||||
je .prnt_right
|
||||
cmp al, 2
|
||||
je .prnt_left
|
||||
cmp al, 4
|
||||
je .prnt_down
|
||||
.prnt_up: mov al, '^'
|
||||
call print_char
|
||||
jmp .prnt_done
|
||||
.prnt_down: mov al, 'v'
|
||||
call print_char
|
||||
jmp .prnt_done
|
||||
.prnt_left: mov al, '<'
|
||||
call print_char
|
||||
jmp .prnt_done
|
||||
.prnt_right: mov al, '>'
|
||||
call print_char
|
||||
jmp .prnt_done
|
||||
.prnt_num:
|
||||
mov eax, edx
|
||||
call print_dec
|
||||
jmp .prnt_done
|
||||
.prnt_char:
|
||||
mov al, [esi+ecx+file]
|
||||
call print_char
|
||||
.prnt_done:
|
||||
p_string ansi_color_reset
|
||||
.for_chars_cont:
|
||||
inc ecx
|
||||
cmp ecx, LINE_LEN-2
|
||||
jbe .for_chars
|
||||
.for_chars_done:
|
||||
.for_lines_cont:
|
||||
call newline
|
||||
add esi, LINE_LEN
|
||||
cmp esi, len(file)
|
||||
jb .for_lines
|
||||
call newline
|
||||
|
||||
game_over:
|
||||
mov eax, ebp
|
||||
call print_dec
|
||||
call newline
|
||||
jmp exit
|
||||
|
||||
[section .data]
|
||||
final_value: dd 0
|
||||
last_energized: dd 0
|
||||
file: incbin FILENAME
|
||||
.over:
|
||||
|
||||
[section .bss]
|
||||
padding: resb 128
|
||||
energized: resb 128*128
|
||||
|
||||
[section .rodata]
|
||||
what_the_fuck: db "Something is terribly wrong in this world."
|
||||
.over:
|
||||
ansi_color_reset: db `\e[0m`
|
||||
.over:
|
||||
ansi_color_green: db `\e[0;32m`
|
||||
.over:
|
||||
ansi_color_highbold_green: db `\e[1;92m`
|
||||
.over:
|
285
16/utils.s
Normal file
285
16/utils.s
Normal file
@@ -0,0 +1,285 @@
|
||||
[bits 32]
|
||||
[section .text]
|
||||
; call # val val2
|
||||
; int $0x80 eax eax edx -
|
||||
;
|
||||
; arg1 arg2 arg3 arg4 arg5 arg6 arg7
|
||||
; ebx ecx edx esi edi ebp -
|
||||
|
||||
exit:
|
||||
mov eax, 1 ; exit
|
||||
int 0x80
|
||||
|
||||
; filename in EBX
|
||||
; return handle in EBX
|
||||
; read only
|
||||
open_file:
|
||||
push eax
|
||||
push ecx
|
||||
mov eax, 5 ; open
|
||||
xor ecx, ecx ; read only
|
||||
int 0x80
|
||||
mov ebx, eax
|
||||
pop ecx
|
||||
pop eax
|
||||
ret
|
||||
|
||||
; file handle in EBX
|
||||
; buffer in ECX
|
||||
; count of bytes to read in EDX
|
||||
; return bytes actually read in EAX
|
||||
; exits on error
|
||||
read_file:
|
||||
mov eax, 3 ; read
|
||||
int 0x80
|
||||
test eax, eax
|
||||
js .err
|
||||
ret
|
||||
.err:
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov ecx, .err_str
|
||||
mov edx, 21
|
||||
int 0x80
|
||||
jmp exit
|
||||
.err_str: db `Could not read file.\n`
|
||||
|
||||
; string input in ESI
|
||||
; value in EAX
|
||||
; CF set if none, clear if some
|
||||
; ESI set past checked area
|
||||
dec_parse:
|
||||
push ebx
|
||||
push edx
|
||||
push edi
|
||||
xor eax, eax
|
||||
xor edi, edi
|
||||
mov ebx, 10 ; base
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .no_input
|
||||
cmp al, 9
|
||||
jle .got_char
|
||||
.no_input:
|
||||
stc ; set CF
|
||||
jmp .done
|
||||
.loop:
|
||||
xor eax,eax
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .dec_done
|
||||
cmp al, 9
|
||||
jg .dec_done
|
||||
.got_char:
|
||||
xchg edi,eax
|
||||
mul ebx
|
||||
add edi,eax
|
||||
jmp .loop
|
||||
.dec_done:
|
||||
clc ; clear CF
|
||||
.done:
|
||||
mov eax,edi
|
||||
pop edi
|
||||
pop edx
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; string input in ESI
|
||||
; value in EAX
|
||||
; CF set if none, clear if some
|
||||
; ESI set past checked area
|
||||
sign_dec_parse:
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
push edi
|
||||
xor eax, eax
|
||||
xor edi, edi
|
||||
xor ecx, ecx ; neg flag
|
||||
mov ebx, 10 ; base
|
||||
cmp byte [esi], '-'
|
||||
jne .no_minus
|
||||
inc esi
|
||||
mov cl, 1
|
||||
.no_minus:
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .no_input
|
||||
cmp al, 9
|
||||
jle .got_char
|
||||
.no_input:
|
||||
stc ; set CF
|
||||
jmp .done
|
||||
.loop:
|
||||
xor eax,eax
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .dec_done
|
||||
cmp al, 9
|
||||
jg .dec_done
|
||||
.got_char:
|
||||
xchg edi,eax
|
||||
mul ebx
|
||||
add edi,eax
|
||||
jmp .loop
|
||||
.dec_done:
|
||||
test ecx, ecx
|
||||
jz .not_neg
|
||||
neg edi
|
||||
.not_neg:
|
||||
clc ; clear CF
|
||||
.done:
|
||||
mov eax,edi
|
||||
pop edi
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; modifies no regs
|
||||
newline:
|
||||
pushad
|
||||
push 10
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov ecx, esp ; string
|
||||
mov edx, 1 ; length
|
||||
int 0x80
|
||||
add esp, 4
|
||||
popad
|
||||
ret
|
||||
; modifies no regs
|
||||
space:
|
||||
pushad
|
||||
push 9
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov ecx, esp ; string
|
||||
mov edx, 1 ; length
|
||||
int 0x80
|
||||
add esp, 4
|
||||
popad
|
||||
ret
|
||||
|
||||
; input in EAX, all regs unmodified
|
||||
print_dec:
|
||||
pushad ; save regs
|
||||
; max 4294967296 is 10 chars
|
||||
; round to nearest 32-bit boundary
|
||||
sub esp, 12
|
||||
; string in ECX, length in EDX
|
||||
lea ecx, [esp+11] ; last possible byte
|
||||
; check for 0
|
||||
test eax, eax
|
||||
jz .zero
|
||||
mov ebx, 10 ; base 10
|
||||
xor esi, esi ; counter
|
||||
.div_shit:
|
||||
xor edx, edx
|
||||
; divide
|
||||
div ebx
|
||||
dec ecx ; next char
|
||||
inc esi
|
||||
; store
|
||||
add dl, '0'
|
||||
mov byte [ecx], dl
|
||||
; check if done
|
||||
test eax, eax
|
||||
jnz .div_shit ; continue
|
||||
mov edx, esi ; counter in edx
|
||||
jmp .write
|
||||
.zero:
|
||||
mov byte [ecx], '0'
|
||||
mov edx, 1 ; length
|
||||
.write:
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
int 0x80
|
||||
add esp, 12 ; restore stack
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; input in EAX, all regs unmodified
|
||||
print_sign_dec:
|
||||
pushad ; save regs
|
||||
; range -2147483648 to 2147483647 is 11 chars
|
||||
; round to nearest 32-bit boundary
|
||||
sub esp, 12
|
||||
; string in ECX, length in EDX
|
||||
lea ecx, [esp+11] ; last possible byte
|
||||
; check for 0, negative
|
||||
xor ebp, ebp
|
||||
test eax, eax
|
||||
jz .zero
|
||||
jns .positive
|
||||
neg eax
|
||||
mov ebp, 1
|
||||
.positive:
|
||||
mov ebx, 10 ; base 10
|
||||
xor esi, esi ; counter
|
||||
.div_shit:
|
||||
xor edx, edx
|
||||
; divide
|
||||
div ebx
|
||||
dec ecx ; next char
|
||||
inc esi
|
||||
; store
|
||||
add dl, '0'
|
||||
mov byte [ecx], dl
|
||||
; check if done
|
||||
test eax, eax
|
||||
jnz .div_shit ; continue
|
||||
mov edx, esi ; counter in edx
|
||||
jmp .write
|
||||
.zero:
|
||||
mov byte [ecx], '0'
|
||||
mov edx, 1 ; length
|
||||
.write:
|
||||
test ebp, ebp
|
||||
jz .no_minus
|
||||
dec ecx
|
||||
inc edx
|
||||
mov byte [ecx], '-'
|
||||
.no_minus:
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
int 0x80
|
||||
add esp, 12 ; restore stack
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; input in ESI, len in ECX, all regs unmodified
|
||||
print_string:
|
||||
pushad ; save regs
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov edx, ecx ; length
|
||||
mov ecx, esi ; string
|
||||
int 0x80
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; input in AL, all regs unmodified
|
||||
print_char:
|
||||
pushad ; save regs
|
||||
push eax
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov edx, 1 ; length
|
||||
mov ecx, esp ; string
|
||||
int 0x80
|
||||
add esp, 4
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; --- MACROS ---
|
||||
%define len(x) x %+ .over - x
|
||||
%macro p_string 1
|
||||
push esi
|
||||
push ecx
|
||||
mov esi, %1
|
||||
mov ecx, len(%1)
|
||||
call print_string
|
||||
pop ecx
|
||||
pop esi
|
||||
%endmacro
|
3
17/Makefile
Normal file
3
17/Makefile
Normal file
@@ -0,0 +1,3 @@
|
||||
all:
|
||||
nasm -g -felf32 main.s && ld -melf_i386 -g main.o
|
||||
|
143
17/input
Normal file
143
17/input
Normal file
@@ -0,0 +1,143 @@
|
||||
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
||||
$545452221113224242466233542635423355626253426445443455757673665557347647355656433643746353634644662254525636256443646245624542442323123124434$
|
||||
$423123553224156354662663652662565323453542525447336537477575644434676433736577536377777334455463373535224645325663632555343244432114515143455$
|
||||
$412533154242243224353222366252356526355257367576363643744576774435663654744573466766563337774647645676664423643264353633522462246212343543534$
|
||||
$312324515521642422652636445534644554523665356655534343537375547744446437364446564476574363354465364444335526246456466465534642522545221525355$
|
||||
$431513132425342544645256323442532642676557544454577773477553376746647356735654457637736466555435447757676662446326565224355645426536544353433$
|
||||
$152515313256642445666534554544332644373336536336456577474544746374336345737444775367547736546647553566343437636426552263525243344634253243155$
|
||||
$135443325556463563643622655423352436666776776734633546375567453734754553445667477777766555547773656573443454755625255564266524452554644145234$
|
||||
$241513543232556336524232462424435737746743746575776755464666467353446767477357654573667646735353777447336743456434254233635466225242632525121$
|
||||
$442114466425542236636355532623577635665736777673573577436763575554353467744376756337466776666746547776573643366373454532562525346426364521212$
|
||||
$541155622643423523354262433657364363646354575667566357546477534336746476674745444646634665776653773333473375747756253522266653336465444335443$
|
||||
$315134623523366526522266354747643547566373676536336653534764337367777657666544734333553663574737675665473765764555363545425566323646362446212$
|
||||
$353142355424432653444565325346456566644744764673467744633777464737845775474776766376767444574545433637456635633567664644636222333626546663624$
|
||||
$315262562366632565525535545577665554665674353536337736534348577475484854557474447578374345363774654336434544754674634746633244226523442264433$
|
||||
$335545645535423623266436675456635746457674747674657776647557877646646675874757745664876653556564444533753335375443577665252425255534456546245$
|
||||
$553355652652264636363367377346645567667346557653434567688677545486848565546546665444456784473354343544647657374633433333555233425565253533356$
|
||||
$243333363523322443663544336473347367764656335567475568787767645554484767666557847484654575478446467365374457346344653755573346552525256565322$
|
||||
$666223435352636335653467647754757343776765635446446788867658547858868785684748487568855845688555756333373536554535476756744646434652424342333$
|
||||
$645455232354462344243445636673564336664747664878865467785568865677886748754847884644784467558578757766455653753346354754754655533565264232532$
|
||||
$466264662434546564673354575575444753656373744566465676768746765458687768457555786448878877475448775543545436357333657537436536626255346662656$
|
||||
$654524643332325657443773473345666645437437457786476648665876645875844657466548548677668648768478465858346357657453545354733536252225236325324$
|
||||
$245235543533534454757574456473757344733876884576864756557877774546778774555757444877858775558546876676464645537473477737556335324623665264554$
|
||||
$552235662634536547455366376357656336444664848888574766754875756656755876868444465858655555676566668664686665663544655356774567736546326366635$
|
||||
$353542423524446556643335547536347646576756685775676766655557774844768557867884484585678554847845646654865854437565545635345436754335643323263$
|
||||
$326635253342553646346557637354574467764875575745775547574584574755667545768464448746656755546475444547874465334763664737345747437656333254563$
|
||||
$653335566256277556643667467346775367576846755455468867867557557555887765578448878848456454866856764644668486873436476677765536767642445626356$
|
||||
$353255366565746364356754435755657577566867745558644476548588748884548574488784666876485787774565875677468876756676547447547545755532634442565$
|
||||
$526256464444756734475435756673776484768854466755657745844446568666657957857746556588454768855565754764675454455437656334744533657457623236224$
|
||||
$345546363576475673635365446743587548544658648758765765475847775665595995997557889547584448655877685856876666444644644334674665743567346233266$
|
||||
$533654332435774354776646364446474846575477447574584776856576779765587966968987698878988545587567868486876764888877575753575453556376745642566$
|
||||
$633636424573637734764776635667487684676748668665568566866889869557556755989955889797856987487464457458644645786764873746476745365753365432463$
|
||||
$436434525766744544555467765487678745586567856888558789667967898667788975588775596575969899765767668556484474454574865565553453736343757423566$
|
||||
$562564353763677646656565447585778775865488767878759868968558979588977867688659588986697765665477854856584885664466675345566465573666456355365$
|
||||
$232544366666336545573336765565884686888688676464687896586586865697669996659769557995958979656645555844656646558777648564373757645766465564263$
|
||||
$325226433577434645734663776868484484574546847759659798668887755976978658579669665775876995696766765667567564857767757436736433534574356375464$
|
||||
$233434647657566365675564855678657456764555868565669776899967977985978785677658977569987558877878886856748745484877655877536777645733565672553$
|
||||
$346247373476565353376638555656666547878646777776699966987887775565755667655885557989588579667655656868844566557565885884763657647737363335464$
|
||||
$532243475547755575777345844444764678745788878877675956599689759687889958677777568677756559957698788764847454855744856566777557736766676435464$
|
||||
$262676537574457653774457566747874566475585789698955597778655878869799695678789958999766885657857566894858485757754485588476476734355556634663$
|
||||
$554273745665445654454755465755788884874769777895865665659996575789596765989769785679566759565995579779754867476767446844747337344367377354722$
|
||||
$223443465575665667345468464778664565646768567659578566988667856788688568878858975798856895758586987665776878777467678677846363447364466655752$
|
||||
$356675376476767636478486488564575777675577587995586676557599976687578955896587568597887786867768768799584654454457787674446666776457355366334$
|
||||
$446346746755447335376878747444548484767989866757676988577659767879598868996657877558889985695985588655575884455566754554678576776575736753747$
|
||||
$554354566643337445757665664854558565869858866656857656695755689989897768888898967697656665688856899957759956444477448748884634353575536635376$
|
||||
$534454344735356453685855755866568857866855877775658577698557768996777867979869796665786759779765759587979888785478444554847485657467766647545$
|
||||
$443436776547774645468645577867656488896978758777798895598889679866888688869967986666655558857856758797976585648874675868764677345555644357543$
|
||||
$257746743747434447467858858468464667666857679685959656776766788988696989987877767689978775665995977695959698477585465847875658656777474576447$
|
||||
$645547747335346637656657768676586568997777755987596665968768787877997778697867879896899888669887779959895769844445545565666568367653644677547$
|
||||
$553466736466736684746886666654678758976976679578775799668666689897777666887669787796967877596969796967796888966448555755588488566576673775433$
|
||||
$776446577567576687686786446648658876958999656689977798667789899869887868779686996797769789857565999575769965795557567748557544647767643763474$
|
||||
$445356637656674775556644475678659975969567657958685979868977878989668969687788668968878769775976789797698975665486687555884857456546534543563$
|
||||
$463645333465775785746547746866865768899858897765787788669686689668888676768786776797687678987958668775876759975857585586487667853553464535457$
|
||||
$564477673374747676645744768548578875768658857689997867667699686677789987896686787796899786989869758579587756857588556884768666757763734637656$
|
||||
$753556345564735887488486654567965956577557956858677778979967788997886678979888678999679867786776689598666566999857586845478647775545436555553$
|
||||
$345365637574455675565456864445579975865657859877896789776886696797878887676788766779699976687768989758796767975696688486546867688535773437576$
|
||||
$563643757353635744777558764668598788688667657587699768679877688999788976678779987678888899988696779888988599798896845755458568487466666645664$
|
||||
$543444466456568748754448767568587899956585778776877666796699889797797698667887698787866798988969666759756886776686778745884658447476754743675$
|
||||
$775555364536476764685787847556888796868878858669787979898869969899798699976896877676666868866868676677787775667578585574574466774833577574646$
|
||||
$634564673656787575774464768665888587665968667897896986988997878998889897878779887897997869989668679679957889756995447574784558575577733545643$
|
||||
$577736376747365476448748478477796768757799598789868889798968776688779897897789868968889799788966888869898975668865987448565667558857736635643$
|
||||
$466345746537546444778477645588885858759799788669769866667686687799778787887998988778696998968788686886759968759855878458545755745583464766353$
|
||||
$367655547534675485475587886859656798596775967889999876777668999898997779779999977967889897689698666959958577896968754558887878487466364554457$
|
||||
$653764635533546656444544748669777855769689666767996998967768787987877997777789877879797669966789688659586895965976884575646866457567553356675$
|
||||
$446653547537785576645688746776557769889589679688779797969868988999887999799878887798996677697677978795956576655686964586475875475887577735776$
|
||||
$344564775776467555666785757659665856977858698769987778997678797998997999999897899987886899987688889897695889685799576867746777467646546576365$
|
||||
$654736333377688685576656654998969878958759867686996898766689989879877978777889778787868686788887869786797867597879898644784877645754354536375$
|
||||
$767747647435455487886768675697877659896578787788669769779799998887879887889788888997789687686768666868776559656566955647588756888764347454776$
|
||||
$774457766435866645686575458679965688767955998897969876799898877798778987778797797888997778868978867995859657556696594555667474878485536473347$
|
||||
$366445576358856847557447789956599979755857769987889697967987878888879779878778977978986998889968887667768699579866588587785767748754376363554$
|
||||
$766344743577475764568847579997598855976966669699688996999998987878789798788998777778898668697689869778596566556756677764576558674474576657474$
|
||||
$736745557656466465485456767695967885795567669968688899788877778797997779788799999888779699767799986898695888998859665878677555646544465653554$
|
||||
$577753734565685574848584466665798865998576787897887876898999799789897997898988879777977976686779986687656986997797786567785888786465457333447$
|
||||
$543537356746774554476444747757978996777959898679879879898977897778987978898988989978978897768898866666796995878796566477765667684545335437676$
|
||||
$437766576438547766556675687655968789988677789998678687769788997898888998987997777989979796877677699676678769556989886464447864567655446374465$
|
||||
$774667644357778464657467446768777587599896669768898996799998899788777877898778789789886686796669799666668777585998986876745458765677776336474$
|
||||
$673456737734575477884884555698977778886667898889798678889979888778788778978887888777789669779686678965957559675775777488875554667477337777664$
|
||||
$665743475468848468864485465868588566687856668986879966888979797778988898997999899999898796978989787969699597586995555564868557476684777756734$
|
||||
$646554756444674645545745554559686885658675878898988999988988999789988998987879997879776797879869887967979579868767585566467556584857466573677$
|
||||
$364764647433677788866778744599756867979797699869867787666678777898999787898989797789767698987787689975759897675779695758585566676486736437565$
|
||||
$535657367676788744488555688866567598959667976889768897689998888978878888799897997777877889778777976969959559979798875545858676548565476756446$
|
||||
$633363763563454644784858847895797557969965876677987878976787878779988997777977799998877787677976867878977587865957557486665588466457543463635$
|
||||
$375433566546784568846466745598558655679968776668798787899889779877878988779887997778797888678778996867596666657866874675645464786473443555447$
|
||||
$434655743646446455646846467678988778555555686866869776667867788797877999888887888976676979997998988976998588698965984485774787566574577553376$
|
||||
$757663464775848684556667686775675566755668979679877689867998687897999788888899797969769667797686789969697795968885567685786664865545733646333$
|
||||
$436536333433585884585488446757557568878876857999666686869666787778897988977877887686867777689966698889899988598867685787566778656564477735445$
|
||||
$436574534734348886888756757498889965758885899878987888866677979798879779777899977868767868996877788995778656675966566755867567565574633456555$
|
||||
$564764653563688455554454885545886885979986956966688986677768987888887788888986967968696889979678777755778658995959858577865848685846647676536$
|
||||
$774666566543587578854654454459798858796687579678788997996798879976879988877696966976978868687797675777579588669865747866555654646757563764356$
|
||||
$334653746666747767874888446759658578686597896567669986768687786769869666679968799886689699667888658865797857988986544445767866746843445663555$
|
||||
$775344654767678685848468464575877876687899677597996789798676698776979787769968688886967768966777857569696867798987665668774554657436543557567$
|
||||
$766543343765565746568886858757686865568578796657979967896798688987979798966679878979878987979679598685776666567766775448885878555657665547357$
|
||||
$636655364436434455888845888778685568678599896776668766887767676667867787968869876966876666689866987776969877858886687745584764557354464333464$
|
||||
$675765663744534578545687478578698557858656798867678988867967999777996889699687796687898679786896785675995877868655448555846488877754667477734$
|
||||
$376666657777454776866467685478859857875585897867777886776668979799679889766696977797676899977576857679985779975754888884877866665753763656567$
|
||||
$553656636455355675644444444747459698859777767998579698866968997767787668988968899867897668767998695767758686979684446467848778567374445455366$
|
||||
$754746745637544445664687865676568868689986785689987697689689969698679786996868877777898786786677866785998778985766777464665886563347736757447$
|
||||
$744657466646636774744445554675666676868675955555767858786996667879668878978868776888798796869879978857865577996565788644766846855557536433763$
|
||||
$446745655755373767857866885858587788668877866696695565989667697677966767697869689788978969797665869856666577584454657576664775376733565354756$
|
||||
$654636755367566664586687484447778479787695578876796699778799789899898676987968866887987986956877768755999996846745684654755648755434654444754$
|
||||
$635344556537573455855776668478688447578999955979699999695669968667779887688976668788756786965858995755576656777877658545555555647667534575366$
|
||||
$435747556465374336665458878467447445675959779776975698666756899678787988689897869778795885896759756577958888884545566466868655534765435574357$
|
||||
$437767766643564433747554467577668757587776755668689999998555765778667999677696988696955786556876667667988974746747864478454737537664677453677$
|
||||
$664347635467563437656868568685484468455677569986876985879577699879986797878559965665568857786598876697898847446667476764656445454547563774635$
|
||||
$335453357433477464545778558588687458646696878686798565588759596859598855679658897766897786687897896866587457546877768774845653576735343735752$
|
||||
$655777543774646674548678844477675556474688567958786967887956958887675987768675555986588965589688887889886444888584878476586567343575354445663$
|
||||
$235453363477465436646567678856678577655849767566798556879779898997989755658656559688876996696676858559457557464577456788673465676535365674745$
|
||||
$653557535667556645354467867774587468586488865599677669989755886567678697988757889697878875858955878776457675775448445776473464477477767663723$
|
||||
$423647457774664567367567688588786455886875877685666999576569666558878966575579888958887568875959897748876746485847657558833665657763667534445$
|
||||
$642244736374347334553476484454457886864876777558556996776685999679967876675775769557785885758655565867454657858447768578474753663535574334625$
|
||||
$336436733375445675473664646565856555648864767887656769899695675757975675565687699957587897798858758888587654455645575843733477364463637346554$
|
||||
$335435534663443676666667487578676657684784777487588895569858889859686655956678559995599665976775765566474568674477774565755333637557456443362$
|
||||
$544553574555543574737357456786577646746577857444859685759965869665959565775665768787565556566764745674557877684464784337435554455363447424542$
|
||||
$532466367673434664644354657754588778676755775886768666885868799568878785557855988668678578786766445778646767754547786674353344647665577622636$
|
||||
$254546266574455447676333746874647468845746684454766755965578588856776657996755995866665756584754744857764888446555686474747766466477373363255$
|
||||
$266564352377575777574547445766866788765476854777647777755855596796559556988877659996958566787777584545576775754474473767554467654656553554332$
|
||||
$522256355666446675564456747738664767486874667675476687786478896698989959668656659687968467645876545646468576457566664435353565756335325455423$
|
||||
$444323436545645543755363664545566464457866856586678787858786757778956969568579798946747584467867878657848746487767644665534735673753556344635$
|
||||
$323454432324636457364755566663657568465848475587778876786656855775678985985658687848774858847777567884787865845753573673347657574545444662333$
|
||||
$634265532422373635667776375763433576454587888546578776578558775467647857865566478665585765455686464585664454657577753367736355637473456622255$
|
||||
$622652422623346667557377766536775386775555647476757786588468585876875775475874454678454778445754858785856648473657737554774554374752234543644$
|
||||
$626444363465537553657447547553534338748756846655465484858676444775654756856447485566556646575845685575686466474566556633663543776752343555663$
|
||||
$535442263436653363546357777754675735775658785476758746846756747484788667788686756847555568587746787644556655745755367533554735377434563655355$
|
||||
$554342625636334436643667447345746337765466846668685587767846687654478458468576565878864858748845754784458634476773434474546454344452263624345$
|
||||
$565345336254245667667673464644643655375486646848574888844888558867884754554747767566586664467557686445654336335375474476363464323325434436625$
|
||||
$332442354652352554553756635666445463456537777656657588588744485464885685786874588448866685887758677684775654736344634537577646434553463233633$
|
||||
$264423644454226544363333743363353543453764748557767447766744574745865865746448687884547865745856555847664474444567466455356545323344624233336$
|
||||
$624364424324325525254434475736744543756757746455757545887885684854876555585578764754564576867554753746356355666473343373737424256554255423523$
|
||||
$662433222232665256245775334733557673537364464544457667464687655758776565487564647678487555685857676544475746676457447467754565543233223432355$
|
||||
$335526225663422356565753436745336336337473673334447858766557576685575848668868544646668474687675476677666534474734376777532524234366425532456$
|
||||
$224434544223322234353647375646454645545464356533655787476846747488548474786866778666778547634433667755755733766475767655364426634454342243225$
|
||||
$115343665234633546565263376447534744657646576367346453768575867668478755786458868487856743347563663553647377756353665654344434266256634336435$
|
||||
$542522653445666245465264554744743545554757337454635474734676576664554868545884455857744457443343774776545543664436646636526654445346625264641$
|
||||
$212345454243326345366432525643537663566453477653467557566745535745888465744676443367676664343457436353346547364465644462456633524632446434245$
|
||||
$152256444334346664644636266764544353565677537647674477765463657665645367433374777437633774465675755553674563647647452223353432253226324623542$
|
||||
$543314543643455255443324653447436466475546347473733756375574455574647736546663676737753633747536667644363433373577625266565562536523653263531$
|
||||
$323324156556533366424334223663556664354675665737455445654473743546365645433344367436563477354677564675374746774552632626523436564364436333125$
|
||||
$235252143234364223446642636543224575373637463676356753733454753456563336535346777535556775743565435544465673644434525462634226464524365541444$
|
||||
$132152313563645443345466655333626644763757433545675545554636757343657777557575474647543744454353557547677667745433252345352224344346244251442$
|
||||
$145324252553642322332363652223266265665333337557545545565467373344435373577653536363764744455463574577733745442455342654643644622632454545141$
|
||||
$532551554325522544422365464343624222657554543453736435733353775644654357356557335773453777745644576533447446326624326254632635265444511254421$
|
||||
$231415354245432533366263463246653334334533336463333665345436677477356745734756355353637773745467756534536353223454622442252244524633251135155$
|
||||
$115313455335154364554632663442562633255536347755433457547673466773633747543655343555654635633737643533463222323433222456626424343225333455422$
|
||||
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
15
17/input_test
Normal file
15
17/input_test
Normal file
@@ -0,0 +1,15 @@
|
||||
$$$$$$$$$$$$$$$
|
||||
$2413432311323$
|
||||
$3215453535623$
|
||||
$3255245654254$
|
||||
$3446585845452$
|
||||
$4546657867536$
|
||||
$1438598798454$
|
||||
$4457876987766$
|
||||
$3637877979653$
|
||||
$4654967986887$
|
||||
$4564679986453$
|
||||
$1224686865563$
|
||||
$2546548887735$
|
||||
$4322674655533$
|
||||
$$$$$$$$$$$$$$$
|
422
17/main.s
Normal file
422
17/main.s
Normal file
@@ -0,0 +1,422 @@
|
||||
%include "utils.s"
|
||||
|
||||
global _start
|
||||
[bits 32]
|
||||
[section .text]
|
||||
|
||||
; len +2 for padding
|
||||
%define LINE_LEN (141+2)
|
||||
%define FILENAME "input"
|
||||
;%define LINE_LEN (13+2)
|
||||
;%define FILENAME "input_test"
|
||||
|
||||
%define DBG_PRINT
|
||||
|
||||
_start:
|
||||
|
||||
; convert input file to useful data
|
||||
mov esi, file
|
||||
mov edi, cost
|
||||
convert_input:
|
||||
lodsb
|
||||
cmp al, 10 ; \n
|
||||
je .cont
|
||||
cmp al, '$'
|
||||
jne .num
|
||||
mov al, 0xFF
|
||||
stosb
|
||||
jmp .cont
|
||||
.num:
|
||||
sub al, '0'
|
||||
stosb
|
||||
.cont:
|
||||
cmp esi, file.over
|
||||
jb convert_input
|
||||
|
||||
; im lazy so doing dijkstra
|
||||
; thanks wikipedia
|
||||
|
||||
; for each vertex v in Graph.Vertices:
|
||||
; dist[v] ← INFINITY
|
||||
; prev[v] ← UNDEFINED
|
||||
; add v to Q
|
||||
mov ecx, LINE_LEN*LINE_LEN*32
|
||||
mov eax, 0xffffffff
|
||||
mov edi, dist
|
||||
rep stosd
|
||||
mov ecx, LINE_LEN*LINE_LEN*32
|
||||
mov eax, 0xffffffff
|
||||
mov edi, prev
|
||||
rep stosd
|
||||
mov ecx, LINE_LEN*LINE_LEN*32
|
||||
mov eax, 1
|
||||
mov edi, q
|
||||
rep stosb
|
||||
|
||||
; for all real dir:
|
||||
; dist[source@dir] ← 0
|
||||
mov dword [dist+((((LINE_LEN*32)+(32*1)))|0b00_000)*4], 0
|
||||
mov dword [dist+((((1*(LINE_LEN*32))+(32*1)))|0b10_000)*4], 0
|
||||
|
||||
|
||||
|
||||
; while Q is not empty and any dist[u] in Q < inf:
|
||||
; u ← vertex in Q with min dist[u]
|
||||
while_q:
|
||||
xor ebp, ebp ; test node
|
||||
mov ecx, 0xffffffff ; best dist
|
||||
mov edx, 0xffffffff ; best node
|
||||
.find_min:
|
||||
cmp byte [q+ebp], 1
|
||||
jne .cont
|
||||
cmp [dist+ebp*4], ecx
|
||||
cmovb ecx, [dist+ebp*4]
|
||||
cmovb edx, ebp
|
||||
.cont:
|
||||
inc ebp
|
||||
cmp ebp, LINE_LEN*LINE_LEN*32
|
||||
jb .find_min
|
||||
cmp ecx, 0xffffffff
|
||||
je while_q_done
|
||||
|
||||
%ifdef DBG_PRINT
|
||||
pushad
|
||||
call newline
|
||||
mov ebp, edx
|
||||
mov eax, edx
|
||||
xor edx, edx
|
||||
shr eax, 5
|
||||
mov ebx, LINE_LEN
|
||||
div ebx
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, edx
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, ebp
|
||||
and eax, 0b11111
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, ecx
|
||||
call print_dec
|
||||
call newline
|
||||
popad
|
||||
%endif
|
||||
|
||||
; remove u from Q
|
||||
mov byte [q+edx], 0
|
||||
|
||||
; for each neighbor v of u still in Q:
|
||||
; alt ← dist[u] + Graph.Edges(u, v)
|
||||
; if alt < dist[v]:
|
||||
; dist[v] ← alt
|
||||
; prev[v] ← u
|
||||
mov ebp, LINE_LEN*32 ; whatever
|
||||
for_neighbor:
|
||||
; turning neighbor 0
|
||||
neighbor_0:
|
||||
; neighbors += v@dir(u, ~u.dir & 0b10_000)
|
||||
mov ebx, edx
|
||||
not ebx
|
||||
and ebx, 0b10000
|
||||
; tmp := 32
|
||||
mov edi, 32
|
||||
; bt dir, 4
|
||||
bt ebx, 4
|
||||
; if CF tmp := LINE_LEN
|
||||
cmovc edi, ebp
|
||||
; bt dir, 3
|
||||
; if CF tmp := -tmp
|
||||
mov esi, edi
|
||||
neg esi
|
||||
bt ebx, 3
|
||||
cmovc edi, esi
|
||||
mov eax, edi
|
||||
; v.dir := dir
|
||||
or edi, ebx
|
||||
; v := u + tmp
|
||||
; CheckBounds(v)
|
||||
; Graph.Edges(u, v) := cost(v)
|
||||
; v := v + tmp
|
||||
; CheckBounds(v)
|
||||
; Graph.Edges(u, v) += cost(v)
|
||||
; v := v + tmp
|
||||
; CheckBounds(v)
|
||||
; Graph.Edges(u, v) += cost(v)
|
||||
; v := v + tmp
|
||||
; CheckBounds(v)
|
||||
; Graph.Edges(u, v) += cost(v)
|
||||
mov ebx, eax
|
||||
mov esi, edx
|
||||
and esi, ~0b11111
|
||||
add edi, esi ; v := u + tmp
|
||||
mov eax, edi
|
||||
shr eax, 5
|
||||
movzx eax, byte [cost+eax]
|
||||
cmp al, 0xff
|
||||
je neighbor_1 ; off graph
|
||||
mov esi, eax ; Graph.Edges(u, v) := cost(v)
|
||||
add edi, ebx ; v := v + tmp
|
||||
mov eax, edi
|
||||
shr eax, 5
|
||||
movzx eax, byte [cost+eax]
|
||||
cmp al, 0xff
|
||||
je neighbor_1 ; off graph
|
||||
add esi, eax ; Graph.Edges(u, v) += cost(v)
|
||||
add edi, ebx ; v := v + tmp
|
||||
mov eax, edi
|
||||
shr eax, 5
|
||||
movzx eax, byte [cost+eax]
|
||||
cmp al, 0xff
|
||||
je neighbor_1 ; off graph
|
||||
add esi, eax ; Graph.Edges(u, v) += cost(v)
|
||||
add edi, ebx ; v := v + tmp
|
||||
mov eax, edi
|
||||
shr eax, 5
|
||||
movzx eax, byte [cost+eax]
|
||||
cmp al, 0xff
|
||||
je neighbor_1 ; off graph
|
||||
add esi, eax ; Graph.Edges(u, v) += cost(v)
|
||||
; alt ← dist[u] + cost(v)
|
||||
; if alt < dist[v]:
|
||||
; dist[v] ← alt
|
||||
; prev[v] ← u
|
||||
add esi, ecx
|
||||
%ifdef DBG_PRINT
|
||||
pushad
|
||||
call space
|
||||
mov esi, eax
|
||||
mov eax, edi
|
||||
shr eax, 5
|
||||
mov ecx, LINE_LEN
|
||||
xor edx, edx
|
||||
div ecx
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, edx
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, edi
|
||||
and eax, 0x1f
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, esi
|
||||
call print_dec
|
||||
call newline
|
||||
popad
|
||||
%endif
|
||||
cmp esi, [dist+edi*4]
|
||||
jae neighbor_1 ; not better
|
||||
mov [dist+edi*4], esi
|
||||
mov [prev+edi*4], edx
|
||||
; turning neighbor 1
|
||||
neighbor_1:
|
||||
; neighbors += v@dir(u, (~u.dir & 0b10_000) | 0b01_000)
|
||||
mov ebx, edx
|
||||
not ebx
|
||||
and ebx, 0b10000
|
||||
or ebx, 0b01000
|
||||
; tmp := 32
|
||||
mov edi, 32
|
||||
; bt dir, 4
|
||||
bt ebx, 4
|
||||
; if CF tmp := LINE_LEN
|
||||
cmovc edi, ebp
|
||||
; bt dir, 3
|
||||
; if CF tmp := -tmp
|
||||
mov esi, edi
|
||||
neg esi
|
||||
bt ebx, 3
|
||||
cmovc edi, esi
|
||||
mov eax, edi
|
||||
; v.dir := dir
|
||||
or edi, ebx
|
||||
; v := u + tmp
|
||||
; CheckBounds(v)
|
||||
; Graph.Edges(u, v) := cost(v)
|
||||
; v := v + tmp
|
||||
; CheckBounds(v)
|
||||
; Graph.Edges(u, v) += cost(v)
|
||||
; v := v + tmp
|
||||
; CheckBounds(v)
|
||||
; Graph.Edges(u, v) += cost(v)
|
||||
; v := v + tmp
|
||||
; CheckBounds(v)
|
||||
; Graph.Edges(u, v) += cost(v)
|
||||
mov ebx, eax
|
||||
mov esi, edx
|
||||
and esi, ~0b11111
|
||||
add edi, esi ; v := u + tmp
|
||||
mov eax, edi
|
||||
shr eax, 5
|
||||
movzx eax, byte [cost+eax]
|
||||
cmp al, 0xff
|
||||
je neighbor_2 ; off graph
|
||||
mov esi, eax ; Graph.Edges(u, v) := cost(v)
|
||||
add edi, ebx ; v := v + tmp
|
||||
mov eax, edi
|
||||
shr eax, 5
|
||||
movzx eax, byte [cost+eax]
|
||||
cmp al, 0xff
|
||||
je neighbor_2 ; off graph
|
||||
add esi, eax ; Graph.Edges(u, v) += cost(v)
|
||||
add edi, ebx ; v := v + tmp
|
||||
mov eax, edi
|
||||
shr eax, 5
|
||||
movzx eax, byte [cost+eax]
|
||||
cmp al, 0xff
|
||||
je neighbor_2 ; off graph
|
||||
add esi, eax ; Graph.Edges(u, v) += cost(v)
|
||||
add edi, ebx ; v := v + tmp
|
||||
mov eax, edi
|
||||
shr eax, 5
|
||||
movzx eax, byte [cost+eax]
|
||||
cmp al, 0xff
|
||||
je neighbor_2 ; off graph
|
||||
add esi, eax ; Graph.Edges(u, v) += cost(v)
|
||||
; alt ← dist[u] + cost(v)
|
||||
; if alt < dist[v]:
|
||||
; dist[v] ← alt
|
||||
; prev[v] ← u
|
||||
add esi, ecx
|
||||
%ifdef DBG_PRINT
|
||||
pushad
|
||||
call space
|
||||
mov esi, eax
|
||||
mov eax, edi
|
||||
shr eax, 5
|
||||
mov ecx, LINE_LEN
|
||||
xor edx, edx
|
||||
div ecx
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, edx
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, edi
|
||||
and eax, 0x1f
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, esi
|
||||
call print_dec
|
||||
call newline
|
||||
popad
|
||||
%endif
|
||||
cmp esi, [dist+edi*4]
|
||||
jae neighbor_2 ; not better
|
||||
mov [dist+edi*4], esi
|
||||
mov [prev+edi*4], edx
|
||||
; straight - neighbor 2
|
||||
neighbor_2:
|
||||
mov ebx, edx
|
||||
and ebx, ~0b11111
|
||||
cmp edx, (((LINE_LEN*32)+(32*1)))
|
||||
je while_q_cont
|
||||
; if u.dir & 0b00_111 < 6
|
||||
; neighbors += v@dir(u, u.dir + 1)
|
||||
mov ebx, edx
|
||||
and ebx, 0b00111
|
||||
cmp ebx, 6
|
||||
jae while_q_cont ; neighbors done
|
||||
mov ebx, edx
|
||||
and ebx, 0b11111
|
||||
inc ebx
|
||||
; tmp := 32
|
||||
mov edi, 32
|
||||
; bt dir, 4
|
||||
bt ebx, 4
|
||||
; if CF tmp := LINE_LEN
|
||||
cmovc edi, ebp
|
||||
; bt dir, 3
|
||||
; if CF tmp := -tmp
|
||||
mov esi, edi
|
||||
neg esi
|
||||
bt ebx, 3
|
||||
cmovc edi, esi
|
||||
; v := u + tmp
|
||||
mov esi, edx
|
||||
and esi, ~0b11111
|
||||
add edi, esi
|
||||
; v.dir := dir
|
||||
or edi, ebx
|
||||
; alt ← dist[u] + cost(v)
|
||||
; if alt < dist[v]:
|
||||
; dist[v] ← alt
|
||||
; prev[v] ← u
|
||||
mov eax, edi
|
||||
shr eax, 5
|
||||
movzx eax, byte [cost+eax]
|
||||
cmp al, 0xff
|
||||
je while_q_cont ; off graph
|
||||
add eax, ecx
|
||||
%ifdef DBG_PRINT
|
||||
pushad
|
||||
call space
|
||||
mov esi, eax
|
||||
mov eax, edi
|
||||
shr eax, 5
|
||||
mov ecx, LINE_LEN
|
||||
xor edx, edx
|
||||
div ecx
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, edx
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, edi
|
||||
and eax, 0x1f
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, esi
|
||||
call print_dec
|
||||
call newline
|
||||
popad
|
||||
%endif
|
||||
cmp eax, [dist+edi*4]
|
||||
jae while_q_cont ; not better
|
||||
mov [dist+edi*4], eax
|
||||
mov [prev+edi*4], edx
|
||||
|
||||
while_q_cont:
|
||||
jmp while_q
|
||||
|
||||
while_q_done:
|
||||
|
||||
call newline
|
||||
|
||||
; last dist values
|
||||
mov ebx, ((((LINE_LEN-2)*(LINE_LEN*32))+((LINE_LEN-2)*32))+0b00000)
|
||||
print_last_dist:
|
||||
mov eax, [dist+ebx*4]
|
||||
call print_sign_dec
|
||||
inc ebx
|
||||
mov ecx, ebx
|
||||
and ecx, 0b111
|
||||
cmp ecx, 0b111
|
||||
jne .space
|
||||
call newline
|
||||
mov ecx, ebx
|
||||
and ecx, 0b11111
|
||||
cmp ecx, 0b11111
|
||||
je .done
|
||||
inc ebx
|
||||
jmp .cont
|
||||
.space:
|
||||
call space
|
||||
.cont:
|
||||
jmp print_last_dist
|
||||
.done:
|
||||
|
||||
game_over:
|
||||
jmp exit
|
||||
|
||||
[section .data]
|
||||
file: incbin FILENAME
|
||||
.over:
|
||||
|
||||
[section .bss]
|
||||
dist: resd LINE_LEN*LINE_LEN*32
|
||||
prev: resd LINE_LEN*LINE_LEN*32
|
||||
q: resb LINE_LEN*LINE_LEN*32
|
||||
cost: resb LINE_LEN*LINE_LEN
|
||||
new_file: resb len(file)
|
363
17/main_part1.s
Normal file
363
17/main_part1.s
Normal file
@@ -0,0 +1,363 @@
|
||||
%include "utils.s"
|
||||
|
||||
global _start
|
||||
[bits 32]
|
||||
[section .text]
|
||||
|
||||
; len +2 for padding
|
||||
%define LINE_LEN (141+2)
|
||||
%define FILENAME "input"
|
||||
;%define LINE_LEN (13+2)
|
||||
;%define FILENAME "input_test"
|
||||
|
||||
;%define DBG_PRINT
|
||||
|
||||
_start:
|
||||
|
||||
; convert input file to useful data
|
||||
mov esi, file
|
||||
mov edi, cost
|
||||
convert_input:
|
||||
lodsb
|
||||
cmp al, 10 ; \n
|
||||
je .cont
|
||||
cmp al, '$'
|
||||
jne .num
|
||||
mov al, 0xFF
|
||||
stosb
|
||||
jmp .cont
|
||||
.num:
|
||||
sub al, '0'
|
||||
stosb
|
||||
.cont:
|
||||
cmp esi, file.over
|
||||
jb convert_input
|
||||
|
||||
; im lazy so doing dijkstra
|
||||
; thanks wikipedia
|
||||
|
||||
; for each vertex v in Graph.Vertices:
|
||||
; dist[v] ← INFINITY
|
||||
; prev[v] ← UNDEFINED
|
||||
; add v to Q
|
||||
mov ecx, LINE_LEN*LINE_LEN*16
|
||||
mov eax, 0xffffffff
|
||||
mov edi, dist
|
||||
rep stosd
|
||||
mov ecx, LINE_LEN*LINE_LEN*16
|
||||
mov eax, 0xffffffff
|
||||
mov edi, prev
|
||||
rep stosd
|
||||
mov ecx, LINE_LEN*LINE_LEN*16
|
||||
mov eax, 1
|
||||
mov edi, q
|
||||
rep stosb
|
||||
|
||||
; for all real dir:
|
||||
; dist[source@dir] ← 0
|
||||
mov dword [dist+((((LINE_LEN*16)+16))|0b0000)*4], 0
|
||||
mov dword [dist+((((LINE_LEN*16)+16))|0b1000)*4], 0
|
||||
|
||||
|
||||
|
||||
; while Q is not empty and any dist[u] in Q < inf:
|
||||
; u ← vertex in Q with min dist[u]
|
||||
while_q:
|
||||
xor ebp, ebp ; test node
|
||||
mov ecx, 0xffffffff ; best dist
|
||||
mov edx, 0xffffffff ; best node
|
||||
.find_min:
|
||||
cmp byte [q+ebp], 1
|
||||
jne .cont
|
||||
cmp [dist+ebp*4], ecx
|
||||
cmovb ecx, [dist+ebp*4]
|
||||
cmovb edx, ebp
|
||||
.cont:
|
||||
inc ebp
|
||||
cmp ebp, LINE_LEN*LINE_LEN*16
|
||||
jb .find_min
|
||||
cmp ecx, 0xffffffff
|
||||
je while_q_done
|
||||
|
||||
%ifdef DBG_PRINT
|
||||
pushad
|
||||
call newline
|
||||
mov ebp, edx
|
||||
mov eax, edx
|
||||
xor edx, edx
|
||||
shr eax, 4
|
||||
mov ebx, LINE_LEN
|
||||
div ebx
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, edx
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, ebp
|
||||
and eax, 0b1111
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, ecx
|
||||
call print_dec
|
||||
call newline
|
||||
popad
|
||||
%endif
|
||||
|
||||
; remove u from Q
|
||||
mov byte [q+edx], 0
|
||||
|
||||
; for each neighbor v of u still in Q:
|
||||
; alt ← dist[u] + Graph.Edges(u, v)
|
||||
; if alt < dist[v]:
|
||||
; dist[v] ← alt
|
||||
; prev[v] ← u
|
||||
mov ebp, LINE_LEN*16 ; whatever
|
||||
for_neighbor:
|
||||
; turning neighbor 0
|
||||
neighbor_0:
|
||||
; neighbors += v@dir(u, ~u.dir & 0b1000)
|
||||
mov ebx, edx
|
||||
not ebx
|
||||
and ebx, 0b1000
|
||||
; tmp := 16
|
||||
mov edi, 16
|
||||
; bt dir, 3
|
||||
bt ebx, 3
|
||||
; if CF tmp := LINE_LEN
|
||||
cmovc edi, ebp
|
||||
; bt dir, 2
|
||||
; if CF tmp := -tmp
|
||||
mov esi, edi
|
||||
neg esi
|
||||
bt ebx, 2
|
||||
cmovc edi, esi
|
||||
; v := u + tmp
|
||||
mov esi, edx
|
||||
and esi, 0xFFFFFFF0
|
||||
add edi, esi
|
||||
; v.dir := dir
|
||||
or edi, ebx
|
||||
; alt ← dist[u] + cost(v)
|
||||
; if alt < dist[v]:
|
||||
; dist[v] ← alt
|
||||
; prev[v] ← u
|
||||
mov eax, edi
|
||||
shr eax, 4
|
||||
movzx eax, byte [cost+eax]
|
||||
cmp al, 0xff
|
||||
je neighbor_1 ; off graph
|
||||
add eax, ecx
|
||||
%ifdef DBG_PRINT
|
||||
pushad
|
||||
call space
|
||||
mov esi, eax
|
||||
mov eax, edi
|
||||
shr eax, 4
|
||||
mov ecx, LINE_LEN
|
||||
xor edx, edx
|
||||
div ecx
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, edx
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, edi
|
||||
and eax, 0xf
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, esi
|
||||
call print_dec
|
||||
call newline
|
||||
popad
|
||||
%endif
|
||||
cmp eax, [dist+edi*4]
|
||||
jae neighbor_1 ; not better
|
||||
mov [dist+edi*4], eax
|
||||
mov [prev+edi*4], edx
|
||||
; turning neighbor 1
|
||||
neighbor_1:
|
||||
; neighbors += v@dir(u, (~u.dir & 0b1000) | 0b0100)
|
||||
mov ebx, edx
|
||||
not ebx
|
||||
and ebx, 0b1000
|
||||
or ebx, 0b0100
|
||||
; tmp := 16
|
||||
mov edi, 16
|
||||
; bt dir, 3
|
||||
bt ebx, 3
|
||||
; if CF tmp := LINE_LEN
|
||||
cmovc edi, ebp
|
||||
; bt dir, 2
|
||||
; if CF tmp := -tmp
|
||||
mov esi, edi
|
||||
neg esi
|
||||
bt ebx, 2
|
||||
cmovc edi, esi
|
||||
; v := u + tmp
|
||||
mov esi, edx
|
||||
and esi, 0xFFFFFFF0
|
||||
add edi, esi
|
||||
; v.dir := dir
|
||||
or edi, ebx
|
||||
; alt ← dist[u] + cost(v)
|
||||
; if alt < dist[v]:
|
||||
; dist[v] ← alt
|
||||
; prev[v] ← u
|
||||
mov eax, edi
|
||||
shr eax, 4
|
||||
movzx eax, byte [cost+eax]
|
||||
cmp al, 0xff
|
||||
je neighbor_2 ; off graph
|
||||
add eax, ecx
|
||||
%ifdef DBG_PRINT
|
||||
pushad
|
||||
call space
|
||||
mov esi, eax
|
||||
mov eax, edi
|
||||
shr eax, 4
|
||||
mov ecx, LINE_LEN
|
||||
xor edx, edx
|
||||
div ecx
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, edx
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, edi
|
||||
and eax, 0xf
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, esi
|
||||
call print_dec
|
||||
call newline
|
||||
popad
|
||||
%endif
|
||||
cmp eax, [dist+edi*4]
|
||||
jae neighbor_2 ; not better
|
||||
mov [dist+edi*4], eax
|
||||
mov [prev+edi*4], edx
|
||||
; straight - neighbor 2
|
||||
neighbor_2:
|
||||
; if u.dir & 0b0011 < 2
|
||||
; neighbors += v@dir(u, u.dir + 1)
|
||||
mov ebx, edx
|
||||
and ebx, 0b0011
|
||||
cmp ebx, 2
|
||||
jae while_q_cont ; neighbors done
|
||||
mov ebx, edx
|
||||
and ebx, 0b1111
|
||||
inc ebx
|
||||
; tmp := 16
|
||||
mov edi, 16
|
||||
; bt dir, 3
|
||||
bt ebx, 3
|
||||
; if CF tmp := LINE_LEN
|
||||
cmovc edi, ebp
|
||||
; bt dir, 2
|
||||
; if CF tmp := -tmp
|
||||
mov esi, edi
|
||||
neg esi
|
||||
bt ebx, 2
|
||||
cmovc edi, esi
|
||||
; v := u + tmp
|
||||
mov esi, edx
|
||||
and esi, 0xFFFFFFF0
|
||||
add edi, esi
|
||||
; v.dir := dir
|
||||
or edi, ebx
|
||||
; alt ← dist[u] + cost(v)
|
||||
; if alt < dist[v]:
|
||||
; dist[v] ← alt
|
||||
; prev[v] ← u
|
||||
mov eax, edi
|
||||
shr eax, 4
|
||||
movzx eax, byte [cost+eax]
|
||||
cmp al, 0xff
|
||||
je while_q_cont ; off graph
|
||||
add eax, ecx
|
||||
%ifdef DBG_PRINT
|
||||
pushad
|
||||
call space
|
||||
mov esi, eax
|
||||
mov eax, edi
|
||||
shr eax, 4
|
||||
mov ecx, LINE_LEN
|
||||
xor edx, edx
|
||||
div ecx
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, edx
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, edi
|
||||
and eax, 0xf
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, esi
|
||||
call print_dec
|
||||
call newline
|
||||
popad
|
||||
%endif
|
||||
cmp eax, [dist+edi*4]
|
||||
jae while_q_cont ; not better
|
||||
mov [dist+edi*4], eax
|
||||
mov [prev+edi*4], edx
|
||||
|
||||
while_q_cont:
|
||||
jmp while_q
|
||||
|
||||
while_q_done:
|
||||
|
||||
call newline
|
||||
|
||||
; last dist values
|
||||
mov eax, [dist+((((LINE_LEN-2)*(LINE_LEN*16))+((LINE_LEN-2)*16))+0b0000)*4]
|
||||
call print_sign_dec
|
||||
call space
|
||||
mov eax, [dist+((((LINE_LEN-2)*(LINE_LEN*16))+((LINE_LEN-2)*16))+0b0001)*4]
|
||||
call print_sign_dec
|
||||
call space
|
||||
mov eax, [dist+((((LINE_LEN-2)*(LINE_LEN*16))+((LINE_LEN-2)*16))+0b0010)*4]
|
||||
call print_sign_dec
|
||||
call newline
|
||||
mov eax, [dist+((((LINE_LEN-2)*(LINE_LEN*16))+((LINE_LEN-2)*16))+0b0100)*4]
|
||||
call print_sign_dec
|
||||
call space
|
||||
mov eax, [dist+((((LINE_LEN-2)*(LINE_LEN*16))+((LINE_LEN-2)*16))+0b0101)*4]
|
||||
call print_sign_dec
|
||||
call space
|
||||
mov eax, [dist+((((LINE_LEN-2)*(LINE_LEN*16))+((LINE_LEN-2)*16))+0b0110)*4]
|
||||
call print_sign_dec
|
||||
call newline
|
||||
mov eax, [dist+((((LINE_LEN-2)*(LINE_LEN*16))+((LINE_LEN-2)*16))+0b1000)*4]
|
||||
call print_sign_dec
|
||||
call space
|
||||
mov eax, [dist+((((LINE_LEN-2)*(LINE_LEN*16))+((LINE_LEN-2)*16))+0b1001)*4]
|
||||
call print_sign_dec
|
||||
call space
|
||||
mov eax, [dist+((((LINE_LEN-2)*(LINE_LEN*16))+((LINE_LEN-2)*16))+0b1010)*4]
|
||||
call print_sign_dec
|
||||
call newline
|
||||
mov eax, [dist+((((LINE_LEN-2)*(LINE_LEN*16))+((LINE_LEN-2)*16))+0b1100)*4]
|
||||
call print_sign_dec
|
||||
call space
|
||||
mov eax, [dist+((((LINE_LEN-2)*(LINE_LEN*16))+((LINE_LEN-2)*16))+0b1101)*4]
|
||||
call print_sign_dec
|
||||
call space
|
||||
mov eax, [dist+((((LINE_LEN-2)*(LINE_LEN*16))+((LINE_LEN-2)*16))+0b1110)*4]
|
||||
call print_sign_dec
|
||||
call newline
|
||||
|
||||
game_over:
|
||||
jmp exit
|
||||
|
||||
[section .data]
|
||||
file: incbin FILENAME
|
||||
.over:
|
||||
|
||||
[section .bss]
|
||||
dist: resd LINE_LEN*LINE_LEN*16
|
||||
prev: resd LINE_LEN*LINE_LEN*16
|
||||
q: resb LINE_LEN*LINE_LEN*16
|
||||
cost: resb LINE_LEN*LINE_LEN
|
||||
new_file: resb len(file)
|
73
17/pseudo
Normal file
73
17/pseudo
Normal file
@@ -0,0 +1,73 @@
|
||||
v@dir(u, dir) {
|
||||
v.dir := dir
|
||||
tmp := 32
|
||||
bt dir, 4
|
||||
if CF
|
||||
tmp := LINE_LEN*32
|
||||
bt dir, 3
|
||||
if CF
|
||||
tmp := -tmp
|
||||
|
||||
if dir & 0b0_111 = 0
|
||||
v := u + tmp
|
||||
CheckBounds(v)
|
||||
Graph.Edges(u, v) := cost(v)
|
||||
v := v + tmp
|
||||
CheckBounds(v)
|
||||
Graph.Edges(u, v) += cost(v)
|
||||
v := v + tmp
|
||||
CheckBounds(v)
|
||||
Graph.Edges(u, v) += cost(v)
|
||||
v := v + tmp
|
||||
CheckBounds(v)
|
||||
Graph.Edges(u, v) += cost(v)
|
||||
else
|
||||
v := u + tmp
|
||||
CheckBounds(v)
|
||||
Graph.Edges(u, v) := cost(v)
|
||||
}
|
||||
|
||||
neighbors(u@dir) {
|
||||
; can always turn
|
||||
neighbors += v@dir(u, ~u.dir & 0b10_000)
|
||||
neighbors += v@dir(u, (~u.dir & 0b10_000) | 0b01_000)
|
||||
; can go forward if consec < 6
|
||||
if u.dir & 0b00_111 < 6
|
||||
neighbors += v@dir(u, u.dir + 1)
|
||||
}
|
||||
|
||||
; 28 possibilities, use 32 so we can do bit hacks
|
||||
; 00000 00001 00010 00011 00100 00101 00110 00111
|
||||
; 0 1 2 3 4 5 6 7
|
||||
dir = { R4, R5, R6, R7, R8, R9, RA, XX,
|
||||
; 01000 01001 01010 01011 01100 01101 01110 01111
|
||||
; 8 9 10 11 12 13 14 15
|
||||
L4, L5, L6, L7, L8, L9, LA, XX,
|
||||
; 10000 10001 10010 10011 10100 10101 10110 10111
|
||||
; 16 17 18 19 20 21 22 23
|
||||
D4, D5, D6, D7, D8, D9, DA, XX,
|
||||
; 11000 11001 11010 11011 11100 11101 11110 11111
|
||||
; 24 25 26 27 28 29 30 31
|
||||
U4, U5, U6, U7, U8, U9, UA, XX}
|
||||
|
||||
dist[(x,y),dir]
|
||||
prev[(x,y),dir]
|
||||
q[(x,y),dir]
|
||||
|
||||
for each vertex v in Graph.Vertices:
|
||||
dist[v] ← INFINITY
|
||||
prev[v] ← UNDEFINED
|
||||
add v to Q
|
||||
|
||||
for all real dir:
|
||||
dist[source@dir] ← 0
|
||||
|
||||
while Q is not empty and any dist[u] in Q < inf:
|
||||
u ← vertex in Q with min dist[u]
|
||||
remove u from Q
|
||||
for each neighbor v of u still in Q:
|
||||
alt ← dist[u] + Graph.Edges(u, v)
|
||||
if alt < dist[v]:
|
||||
dist[v] ← alt
|
||||
prev[v] ← u
|
||||
done
|
285
17/utils.s
Normal file
285
17/utils.s
Normal file
@@ -0,0 +1,285 @@
|
||||
[bits 32]
|
||||
[section .text]
|
||||
; call # val val2
|
||||
; int $0x80 eax eax edx -
|
||||
;
|
||||
; arg1 arg2 arg3 arg4 arg5 arg6 arg7
|
||||
; ebx ecx edx esi edi ebp -
|
||||
|
||||
exit:
|
||||
mov eax, 1 ; exit
|
||||
int 0x80
|
||||
|
||||
; filename in EBX
|
||||
; return handle in EBX
|
||||
; read only
|
||||
open_file:
|
||||
push eax
|
||||
push ecx
|
||||
mov eax, 5 ; open
|
||||
xor ecx, ecx ; read only
|
||||
int 0x80
|
||||
mov ebx, eax
|
||||
pop ecx
|
||||
pop eax
|
||||
ret
|
||||
|
||||
; file handle in EBX
|
||||
; buffer in ECX
|
||||
; count of bytes to read in EDX
|
||||
; return bytes actually read in EAX
|
||||
; exits on error
|
||||
read_file:
|
||||
mov eax, 3 ; read
|
||||
int 0x80
|
||||
test eax, eax
|
||||
js .err
|
||||
ret
|
||||
.err:
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov ecx, .err_str
|
||||
mov edx, 21
|
||||
int 0x80
|
||||
jmp exit
|
||||
.err_str: db `Could not read file.\n`
|
||||
|
||||
; string input in ESI
|
||||
; value in EAX
|
||||
; CF set if none, clear if some
|
||||
; ESI set past checked area
|
||||
dec_parse:
|
||||
push ebx
|
||||
push edx
|
||||
push edi
|
||||
xor eax, eax
|
||||
xor edi, edi
|
||||
mov ebx, 10 ; base
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .no_input
|
||||
cmp al, 9
|
||||
jle .got_char
|
||||
.no_input:
|
||||
stc ; set CF
|
||||
jmp .done
|
||||
.loop:
|
||||
xor eax,eax
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .dec_done
|
||||
cmp al, 9
|
||||
jg .dec_done
|
||||
.got_char:
|
||||
xchg edi,eax
|
||||
mul ebx
|
||||
add edi,eax
|
||||
jmp .loop
|
||||
.dec_done:
|
||||
clc ; clear CF
|
||||
.done:
|
||||
mov eax,edi
|
||||
pop edi
|
||||
pop edx
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; string input in ESI
|
||||
; value in EAX
|
||||
; CF set if none, clear if some
|
||||
; ESI set past checked area
|
||||
sign_dec_parse:
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
push edi
|
||||
xor eax, eax
|
||||
xor edi, edi
|
||||
xor ecx, ecx ; neg flag
|
||||
mov ebx, 10 ; base
|
||||
cmp byte [esi], '-'
|
||||
jne .no_minus
|
||||
inc esi
|
||||
mov cl, 1
|
||||
.no_minus:
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .no_input
|
||||
cmp al, 9
|
||||
jle .got_char
|
||||
.no_input:
|
||||
stc ; set CF
|
||||
jmp .done
|
||||
.loop:
|
||||
xor eax,eax
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .dec_done
|
||||
cmp al, 9
|
||||
jg .dec_done
|
||||
.got_char:
|
||||
xchg edi,eax
|
||||
mul ebx
|
||||
add edi,eax
|
||||
jmp .loop
|
||||
.dec_done:
|
||||
test ecx, ecx
|
||||
jz .not_neg
|
||||
neg edi
|
||||
.not_neg:
|
||||
clc ; clear CF
|
||||
.done:
|
||||
mov eax,edi
|
||||
pop edi
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; modifies no regs
|
||||
newline:
|
||||
pushad
|
||||
push 10
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov ecx, esp ; string
|
||||
mov edx, 1 ; length
|
||||
int 0x80
|
||||
add esp, 4
|
||||
popad
|
||||
ret
|
||||
; modifies no regs
|
||||
space:
|
||||
pushad
|
||||
push 9
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov ecx, esp ; string
|
||||
mov edx, 1 ; length
|
||||
int 0x80
|
||||
add esp, 4
|
||||
popad
|
||||
ret
|
||||
|
||||
; input in EAX, all regs unmodified
|
||||
print_dec:
|
||||
pushad ; save regs
|
||||
; max 4294967296 is 10 chars
|
||||
; round to nearest 32-bit boundary
|
||||
sub esp, 12
|
||||
; string in ECX, length in EDX
|
||||
lea ecx, [esp+11] ; last possible byte
|
||||
; check for 0
|
||||
test eax, eax
|
||||
jz .zero
|
||||
mov ebx, 10 ; base 10
|
||||
xor esi, esi ; counter
|
||||
.div_shit:
|
||||
xor edx, edx
|
||||
; divide
|
||||
div ebx
|
||||
dec ecx ; next char
|
||||
inc esi
|
||||
; store
|
||||
add dl, '0'
|
||||
mov byte [ecx], dl
|
||||
; check if done
|
||||
test eax, eax
|
||||
jnz .div_shit ; continue
|
||||
mov edx, esi ; counter in edx
|
||||
jmp .write
|
||||
.zero:
|
||||
mov byte [ecx], '0'
|
||||
mov edx, 1 ; length
|
||||
.write:
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
int 0x80
|
||||
add esp, 12 ; restore stack
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; input in EAX, all regs unmodified
|
||||
print_sign_dec:
|
||||
pushad ; save regs
|
||||
; range -2147483648 to 2147483647 is 11 chars
|
||||
; round to nearest 32-bit boundary
|
||||
sub esp, 12
|
||||
; string in ECX, length in EDX
|
||||
lea ecx, [esp+11] ; last possible byte
|
||||
; check for 0, negative
|
||||
xor ebp, ebp
|
||||
test eax, eax
|
||||
jz .zero
|
||||
jns .positive
|
||||
neg eax
|
||||
mov ebp, 1
|
||||
.positive:
|
||||
mov ebx, 10 ; base 10
|
||||
xor esi, esi ; counter
|
||||
.div_shit:
|
||||
xor edx, edx
|
||||
; divide
|
||||
div ebx
|
||||
dec ecx ; next char
|
||||
inc esi
|
||||
; store
|
||||
add dl, '0'
|
||||
mov byte [ecx], dl
|
||||
; check if done
|
||||
test eax, eax
|
||||
jnz .div_shit ; continue
|
||||
mov edx, esi ; counter in edx
|
||||
jmp .write
|
||||
.zero:
|
||||
mov byte [ecx], '0'
|
||||
mov edx, 1 ; length
|
||||
.write:
|
||||
test ebp, ebp
|
||||
jz .no_minus
|
||||
dec ecx
|
||||
inc edx
|
||||
mov byte [ecx], '-'
|
||||
.no_minus:
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
int 0x80
|
||||
add esp, 12 ; restore stack
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; input in ESI, len in ECX, all regs unmodified
|
||||
print_string:
|
||||
pushad ; save regs
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov edx, ecx ; length
|
||||
mov ecx, esi ; string
|
||||
int 0x80
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; input in AL, all regs unmodified
|
||||
print_char:
|
||||
pushad ; save regs
|
||||
push eax
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov edx, 1 ; length
|
||||
mov ecx, esp ; string
|
||||
int 0x80
|
||||
add esp, 4
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; --- MACROS ---
|
||||
%define len(x) x %+ .over - x
|
||||
%macro p_string 1
|
||||
push esi
|
||||
push ecx
|
||||
mov esi, %1
|
||||
mov ecx, len(%1)
|
||||
call print_string
|
||||
pop ecx
|
||||
pop esi
|
||||
%endmacro
|
6
18/Makefile
Normal file
6
18/Makefile
Normal file
@@ -0,0 +1,6 @@
|
||||
all:
|
||||
nasm -g -felf64 main.s && ld -g main.o
|
||||
|
||||
part_1:
|
||||
nasm -g -felf32 main_part1.s && ld -melf_i386 -g main_part1.o
|
||||
|
784
18/input
Normal file
784
18/input
Normal file
@@ -0,0 +1,784 @@
|
||||
R 7 (#43c232)
|
||||
U 6 (#1f0fa3)
|
||||
R 7 (#18f980)
|
||||
D 3 (#1c5a83)
|
||||
R 13 (#2a4010)
|
||||
D 8 (#10ed73)
|
||||
R 6 (#43c470)
|
||||
D 9 (#2c1c51)
|
||||
L 12 (#372130)
|
||||
D 6 (#2c1c53)
|
||||
L 7 (#0e8680)
|
||||
D 6 (#3c7e13)
|
||||
R 7 (#2f0660)
|
||||
D 4 (#187de3)
|
||||
R 6 (#6f1062)
|
||||
D 8 (#3e68d3)
|
||||
R 14 (#0b0972)
|
||||
U 7 (#3b8553)
|
||||
R 10 (#1bbcd2)
|
||||
U 8 (#5aa601)
|
||||
R 9 (#59c0b2)
|
||||
U 3 (#5aa603)
|
||||
L 14 (#0c14c2)
|
||||
U 2 (#1b79e3)
|
||||
L 4 (#322f62)
|
||||
U 6 (#416201)
|
||||
R 5 (#366202)
|
||||
U 12 (#416203)
|
||||
R 13 (#3fd0d2)
|
||||
U 3 (#331943)
|
||||
L 9 (#0c5f82)
|
||||
U 3 (#2f0303)
|
||||
R 9 (#6f6222)
|
||||
U 9 (#4fd8a3)
|
||||
L 11 (#15eaf0)
|
||||
U 14 (#374c63)
|
||||
R 11 (#0c26f0)
|
||||
U 6 (#3f7353)
|
||||
L 6 (#125130)
|
||||
U 7 (#51dae3)
|
||||
L 8 (#382b30)
|
||||
D 8 (#51dae1)
|
||||
L 5 (#3cd4c0)
|
||||
D 6 (#1a2ea3)
|
||||
L 11 (#251d90)
|
||||
D 14 (#0842b3)
|
||||
L 5 (#55c8c0)
|
||||
U 3 (#58dea3)
|
||||
L 8 (#0b7bb0)
|
||||
U 11 (#5b3af3)
|
||||
L 4 (#382100)
|
||||
U 9 (#47fe13)
|
||||
L 6 (#01b2e0)
|
||||
U 5 (#4e82f3)
|
||||
L 7 (#6e3740)
|
||||
U 14 (#1cb493)
|
||||
R 9 (#2c13e2)
|
||||
U 9 (#206be3)
|
||||
R 2 (#422362)
|
||||
U 8 (#3bcfb3)
|
||||
R 9 (#35b660)
|
||||
U 7 (#37b1c3)
|
||||
R 5 (#0d2980)
|
||||
U 5 (#38fae3)
|
||||
R 9 (#33e870)
|
||||
U 10 (#403e11)
|
||||
R 8 (#400260)
|
||||
D 6 (#225021)
|
||||
L 5 (#716760)
|
||||
D 7 (#0e1e71)
|
||||
R 5 (#287120)
|
||||
D 9 (#5a71b1)
|
||||
R 4 (#015c40)
|
||||
U 10 (#6d0161)
|
||||
R 6 (#06ed20)
|
||||
D 8 (#602ca3)
|
||||
R 7 (#3ddc50)
|
||||
D 5 (#1adef3)
|
||||
L 4 (#51eca0)
|
||||
D 4 (#1adef1)
|
||||
L 8 (#167b90)
|
||||
U 4 (#3c7553)
|
||||
L 5 (#3651e0)
|
||||
D 7 (#0ce671)
|
||||
R 17 (#26fae0)
|
||||
D 5 (#0ce673)
|
||||
L 7 (#2216b0)
|
||||
D 5 (#1ac753)
|
||||
R 13 (#2585f0)
|
||||
U 10 (#05c323)
|
||||
R 4 (#6a5190)
|
||||
D 4 (#0c9913)
|
||||
R 4 (#53e6e0)
|
||||
D 10 (#239103)
|
||||
L 4 (#1a0b82)
|
||||
D 4 (#217593)
|
||||
R 7 (#117862)
|
||||
U 8 (#0efd13)
|
||||
R 11 (#3b6432)
|
||||
U 7 (#0efd11)
|
||||
L 11 (#449482)
|
||||
U 3 (#4b4ab3)
|
||||
R 7 (#400530)
|
||||
U 7 (#093f03)
|
||||
L 16 (#516be0)
|
||||
U 8 (#529313)
|
||||
L 2 (#1a0b80)
|
||||
U 5 (#49b4e3)
|
||||
R 13 (#388aa0)
|
||||
U 11 (#268b13)
|
||||
R 3 (#3ed060)
|
||||
U 10 (#525fd1)
|
||||
R 7 (#2dee20)
|
||||
U 14 (#525fd3)
|
||||
R 4 (#1c7120)
|
||||
U 4 (#4b5dc3)
|
||||
R 6 (#071870)
|
||||
U 3 (#16bc91)
|
||||
R 6 (#0f7ea0)
|
||||
D 4 (#3c3a83)
|
||||
R 5 (#40a2f0)
|
||||
U 4 (#3c3a81)
|
||||
R 8 (#322d90)
|
||||
D 2 (#16bc93)
|
||||
R 7 (#1a45b0)
|
||||
D 3 (#0dda01)
|
||||
R 2 (#002990)
|
||||
D 14 (#3ce0a1)
|
||||
R 6 (#09b080)
|
||||
D 2 (#3f3411)
|
||||
R 6 (#712ba0)
|
||||
U 4 (#18fc01)
|
||||
R 4 (#50ae42)
|
||||
U 14 (#394c81)
|
||||
L 8 (#5992d2)
|
||||
U 9 (#2c5181)
|
||||
R 8 (#485892)
|
||||
U 5 (#304b41)
|
||||
L 6 (#671760)
|
||||
U 11 (#3b2833)
|
||||
L 10 (#349250)
|
||||
U 10 (#3b2831)
|
||||
L 9 (#1fea10)
|
||||
U 6 (#5a4581)
|
||||
L 8 (#3705e0)
|
||||
D 7 (#2140a1)
|
||||
L 6 (#3e1360)
|
||||
U 7 (#51bce1)
|
||||
L 7 (#61f190)
|
||||
U 2 (#105a71)
|
||||
L 6 (#2f41f0)
|
||||
U 7 (#2eb5a1)
|
||||
L 8 (#6a2b10)
|
||||
U 3 (#103f93)
|
||||
L 8 (#358c70)
|
||||
U 5 (#103f91)
|
||||
L 4 (#44e3e0)
|
||||
U 12 (#2eb5a3)
|
||||
L 11 (#1d4ef0)
|
||||
U 9 (#621753)
|
||||
L 4 (#0a1d50)
|
||||
U 4 (#249d51)
|
||||
R 4 (#287d90)
|
||||
U 12 (#539513)
|
||||
L 13 (#4e0190)
|
||||
U 3 (#539511)
|
||||
R 9 (#2ff870)
|
||||
U 5 (#47b5b1)
|
||||
R 7 (#385e80)
|
||||
D 6 (#319f31)
|
||||
R 5 (#247600)
|
||||
D 7 (#0546b1)
|
||||
R 16 (#4ee172)
|
||||
D 4 (#163921)
|
||||
L 16 (#006a42)
|
||||
D 9 (#5c7f61)
|
||||
R 6 (#4f4bb0)
|
||||
D 2 (#09d9f1)
|
||||
R 12 (#2da090)
|
||||
U 3 (#38a4a3)
|
||||
R 6 (#233670)
|
||||
U 12 (#411713)
|
||||
R 7 (#44f222)
|
||||
U 13 (#5936f3)
|
||||
R 9 (#0846c2)
|
||||
D 5 (#2495a3)
|
||||
R 8 (#4d38e0)
|
||||
U 8 (#284313)
|
||||
R 2 (#004360)
|
||||
U 9 (#591641)
|
||||
R 9 (#249b10)
|
||||
U 15 (#5dbd81)
|
||||
R 10 (#542730)
|
||||
D 12 (#0658a1)
|
||||
R 8 (#202200)
|
||||
D 13 (#63e481)
|
||||
R 7 (#417100)
|
||||
D 11 (#115831)
|
||||
R 3 (#1308a0)
|
||||
D 8 (#5d7591)
|
||||
R 4 (#5bbe90)
|
||||
U 7 (#1dc0a3)
|
||||
R 5 (#051c50)
|
||||
U 17 (#510d23)
|
||||
R 3 (#2322f0)
|
||||
D 15 (#020aa3)
|
||||
R 6 (#47ea42)
|
||||
D 9 (#09f123)
|
||||
R 7 (#130062)
|
||||
D 12 (#1a0523)
|
||||
L 6 (#4a2022)
|
||||
D 4 (#473b73)
|
||||
L 6 (#6dfee0)
|
||||
D 4 (#24c393)
|
||||
L 7 (#6dfee2)
|
||||
U 4 (#2cbcb3)
|
||||
L 6 (#137852)
|
||||
U 4 (#57d193)
|
||||
L 8 (#2c6570)
|
||||
D 9 (#2c2113)
|
||||
L 5 (#30de90)
|
||||
D 8 (#298141)
|
||||
L 10 (#286a40)
|
||||
D 2 (#298143)
|
||||
R 10 (#2c7790)
|
||||
D 8 (#2c2111)
|
||||
L 4 (#065d40)
|
||||
D 11 (#0ded33)
|
||||
R 14 (#5189c0)
|
||||
U 11 (#125f21)
|
||||
R 7 (#183960)
|
||||
U 10 (#280071)
|
||||
R 3 (#1fe640)
|
||||
D 5 (#2c8b81)
|
||||
R 7 (#504d70)
|
||||
D 9 (#532921)
|
||||
R 4 (#03e252)
|
||||
D 7 (#169441)
|
||||
R 7 (#3d6792)
|
||||
D 14 (#278961)
|
||||
L 4 (#472332)
|
||||
D 9 (#2c4981)
|
||||
R 8 (#2df3a0)
|
||||
D 5 (#2ca501)
|
||||
R 13 (#06f2d0)
|
||||
D 3 (#479821)
|
||||
L 10 (#06f2d2)
|
||||
D 14 (#0916f1)
|
||||
L 4 (#3a21d0)
|
||||
D 6 (#342e23)
|
||||
L 7 (#143d52)
|
||||
D 10 (#3de0a3)
|
||||
R 4 (#143d50)
|
||||
D 7 (#0b4553)
|
||||
R 6 (#3578d0)
|
||||
D 4 (#454381)
|
||||
R 8 (#12b310)
|
||||
D 15 (#5c55a1)
|
||||
R 3 (#400ad2)
|
||||
D 15 (#708e81)
|
||||
R 4 (#44a4e2)
|
||||
D 3 (#195891)
|
||||
R 11 (#40cec2)
|
||||
D 14 (#0bf6f1)
|
||||
R 9 (#3f7c42)
|
||||
D 7 (#44f361)
|
||||
L 14 (#252c20)
|
||||
D 7 (#219561)
|
||||
R 14 (#252c22)
|
||||
D 5 (#3b93f1)
|
||||
R 5 (#3f7c40)
|
||||
D 4 (#1b4631)
|
||||
R 7 (#5a10e2)
|
||||
U 10 (#403fe3)
|
||||
L 6 (#1c0942)
|
||||
U 5 (#166bd3)
|
||||
R 6 (#0dfeb2)
|
||||
U 10 (#2faa13)
|
||||
R 9 (#442662)
|
||||
D 11 (#430413)
|
||||
R 5 (#24e8f2)
|
||||
D 10 (#254ae1)
|
||||
L 5 (#698c32)
|
||||
D 4 (#450431)
|
||||
R 10 (#698c30)
|
||||
U 8 (#19b101)
|
||||
R 7 (#280ab2)
|
||||
U 3 (#207b01)
|
||||
R 8 (#1056d2)
|
||||
U 4 (#0188c1)
|
||||
R 9 (#566192)
|
||||
U 8 (#153a81)
|
||||
R 8 (#0ff8a2)
|
||||
D 12 (#50b171)
|
||||
R 10 (#0611d2)
|
||||
D 11 (#168a11)
|
||||
R 11 (#0ac2c0)
|
||||
D 8 (#27c361)
|
||||
L 5 (#49f630)
|
||||
D 17 (#27c363)
|
||||
R 5 (#2809e0)
|
||||
D 12 (#08f281)
|
||||
R 8 (#5d4ed0)
|
||||
D 5 (#60c0b3)
|
||||
R 3 (#1281e0)
|
||||
U 4 (#4ee241)
|
||||
R 7 (#627020)
|
||||
U 7 (#4ee243)
|
||||
R 8 (#4cdbc0)
|
||||
U 7 (#60c0b1)
|
||||
R 7 (#425e30)
|
||||
D 6 (#059533)
|
||||
R 4 (#259d90)
|
||||
D 12 (#059531)
|
||||
R 8 (#5398f0)
|
||||
D 5 (#0f94a1)
|
||||
R 6 (#1f6202)
|
||||
U 6 (#118ec1)
|
||||
R 7 (#584412)
|
||||
D 6 (#633d01)
|
||||
R 8 (#15f142)
|
||||
D 8 (#30fcf1)
|
||||
R 3 (#545932)
|
||||
D 7 (#2e3d11)
|
||||
L 3 (#0e4c62)
|
||||
D 15 (#029c53)
|
||||
L 6 (#1c5592)
|
||||
D 3 (#3d4a43)
|
||||
R 2 (#139220)
|
||||
D 3 (#526013)
|
||||
R 5 (#139222)
|
||||
D 11 (#12bd03)
|
||||
R 11 (#3955d2)
|
||||
D 7 (#2f0223)
|
||||
R 7 (#301b12)
|
||||
D 5 (#0639e3)
|
||||
R 12 (#2dbde2)
|
||||
D 7 (#0639e1)
|
||||
L 15 (#368152)
|
||||
D 3 (#035551)
|
||||
L 4 (#504f00)
|
||||
D 12 (#4daf51)
|
||||
R 7 (#09a6a0)
|
||||
D 4 (#4ade31)
|
||||
L 8 (#5b7570)
|
||||
D 12 (#2a8671)
|
||||
L 10 (#0291f0)
|
||||
D 2 (#0f4cd1)
|
||||
L 7 (#6f41f0)
|
||||
D 16 (#4c29f1)
|
||||
L 9 (#135550)
|
||||
D 7 (#227161)
|
||||
L 11 (#0e4ab2)
|
||||
D 12 (#5b4aa1)
|
||||
L 6 (#3d25f2)
|
||||
D 6 (#5b4aa3)
|
||||
L 7 (#40ef22)
|
||||
D 4 (#3c2521)
|
||||
L 9 (#018b52)
|
||||
U 7 (#19e481)
|
||||
L 5 (#47bbf2)
|
||||
U 7 (#088601)
|
||||
L 10 (#21bf60)
|
||||
U 6 (#3c1c71)
|
||||
L 6 (#21bf62)
|
||||
U 7 (#3df0a1)
|
||||
L 11 (#45d380)
|
||||
U 7 (#23fff1)
|
||||
R 10 (#455c50)
|
||||
U 4 (#2d4481)
|
||||
R 7 (#4a7730)
|
||||
D 4 (#20be61)
|
||||
R 10 (#032890)
|
||||
U 10 (#66a6e3)
|
||||
L 6 (#174410)
|
||||
U 12 (#31a043)
|
||||
L 5 (#302140)
|
||||
U 12 (#5240c1)
|
||||
L 8 (#43c1e0)
|
||||
U 11 (#5240c3)
|
||||
L 6 (#498ad0)
|
||||
U 12 (#31a041)
|
||||
L 4 (#0612a0)
|
||||
U 4 (#4cc393)
|
||||
L 2 (#416240)
|
||||
U 6 (#3f9c83)
|
||||
L 4 (#6624a2)
|
||||
U 6 (#2f4df3)
|
||||
L 11 (#233af2)
|
||||
U 7 (#67d713)
|
||||
L 8 (#219562)
|
||||
D 4 (#191fd3)
|
||||
L 11 (#425670)
|
||||
D 7 (#2f9aa1)
|
||||
L 9 (#5826b0)
|
||||
D 5 (#2f9aa3)
|
||||
L 9 (#02b510)
|
||||
D 5 (#1eee93)
|
||||
L 7 (#0dc2c0)
|
||||
D 9 (#5e5973)
|
||||
R 7 (#3a3e70)
|
||||
D 5 (#1a55b3)
|
||||
L 3 (#5bc130)
|
||||
D 11 (#3c03a3)
|
||||
L 7 (#2add40)
|
||||
D 8 (#2fd5e3)
|
||||
L 7 (#140162)
|
||||
D 8 (#11daa3)
|
||||
L 8 (#5d1932)
|
||||
D 11 (#11daa1)
|
||||
L 9 (#1583e2)
|
||||
D 8 (#4b35b3)
|
||||
L 9 (#742210)
|
||||
D 2 (#2cb393)
|
||||
L 13 (#275e80)
|
||||
U 3 (#5989e1)
|
||||
L 5 (#04e2c2)
|
||||
U 11 (#2865a1)
|
||||
R 5 (#04e2c0)
|
||||
U 13 (#7c28f1)
|
||||
R 5 (#338d60)
|
||||
U 3 (#6cb1a1)
|
||||
R 3 (#33f4c0)
|
||||
U 4 (#19a1a1)
|
||||
L 13 (#404cc0)
|
||||
U 3 (#4671a1)
|
||||
L 4 (#467420)
|
||||
D 14 (#4e3051)
|
||||
L 11 (#2653e2)
|
||||
D 5 (#2d21d1)
|
||||
L 4 (#3fe972)
|
||||
D 9 (#2d21d3)
|
||||
L 6 (#547852)
|
||||
D 9 (#523421)
|
||||
L 8 (#61db40)
|
||||
D 17 (#093c71)
|
||||
L 7 (#013960)
|
||||
D 9 (#5341d1)
|
||||
L 11 (#137f70)
|
||||
D 12 (#1f9541)
|
||||
L 2 (#43d170)
|
||||
D 3 (#3756f1)
|
||||
R 2 (#1460c0)
|
||||
D 16 (#5f6ae1)
|
||||
R 3 (#3d9e12)
|
||||
D 13 (#0e0541)
|
||||
R 10 (#290712)
|
||||
D 7 (#244a91)
|
||||
R 3 (#08f492)
|
||||
U 14 (#50e851)
|
||||
R 9 (#319750)
|
||||
U 6 (#50cce1)
|
||||
R 9 (#3e0260)
|
||||
D 6 (#133501)
|
||||
R 4 (#3e7640)
|
||||
U 4 (#5b11d1)
|
||||
R 13 (#18ca50)
|
||||
U 9 (#1bde41)
|
||||
R 8 (#2f7fe0)
|
||||
U 10 (#1d8fa1)
|
||||
R 3 (#013520)
|
||||
U 3 (#4a1001)
|
||||
R 3 (#005960)
|
||||
U 9 (#41de93)
|
||||
R 10 (#5ac660)
|
||||
U 7 (#25c113)
|
||||
R 3 (#4a0ae0)
|
||||
D 3 (#57bd11)
|
||||
R 14 (#186ec2)
|
||||
D 11 (#363301)
|
||||
L 14 (#6f3c92)
|
||||
D 5 (#30d021)
|
||||
R 10 (#0b4520)
|
||||
D 4 (#37c321)
|
||||
R 5 (#64e710)
|
||||
D 6 (#37c323)
|
||||
R 8 (#352280)
|
||||
D 13 (#3e6021)
|
||||
R 5 (#023060)
|
||||
D 3 (#34b0e1)
|
||||
L 9 (#1134f2)
|
||||
D 4 (#5ef331)
|
||||
L 9 (#1a4052)
|
||||
D 3 (#274471)
|
||||
R 3 (#333bd2)
|
||||
D 8 (#1e38a3)
|
||||
R 12 (#3462b2)
|
||||
D 4 (#67ff03)
|
||||
R 3 (#146b52)
|
||||
D 7 (#224ba1)
|
||||
R 10 (#099452)
|
||||
D 9 (#076ef1)
|
||||
R 9 (#406312)
|
||||
D 2 (#54eda1)
|
||||
R 10 (#0fae42)
|
||||
D 9 (#74d4a1)
|
||||
L 4 (#220d72)
|
||||
D 8 (#0b6731)
|
||||
L 15 (#314cb2)
|
||||
D 3 (#2541f1)
|
||||
L 9 (#061062)
|
||||
D 8 (#65c091)
|
||||
L 8 (#220c02)
|
||||
D 13 (#0e5b01)
|
||||
L 11 (#4f0f62)
|
||||
D 10 (#469d91)
|
||||
L 14 (#31c612)
|
||||
U 8 (#406ec1)
|
||||
L 16 (#382f52)
|
||||
U 5 (#479c53)
|
||||
L 13 (#548c72)
|
||||
U 8 (#4005f3)
|
||||
L 9 (#610822)
|
||||
U 2 (#02cfd3)
|
||||
L 9 (#0d4c22)
|
||||
U 4 (#4f4793)
|
||||
L 5 (#2291b2)
|
||||
U 7 (#53adc3)
|
||||
R 6 (#3a5872)
|
||||
U 4 (#25eaf3)
|
||||
R 9 (#3dc5e0)
|
||||
D 4 (#4cf953)
|
||||
R 8 (#1e7810)
|
||||
U 6 (#2fec63)
|
||||
L 4 (#0c79f0)
|
||||
U 10 (#144493)
|
||||
L 8 (#39b740)
|
||||
U 10 (#144491)
|
||||
L 6 (#3a0830)
|
||||
U 7 (#2c4793)
|
||||
L 5 (#4213d2)
|
||||
D 10 (#4aa983)
|
||||
L 4 (#24f902)
|
||||
D 8 (#3f1823)
|
||||
L 6 (#4802f2)
|
||||
D 8 (#253191)
|
||||
L 3 (#19c2c2)
|
||||
D 6 (#2818e1)
|
||||
L 7 (#19c2c0)
|
||||
D 16 (#3c7731)
|
||||
R 7 (#2d6792)
|
||||
D 6 (#4ef903)
|
||||
R 4 (#336e42)
|
||||
D 4 (#238ec3)
|
||||
L 4 (#4ac572)
|
||||
D 9 (#5427a3)
|
||||
L 9 (#053882)
|
||||
D 8 (#6bf101)
|
||||
L 2 (#42c482)
|
||||
D 16 (#044bf1)
|
||||
L 3 (#1461c2)
|
||||
U 12 (#0502c1)
|
||||
L 8 (#74a2e2)
|
||||
U 11 (#0502c3)
|
||||
L 4 (#3e7212)
|
||||
D 4 (#2bd771)
|
||||
L 13 (#141c02)
|
||||
D 5 (#6061d1)
|
||||
L 3 (#5ca8e2)
|
||||
D 8 (#04a951)
|
||||
R 9 (#2b1342)
|
||||
D 9 (#671121)
|
||||
L 9 (#33afb2)
|
||||
D 8 (#1eb701)
|
||||
L 12 (#4db550)
|
||||
U 7 (#609eb1)
|
||||
R 8 (#4db552)
|
||||
U 15 (#10ae91)
|
||||
L 8 (#2b2572)
|
||||
U 8 (#25c4f1)
|
||||
L 8 (#605e82)
|
||||
U 4 (#09af31)
|
||||
L 9 (#4328a2)
|
||||
U 9 (#09af33)
|
||||
L 17 (#21d142)
|
||||
U 2 (#11e5f1)
|
||||
R 17 (#263f50)
|
||||
U 9 (#152301)
|
||||
R 7 (#18b880)
|
||||
U 8 (#014a31)
|
||||
R 5 (#42b160)
|
||||
U 14 (#17c201)
|
||||
R 7 (#5d7500)
|
||||
D 7 (#17c203)
|
||||
R 10 (#23e090)
|
||||
D 10 (#014a33)
|
||||
R 12 (#0a5140)
|
||||
U 14 (#152303)
|
||||
R 3 (#55f650)
|
||||
U 3 (#1c1ec1)
|
||||
R 9 (#3aec42)
|
||||
U 6 (#03e4b1)
|
||||
R 3 (#45b7a2)
|
||||
U 10 (#5ce301)
|
||||
L 10 (#223d12)
|
||||
U 13 (#2330d1)
|
||||
L 13 (#74b632)
|
||||
U 9 (#411551)
|
||||
L 7 (#22caa2)
|
||||
D 5 (#429fb1)
|
||||
L 6 (#28e492)
|
||||
D 14 (#4b6a41)
|
||||
L 5 (#60a302)
|
||||
D 3 (#05e403)
|
||||
L 3 (#70cdf2)
|
||||
U 9 (#05e4a1)
|
||||
L 3 (#004a12)
|
||||
U 11 (#6ebca1)
|
||||
L 9 (#2f5d62)
|
||||
U 4 (#51e5e3)
|
||||
L 9 (#33ef12)
|
||||
U 13 (#22bb63)
|
||||
L 9 (#400e42)
|
||||
U 6 (#4e0bc3)
|
||||
L 10 (#2efb82)
|
||||
U 11 (#320cc3)
|
||||
L 5 (#3f8372)
|
||||
U 3 (#529693)
|
||||
L 9 (#305d52)
|
||||
U 3 (#356f73)
|
||||
L 5 (#068d72)
|
||||
U 7 (#7321f1)
|
||||
R 5 (#46e4b2)
|
||||
U 4 (#7321f3)
|
||||
R 5 (#32a3a2)
|
||||
D 11 (#4b2fe3)
|
||||
R 5 (#20bd80)
|
||||
U 11 (#65e3a3)
|
||||
R 8 (#3b3e40)
|
||||
U 6 (#139783)
|
||||
L 15 (#7a1050)
|
||||
U 9 (#139781)
|
||||
L 8 (#3ad500)
|
||||
U 11 (#1fc253)
|
||||
L 3 (#0e10f0)
|
||||
U 9 (#580d53)
|
||||
L 4 (#195782)
|
||||
U 8 (#170a13)
|
||||
L 7 (#1cc302)
|
||||
U 2 (#4641b1)
|
||||
L 6 (#4ec5c2)
|
||||
U 10 (#492003)
|
||||
L 11 (#43f2e2)
|
||||
U 3 (#754983)
|
||||
L 5 (#47df02)
|
||||
U 6 (#754981)
|
||||
L 9 (#0b6ed2)
|
||||
U 5 (#492001)
|
||||
R 9 (#0fb482)
|
||||
U 8 (#6c73c1)
|
||||
R 5 (#2d8f52)
|
||||
U 3 (#23de61)
|
||||
L 8 (#325f00)
|
||||
D 3 (#53e8e1)
|
||||
L 6 (#325f02)
|
||||
D 3 (#3715c1)
|
||||
L 4 (#433092)
|
||||
D 14 (#40d3b1)
|
||||
R 10 (#681512)
|
||||
D 3 (#57d843)
|
||||
L 7 (#1af362)
|
||||
D 4 (#107e23)
|
||||
L 6 (#545a32)
|
||||
D 12 (#4e9023)
|
||||
L 6 (#0ff9f2)
|
||||
D 8 (#4b29b3)
|
||||
L 3 (#484e52)
|
||||
D 8 (#0a1063)
|
||||
L 15 (#32d802)
|
||||
D 7 (#5003e3)
|
||||
L 4 (#213d02)
|
||||
D 11 (#190461)
|
||||
L 2 (#357f92)
|
||||
D 6 (#6b8611)
|
||||
L 10 (#3990e0)
|
||||
D 5 (#077dd1)
|
||||
L 4 (#426220)
|
||||
D 11 (#6536c1)
|
||||
L 8 (#18d540)
|
||||
U 11 (#034201)
|
||||
L 8 (#5b3762)
|
||||
D 3 (#0fa911)
|
||||
L 3 (#3990e2)
|
||||
U 6 (#21be11)
|
||||
L 14 (#59c742)
|
||||
U 6 (#384881)
|
||||
L 4 (#4ebc42)
|
||||
U 8 (#5ed321)
|
||||
L 4 (#4ebc40)
|
||||
U 12 (#1a8f21)
|
||||
L 3 (#504172)
|
||||
U 5 (#042cd3)
|
||||
L 11 (#3913b2)
|
||||
U 4 (#77f953)
|
||||
R 14 (#328612)
|
||||
U 9 (#0d33d3)
|
||||
R 3 (#20be92)
|
||||
U 3 (#377b23)
|
||||
R 10 (#20be90)
|
||||
U 10 (#439383)
|
||||
R 4 (#156e80)
|
||||
U 14 (#12bf53)
|
||||
R 5 (#562b40)
|
||||
U 10 (#220b93)
|
||||
L 5 (#1c3732)
|
||||
U 3 (#46b0d3)
|
||||
R 9 (#03f4c2)
|
||||
U 9 (#165873)
|
||||
L 9 (#12b652)
|
||||
U 6 (#4737a3)
|
||||
L 6 (#3bae72)
|
||||
U 2 (#4ca8b3)
|
||||
L 11 (#422bc2)
|
||||
D 7 (#4ca8b1)
|
||||
R 4 (#090d02)
|
||||
D 9 (#406043)
|
||||
R 9 (#091222)
|
||||
D 6 (#2fd4c3)
|
||||
L 7 (#0e6352)
|
||||
D 3 (#42d653)
|
||||
L 6 (#4aa522)
|
||||
D 13 (#287113)
|
||||
L 7 (#145852)
|
||||
U 5 (#4a75c1)
|
||||
L 7 (#640962)
|
||||
U 15 (#4a75c3)
|
||||
R 7 (#506322)
|
||||
U 10 (#482373)
|
||||
L 11 (#75df22)
|
||||
U 8 (#369ab3)
|
||||
L 8 (#75df20)
|
||||
U 11 (#390283)
|
||||
R 7 (#52b932)
|
||||
U 4 (#508653)
|
||||
R 5 (#46bbc0)
|
||||
U 11 (#56d983)
|
||||
R 6 (#64efe0)
|
||||
U 10 (#1482b3)
|
||||
R 7 (#3d20d0)
|
||||
D 6 (#1dad03)
|
||||
R 4 (#5fb9f0)
|
||||
D 7 (#490903)
|
||||
L 4 (#2c0010)
|
||||
D 12 (#662ae3)
|
||||
R 3 (#30a052)
|
||||
U 8 (#64f5f3)
|
||||
R 15 (#30a050)
|
||||
U 5 (#650093)
|
||||
R 12 (#5a5bd2)
|
||||
U 4 (#2b5033)
|
||||
R 3 (#3a86c2)
|
||||
D 7 (#5d1e83)
|
||||
R 7 (#218372)
|
||||
D 11 (#0bc483)
|
||||
R 7 (#0dcaf2)
|
||||
U 3 (#2d2f93)
|
||||
L 4 (#653610)
|
||||
U 11 (#422573)
|
||||
R 4 (#653612)
|
||||
U 4 (#479223)
|
||||
R 3 (#0dcaf0)
|
||||
D 8 (#202b53)
|
||||
R 10 (#4f8ea0)
|
||||
D 3 (#210eb3)
|
||||
R 14 (#4f8ea2)
|
||||
D 9 (#3c44b3)
|
||||
R 12 (#458112)
|
||||
U 9 (#12cf91)
|
||||
R 8 (#413da2)
|
||||
U 11 (#036641)
|
||||
R 5 (#4e1fe0)
|
||||
D 4 (#465131)
|
||||
R 12 (#01c8c0)
|
||||
U 4 (#2aa881)
|
||||
R 10 (#4fe8a2)
|
||||
U 3 (#341941)
|
||||
R 6 (#55c252)
|
||||
U 13 (#339dc3)
|
||||
R 5 (#449340)
|
||||
U 7 (#566e43)
|
||||
R 3 (#449342)
|
||||
U 10 (#313cc3)
|
||||
L 10 (#1e28f2)
|
||||
U 9 (#09d973)
|
14
18/input_test
Normal file
14
18/input_test
Normal file
@@ -0,0 +1,14 @@
|
||||
R 6 (#70c710)
|
||||
D 5 (#0dc571)
|
||||
L 2 (#5713f0)
|
||||
D 2 (#d2c081)
|
||||
R 2 (#59c680)
|
||||
D 2 (#411b91)
|
||||
L 5 (#8ceee2)
|
||||
U 2 (#caa173)
|
||||
L 1 (#1b58a2)
|
||||
U 2 (#caa171)
|
||||
R 2 (#7807d2)
|
||||
U 3 (#a77fa3)
|
||||
L 2 (#015232)
|
||||
U 2 (#7a21e3)
|
65
18/main.s
Normal file
65
18/main.s
Normal file
@@ -0,0 +1,65 @@
|
||||
%include "utils64.s"
|
||||
|
||||
global _start
|
||||
[bits 64]
|
||||
[section .text]
|
||||
|
||||
%define FILENAME "input"
|
||||
;%define FILENAME "input_test"
|
||||
|
||||
_start:
|
||||
mov rsi, file
|
||||
mov rbp, 11_000_000_000 ; vert
|
||||
mov rdi, 1 ; area
|
||||
proc_line:
|
||||
cmp rsi, file.over
|
||||
jae .done
|
||||
mov al, '#'
|
||||
mov rcx, 32
|
||||
xchg rdi, rsi
|
||||
repne scasb
|
||||
xchg rdi, rsi
|
||||
call hex_parse
|
||||
mov rbx, rax
|
||||
and bl, 3
|
||||
shr rax, 4
|
||||
inc rsi ; \n
|
||||
; process shit
|
||||
cmp bl, 0
|
||||
je .r
|
||||
cmp bl, 1
|
||||
je .d
|
||||
cmp bl, 2
|
||||
je .l
|
||||
cmp bl, 3
|
||||
je .u
|
||||
.r:
|
||||
add rdi, rax
|
||||
mul rbp
|
||||
add rdi, rax
|
||||
jmp proc_line
|
||||
.l:
|
||||
mul rbp
|
||||
sub rdi, rax
|
||||
jmp proc_line
|
||||
.d:
|
||||
add rdi, rax
|
||||
sub rbp, rax
|
||||
jmp proc_line
|
||||
.u:
|
||||
add rbp, rax
|
||||
jmp proc_line
|
||||
.done:
|
||||
|
||||
hlt:
|
||||
hlt ; go get a debugger, answer in rdi
|
||||
jmp hlt
|
||||
|
||||
[section .data]
|
||||
final_value: dq 0
|
||||
file: incbin FILENAME
|
||||
.over:
|
||||
|
||||
[section .bss]
|
||||
|
||||
[section .rodata]
|
149
18/main_part1.s
Normal file
149
18/main_part1.s
Normal file
@@ -0,0 +1,149 @@
|
||||
%include "utils.s"
|
||||
|
||||
global _start
|
||||
[bits 32]
|
||||
[section .text]
|
||||
|
||||
%define FILENAME "input"
|
||||
;%define FILENAME "input_test"
|
||||
|
||||
;%define PRINT
|
||||
|
||||
_start:
|
||||
mov esi, file
|
||||
mov edi, array+1024*512+512 ; like, the middle idk
|
||||
mov byte [edi], 1 ; filled!
|
||||
|
||||
proc_line:
|
||||
cmp esi, file.over
|
||||
jae .done
|
||||
lodsb ; RDLU
|
||||
%ifdef PRINT
|
||||
call print_char
|
||||
call space
|
||||
%endif
|
||||
mov ebx, eax
|
||||
inc esi ; space
|
||||
call dec_parse ; count
|
||||
%ifdef PRINT
|
||||
call print_dec
|
||||
call newline
|
||||
%endif
|
||||
; skip to next line
|
||||
add esi, 10
|
||||
; put in array
|
||||
cmp bl, 'R'
|
||||
mov ecx, 1
|
||||
cmove edx, ecx
|
||||
cmp bl, 'L'
|
||||
mov ecx, -1
|
||||
cmove edx, ecx
|
||||
cmp bl, 'D'
|
||||
mov ecx, 1024
|
||||
cmove edx, ecx
|
||||
cmp bl, 'U'
|
||||
mov ecx, -1024
|
||||
cmove edx, ecx
|
||||
mov ecx, eax
|
||||
.draw:
|
||||
add edi, edx
|
||||
mov byte [edi], 1
|
||||
loop .draw
|
||||
jmp proc_line
|
||||
.done:
|
||||
|
||||
%ifdef PRINT
|
||||
print_array:
|
||||
call newline
|
||||
mov esi, array
|
||||
xor ecx, ecx
|
||||
.inner:
|
||||
mov bl, '.'
|
||||
lodsb
|
||||
test al, al
|
||||
mov dl, '#'
|
||||
cmovnz bx, dx
|
||||
mov al, bl
|
||||
call print_char
|
||||
inc ecx
|
||||
cmp ecx, 1024*1024
|
||||
jae .done
|
||||
mov ebx, ecx
|
||||
and ebx, 1023
|
||||
jnz .inner
|
||||
call newline
|
||||
jmp .inner
|
||||
.done:
|
||||
call newline
|
||||
%endif
|
||||
|
||||
xor ecx, ecx ; x = 0
|
||||
xor ebx, ebx ; y = 0
|
||||
mov ebp, 1024*1024 ; count
|
||||
call flood_fill
|
||||
jmp flood_done
|
||||
|
||||
flood_fill:
|
||||
mov eax, ebx
|
||||
shl eax, 10
|
||||
cmp byte [array+eax+ecx], 0
|
||||
je .zero
|
||||
ret
|
||||
.zero:
|
||||
dec ebp
|
||||
mov byte [array+eax+ecx], 1
|
||||
sub esp, 8
|
||||
mov [esp+4], ecx
|
||||
mov [esp+0], ebx
|
||||
.t_right:
|
||||
cmp ecx, 1023
|
||||
je .t_left
|
||||
inc ecx
|
||||
call flood_fill
|
||||
mov ecx, [esp+4]
|
||||
.t_left:
|
||||
cmp ecx, 0
|
||||
je .t_down
|
||||
dec ecx
|
||||
call flood_fill
|
||||
mov ecx, [esp+4]
|
||||
.t_down:
|
||||
cmp ebx, 1023
|
||||
je .t_up
|
||||
inc ebx
|
||||
call flood_fill
|
||||
mov ebx, [esp+0]
|
||||
.t_up:
|
||||
cmp ebx, 0
|
||||
je .ret
|
||||
dec ebx
|
||||
call flood_fill
|
||||
mov ebx, [esp+0]
|
||||
.ret:
|
||||
add esp, 8
|
||||
ret
|
||||
|
||||
flood_done:
|
||||
mov [final_value], ebp
|
||||
|
||||
game_over:
|
||||
mov eax, [final_value]
|
||||
call print_dec
|
||||
call newline
|
||||
jmp exit
|
||||
|
||||
PANIC:
|
||||
p_string panic_str
|
||||
jmp exit
|
||||
|
||||
[section .data]
|
||||
final_value: dd 0
|
||||
file: incbin FILENAME
|
||||
.over:
|
||||
|
||||
[section .bss]
|
||||
array: resb 1024*1024
|
||||
|
||||
[section .rodata]
|
||||
panic_str: db 10, "AAAAAAAAAAAAAAAAAAAAAA!!!!!!!!!!11111111", 10
|
||||
.over:
|
285
18/utils.s
Normal file
285
18/utils.s
Normal file
@@ -0,0 +1,285 @@
|
||||
[bits 32]
|
||||
[section .text]
|
||||
; call # val val2
|
||||
; int $0x80 eax eax edx -
|
||||
;
|
||||
; arg1 arg2 arg3 arg4 arg5 arg6 arg7
|
||||
; ebx ecx edx esi edi ebp -
|
||||
|
||||
exit:
|
||||
mov eax, 1 ; exit
|
||||
int 0x80
|
||||
|
||||
; filename in EBX
|
||||
; return handle in EBX
|
||||
; read only
|
||||
open_file:
|
||||
push eax
|
||||
push ecx
|
||||
mov eax, 5 ; open
|
||||
xor ecx, ecx ; read only
|
||||
int 0x80
|
||||
mov ebx, eax
|
||||
pop ecx
|
||||
pop eax
|
||||
ret
|
||||
|
||||
; file handle in EBX
|
||||
; buffer in ECX
|
||||
; count of bytes to read in EDX
|
||||
; return bytes actually read in EAX
|
||||
; exits on error
|
||||
read_file:
|
||||
mov eax, 3 ; read
|
||||
int 0x80
|
||||
test eax, eax
|
||||
js .err
|
||||
ret
|
||||
.err:
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov ecx, .err_str
|
||||
mov edx, 21
|
||||
int 0x80
|
||||
jmp exit
|
||||
.err_str: db `Could not read file.\n`
|
||||
|
||||
; string input in ESI
|
||||
; value in EAX
|
||||
; CF set if none, clear if some
|
||||
; ESI set past checked area
|
||||
dec_parse:
|
||||
push ebx
|
||||
push edx
|
||||
push edi
|
||||
xor eax, eax
|
||||
xor edi, edi
|
||||
mov ebx, 10 ; base
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .no_input
|
||||
cmp al, 9
|
||||
jle .got_char
|
||||
.no_input:
|
||||
stc ; set CF
|
||||
jmp .done
|
||||
.loop:
|
||||
xor eax,eax
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .dec_done
|
||||
cmp al, 9
|
||||
jg .dec_done
|
||||
.got_char:
|
||||
xchg edi,eax
|
||||
mul ebx
|
||||
add edi,eax
|
||||
jmp .loop
|
||||
.dec_done:
|
||||
clc ; clear CF
|
||||
.done:
|
||||
mov eax,edi
|
||||
pop edi
|
||||
pop edx
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; string input in ESI
|
||||
; value in EAX
|
||||
; CF set if none, clear if some
|
||||
; ESI set past checked area
|
||||
sign_dec_parse:
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
push edi
|
||||
xor eax, eax
|
||||
xor edi, edi
|
||||
xor ecx, ecx ; neg flag
|
||||
mov ebx, 10 ; base
|
||||
cmp byte [esi], '-'
|
||||
jne .no_minus
|
||||
inc esi
|
||||
mov cl, 1
|
||||
.no_minus:
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .no_input
|
||||
cmp al, 9
|
||||
jle .got_char
|
||||
.no_input:
|
||||
stc ; set CF
|
||||
jmp .done
|
||||
.loop:
|
||||
xor eax,eax
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .dec_done
|
||||
cmp al, 9
|
||||
jg .dec_done
|
||||
.got_char:
|
||||
xchg edi,eax
|
||||
mul ebx
|
||||
add edi,eax
|
||||
jmp .loop
|
||||
.dec_done:
|
||||
test ecx, ecx
|
||||
jz .not_neg
|
||||
neg edi
|
||||
.not_neg:
|
||||
clc ; clear CF
|
||||
.done:
|
||||
mov eax,edi
|
||||
pop edi
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; modifies no regs
|
||||
newline:
|
||||
pushad
|
||||
push 10
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov ecx, esp ; string
|
||||
mov edx, 1 ; length
|
||||
int 0x80
|
||||
add esp, 4
|
||||
popad
|
||||
ret
|
||||
; modifies no regs
|
||||
space:
|
||||
pushad
|
||||
push 9
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov ecx, esp ; string
|
||||
mov edx, 1 ; length
|
||||
int 0x80
|
||||
add esp, 4
|
||||
popad
|
||||
ret
|
||||
|
||||
; input in EAX, all regs unmodified
|
||||
print_dec:
|
||||
pushad ; save regs
|
||||
; max 4294967296 is 10 chars
|
||||
; round to nearest 32-bit boundary
|
||||
sub esp, 12
|
||||
; string in ECX, length in EDX
|
||||
lea ecx, [esp+11] ; last possible byte
|
||||
; check for 0
|
||||
test eax, eax
|
||||
jz .zero
|
||||
mov ebx, 10 ; base 10
|
||||
xor esi, esi ; counter
|
||||
.div_shit:
|
||||
xor edx, edx
|
||||
; divide
|
||||
div ebx
|
||||
dec ecx ; next char
|
||||
inc esi
|
||||
; store
|
||||
add dl, '0'
|
||||
mov byte [ecx], dl
|
||||
; check if done
|
||||
test eax, eax
|
||||
jnz .div_shit ; continue
|
||||
mov edx, esi ; counter in edx
|
||||
jmp .write
|
||||
.zero:
|
||||
mov byte [ecx], '0'
|
||||
mov edx, 1 ; length
|
||||
.write:
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
int 0x80
|
||||
add esp, 12 ; restore stack
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; input in EAX, all regs unmodified
|
||||
print_sign_dec:
|
||||
pushad ; save regs
|
||||
; range -2147483648 to 2147483647 is 11 chars
|
||||
; round to nearest 32-bit boundary
|
||||
sub esp, 12
|
||||
; string in ECX, length in EDX
|
||||
lea ecx, [esp+11] ; last possible byte
|
||||
; check for 0, negative
|
||||
xor ebp, ebp
|
||||
test eax, eax
|
||||
jz .zero
|
||||
jns .positive
|
||||
neg eax
|
||||
mov ebp, 1
|
||||
.positive:
|
||||
mov ebx, 10 ; base 10
|
||||
xor esi, esi ; counter
|
||||
.div_shit:
|
||||
xor edx, edx
|
||||
; divide
|
||||
div ebx
|
||||
dec ecx ; next char
|
||||
inc esi
|
||||
; store
|
||||
add dl, '0'
|
||||
mov byte [ecx], dl
|
||||
; check if done
|
||||
test eax, eax
|
||||
jnz .div_shit ; continue
|
||||
mov edx, esi ; counter in edx
|
||||
jmp .write
|
||||
.zero:
|
||||
mov byte [ecx], '0'
|
||||
mov edx, 1 ; length
|
||||
.write:
|
||||
test ebp, ebp
|
||||
jz .no_minus
|
||||
dec ecx
|
||||
inc edx
|
||||
mov byte [ecx], '-'
|
||||
.no_minus:
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
int 0x80
|
||||
add esp, 12 ; restore stack
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; input in ESI, len in ECX, all regs unmodified
|
||||
print_string:
|
||||
pushad ; save regs
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov edx, ecx ; length
|
||||
mov ecx, esi ; string
|
||||
int 0x80
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; input in AL, all regs unmodified
|
||||
print_char:
|
||||
pushad ; save regs
|
||||
push eax
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov edx, 1 ; length
|
||||
mov ecx, esp ; string
|
||||
int 0x80
|
||||
add esp, 4
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; --- MACROS ---
|
||||
%define len(x) x %+ .over - x
|
||||
%macro p_string 1
|
||||
push esi
|
||||
push ecx
|
||||
mov esi, %1
|
||||
mov ecx, len(%1)
|
||||
call print_string
|
||||
pop ecx
|
||||
pop esi
|
||||
%endmacro
|
117
18/utils64.s
Normal file
117
18/utils64.s
Normal file
@@ -0,0 +1,117 @@
|
||||
[bits 64]
|
||||
[section .text]
|
||||
; string input in RSI
|
||||
; value in RAX
|
||||
; CF set if none, clear if some
|
||||
; RSI set past checked area
|
||||
dec_parse:
|
||||
sub rsp, 24
|
||||
mov [rsp+16], rbx
|
||||
mov [rsp+8], rdx
|
||||
mov [rsp+0], rdi
|
||||
xor rax, rax
|
||||
xor rdi, rdi
|
||||
mov rbx, 10 ; base
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .no_input
|
||||
cmp al, 9
|
||||
jle .got_char
|
||||
.no_input:
|
||||
stc ; set CF
|
||||
jmp .done
|
||||
.loop:
|
||||
xor rax,rax
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .dec_done
|
||||
cmp al, 9
|
||||
jg .dec_done
|
||||
.got_char:
|
||||
xchg rdi,rax
|
||||
mul rbx
|
||||
add rdi,rax
|
||||
jmp .loop
|
||||
.dec_done:
|
||||
clc ; clear CF
|
||||
.done:
|
||||
mov rax, rdi
|
||||
mov rdi, [rsp+0]
|
||||
mov rdx, [rsp+8]
|
||||
mov rbx, [rsp+16]
|
||||
add rsp, 24
|
||||
ret
|
||||
|
||||
; string input in RSI
|
||||
; value in RAX
|
||||
; CF set if none, cear if some
|
||||
; RSI set past checked area
|
||||
hex_parse:
|
||||
sub rsp, 24
|
||||
mov [rsp+16], rbx
|
||||
mov [rsp+8], rdx
|
||||
mov [rsp+0], rdi
|
||||
xor rax, rax
|
||||
xor rdi, rdi
|
||||
lodsb
|
||||
cmp al, '0'
|
||||
jb .no_input
|
||||
cmp al, '9'
|
||||
jbe .got_dec_char
|
||||
cmp al, 'A'
|
||||
jb .no_input
|
||||
cmp al, 'F'
|
||||
jbe .got_ualpha_char
|
||||
cmp al, 'a'
|
||||
jb .no_input
|
||||
cmp al, 'f'
|
||||
jbe .got_ualpha_char
|
||||
.no_input:
|
||||
stc ; set CF
|
||||
jmp .done
|
||||
.loop:
|
||||
xor rax,rax
|
||||
lodsb
|
||||
cmp al, '0'
|
||||
jb .hex_done
|
||||
cmp al, '9'
|
||||
jbe .got_dec_char
|
||||
cmp al, 'A'
|
||||
jb .hex_done
|
||||
cmp al, 'F'
|
||||
jbe .got_ualpha_char
|
||||
cmp al, 'a'
|
||||
jb .hex_done
|
||||
cmp al, 'f'
|
||||
jbe .got_ualpha_char
|
||||
jmp .hex_done
|
||||
.got_dec_char:
|
||||
sub al, '0'
|
||||
xchg rdi,rax
|
||||
shl rax, 4
|
||||
add rdi,rax
|
||||
jmp .loop
|
||||
.got_alpha_char:
|
||||
sub al, 'A'-10
|
||||
xchg rdi,rax
|
||||
shl rax, 4
|
||||
add rdi,rax
|
||||
jmp .loop
|
||||
.got_ualpha_char:
|
||||
sub al, 'a'-10
|
||||
xchg rdi,rax
|
||||
shl rax, 4
|
||||
add rdi,rax
|
||||
jmp .loop
|
||||
.hex_done:
|
||||
clc ; clear CF
|
||||
.done:
|
||||
mov rax, rdi
|
||||
mov rdi, [rsp+0]
|
||||
mov rdx, [rsp+8]
|
||||
mov rbx, [rsp+16]
|
||||
add rsp, 24
|
||||
ret
|
||||
|
||||
; --- MACROS ---
|
||||
%define len(x) x %+ .over - x
|
3
19/Makefile
Normal file
3
19/Makefile
Normal file
@@ -0,0 +1,3 @@
|
||||
all:
|
||||
nasm -g -felf32 main.s && ld -melf_i386 -g main.o
|
||||
|
780
19/input
Normal file
780
19/input
Normal file
@@ -0,0 +1,780 @@
|
||||
fr{a>2845:A,m<2004:A,A}
|
||||
lxs{s<2192:R,R}
|
||||
jhz{x<442:A,A}
|
||||
zm{x<1231:R,A}
|
||||
jz{s<2913:A,x<2108:R,R}
|
||||
cqv{a>2101:R,A}
|
||||
hsx{m<1426:xxn,s<1619:sq,qqb}
|
||||
sdm{x>1360:A,A}
|
||||
zbb{a>3503:R,s>2984:R,A}
|
||||
skk{x>1878:A,s>1548:R,R}
|
||||
mn{x>576:R,x<195:A,s<303:R,A}
|
||||
hbj{a>728:hqq,ggl}
|
||||
lq{x>1539:A,m>950:A,m>611:A,R}
|
||||
gx{a>3590:zmc,tg}
|
||||
xpr{a<3371:R,s<3114:A,R}
|
||||
nf{m>2252:A,m<1915:A,x<1541:A,R}
|
||||
mfl{m<1608:vk,m>2471:mp,x<1842:A,A}
|
||||
md{x<1958:A,A}
|
||||
bt{s>2495:R,x<2051:R,a<3362:R,R}
|
||||
zp{m>1849:R,m>1720:A,s<2907:A,R}
|
||||
kp{x>2295:R,x>2106:R,A}
|
||||
dm{a>3142:rk,x<996:kc,m>2686:lxc,svc}
|
||||
cq{a<1392:xkx,s>2114:czc,R}
|
||||
xlc{m>3640:xh,s<1981:ck,x<1275:R,tv}
|
||||
qhp{a>2255:R,m<2909:A,R}
|
||||
zz{x>158:A,A}
|
||||
bmg{s>3584:A,R}
|
||||
tp{m>1848:vrs,mds}
|
||||
mds{a<3473:A,a>3501:A,s<3009:A,R}
|
||||
kdm{s<3771:zx,vq}
|
||||
xxn{a>1741:fq,m<899:bkf,vm}
|
||||
lbm{m>3455:A,R}
|
||||
bq{x>2598:R,A}
|
||||
vlr{m>1824:rsn,a<3330:mr,x<1229:ch,gfp}
|
||||
rfd{x<1380:vxx,m>2215:A,jbz}
|
||||
fnp{s<2124:bh,a<1450:A,A}
|
||||
pvh{s>1623:A,x<3503:A,s<1454:R,R}
|
||||
dhh{s>1900:A,R}
|
||||
cv{m>2619:gvq,zbb}
|
||||
gz{a<2237:R,A}
|
||||
hrf{a>1467:shg,A}
|
||||
kqp{m>2434:qst,x>1969:kgz,gr}
|
||||
xlg{s<1949:tj,x<1948:czj,R}
|
||||
xf{s<2587:A,m>2612:R,a>381:A,R}
|
||||
fdj{a>3545:A,a<3532:R,s<2736:R,R}
|
||||
shn{m>2612:R,m<1284:jlp,A}
|
||||
xx{a>3575:jzf,a<3518:A,s>2638:fdj,A}
|
||||
sd{a<3248:R,m<3422:js,s>1555:A,lz}
|
||||
vd{s>1745:txb,fs}
|
||||
hm{a>1763:pg,s<3711:dvf,xpp}
|
||||
xhj{a<1056:A,m>3355:A,ntz}
|
||||
td{x>705:A,R}
|
||||
znz{a>3929:xg,fcf}
|
||||
kk{s>2920:A,m>3806:R,ng}
|
||||
mx{m>987:R,m<500:A,A}
|
||||
rk{s<2159:ph,s<2256:dxp,m<2823:jq,km}
|
||||
lb{a>2647:A,s<1457:A,x>3452:R,R}
|
||||
svc{s<2017:kgt,xff}
|
||||
nk{x>1466:A,s<2004:lxg,s>2073:sgd,mnx}
|
||||
cn{x<3437:R,R}
|
||||
shg{m<2072:R,R}
|
||||
xbh{s>1178:R,R}
|
||||
czj{m>873:R,x>1527:R,x>1352:R,A}
|
||||
dj{s<3859:nsk,x<3298:ktl,a>730:ll,bx}
|
||||
lzq{m<3709:A,a>758:R,a<697:R,R}
|
||||
xjn{a>2302:A,m>2041:A,s>3482:R,A}
|
||||
zcb{a<276:R,m<2219:R,s>2027:A,A}
|
||||
hmn{x<2560:A,m<2069:R,x>3240:R,A}
|
||||
dxp{x<1615:R,a<3653:A,R}
|
||||
thv{m>1443:fnp,dnc}
|
||||
bpq{a>2566:R,s>2238:ndq,a>2202:R,A}
|
||||
xkv{s<1708:R,s<1764:A,m<2486:A,A}
|
||||
xrs{s>2780:vn,hvh}
|
||||
tkq{s<3890:R,s>3905:A,s<3900:R,A}
|
||||
cxv{m>3326:zl,x<1480:mz,x<2829:rv,lt}
|
||||
kzn{m<2943:A,x<3690:A,R}
|
||||
gd{s>1936:A,x>3201:R,m>3130:A,R}
|
||||
qqb{x>858:rf,x<392:vd,mh}
|
||||
mmb{s>1505:vl,m>2260:zzn,jd}
|
||||
zlb{m<2754:A,m>2824:R,R}
|
||||
gf{s>2007:zhl,x>742:mzn,a<2531:nm,R}
|
||||
th{s<3579:A,A}
|
||||
nsk{s<3700:A,crp}
|
||||
jc{x>770:A,A}
|
||||
ln{x>970:xzr,s>3048:ccr,lfn}
|
||||
lnf{m<2433:ds,m>3234:lzq,gkn}
|
||||
crp{s>3759:A,x<3534:A,A}
|
||||
thj{s<2817:R,R}
|
||||
rpn{m<463:R,s>1546:R,s>1448:A,R}
|
||||
lf{a<3216:R,x<1505:gkh,s>1758:R,bxz}
|
||||
jg{m>552:vxm,a<3207:nq,fz}
|
||||
rsn{a>3358:R,gzj}
|
||||
nn{x>2059:qq,a>159:dhl,gfc}
|
||||
skv{s<1728:A,a<1776:A,x<555:R,R}
|
||||
ktv{s>3176:R,s>3065:A,A}
|
||||
zq{m>3113:A,x<3424:A,R}
|
||||
tqv{x>3879:A,x>3815:A,A}
|
||||
vp{a<1366:lgh,m>1586:nl,jpj}
|
||||
cz{x>1163:R,A}
|
||||
dxn{m>3105:R,m<2018:skv,x<548:R,xkv}
|
||||
xtn{a>3160:rd,s>2740:tl,xj}
|
||||
dv{a<3922:bv,s<2651:rl,R}
|
||||
glg{s>3870:R,m>3122:R,R}
|
||||
mls{a>2798:R,x>2352:A,R}
|
||||
ztq{a<2008:jhc,m>862:tbl,A}
|
||||
rqk{a>1311:R,R}
|
||||
nlx{a<2137:A,s>2037:nnf,a<2838:R,vkh}
|
||||
jvd{s>1469:A,m<3294:zm,s<1435:R,mcb}
|
||||
dmf{m<3734:A,A}
|
||||
zl{m<3721:zf,A}
|
||||
hvh{x<1599:fcp,a>256:xth,x<2400:nn,bpx}
|
||||
sf{x>1556:ztq,mzl}
|
||||
lcq{m>635:mjp,s>2859:A,m>413:R,hbt}
|
||||
xn{m>2426:jvd,x<858:pfz,mfv}
|
||||
zgf{a>1378:R,m<1291:ptd,R}
|
||||
qhv{m>1852:A,m>1719:R,s<3007:R,A}
|
||||
ph{a<3497:vv,R}
|
||||
mps{s<2806:zps,kbd}
|
||||
bz{s>2864:R,A}
|
||||
ll{s<3917:tkq,x<3703:R,R}
|
||||
tbl{m<1295:A,A}
|
||||
tm{s<3029:sl,a>3664:dg,a>3563:crg,dcm}
|
||||
xxr{x<2995:A,s>1322:R,a>3132:A,A}
|
||||
kgz{x>2235:R,A}
|
||||
pfz{x<300:A,R}
|
||||
pb{m>3682:lpv,A}
|
||||
ps{m>2481:xvp,x>3501:thv,bk}
|
||||
dvf{s>3547:shn,hc}
|
||||
gkh{s>1768:A,s<1736:A,A}
|
||||
kbd{x>827:A,A}
|
||||
zhj{s<2126:xlc,a<734:pb,x>1387:qcz,rn}
|
||||
xg{a<3969:A,m<2656:A,R}
|
||||
sm{s>2585:A,R}
|
||||
zhl{a<2775:R,m<712:A,A}
|
||||
df{x<2518:R,A}
|
||||
lfn{s<2787:mfc,m<3120:A,bmf}
|
||||
sdx{m>2324:R,A}
|
||||
qcz{a>1412:gxd,R}
|
||||
tq{m>1287:A,m<798:A,s>3148:R,R}
|
||||
gq{a<2067:R,a>2180:gz,m<2530:R,lbm}
|
||||
lmv{m>1460:A,A}
|
||||
jqz{x>800:A,m<2431:R,a<1059:A,A}
|
||||
hzl{m<3210:A,R}
|
||||
fqd{s<3517:A,dd}
|
||||
xpp{m<1921:kfl,x>716:kv,x>273:ntk,vmd}
|
||||
st{a>2725:R,A}
|
||||
pd{m<3138:A,x<3799:R,A}
|
||||
cx{m<2622:cn,x>3616:A,m<3404:zq,dcs}
|
||||
vkh{s>1912:R,x>2874:R,R}
|
||||
dpm{a>2728:fr,a<2543:qzb,m>2249:vs,fhh}
|
||||
zjn{m<1731:R,s>1599:A,A}
|
||||
dg{s<3279:A,m<899:R,a<3806:lrq,R}
|
||||
qj{a<2324:A,R}
|
||||
bm{a<2544:A,m<973:A,m<1233:R,R}
|
||||
dmm{x>420:R,a<3938:A,m<1567:A,A}
|
||||
nxd{m>1378:gkl,gps}
|
||||
fcf{a<3859:R,s>3094:R,A}
|
||||
km{m<3292:db,s>2311:nlh,x>949:nkt,R}
|
||||
fz{m>224:A,s>427:A,s>193:R,R}
|
||||
jgn{x>3689:tqv,a>3896:rhx,ktq}
|
||||
jcz{m<964:fcc,lmv}
|
||||
dqt{x>1042:R,A}
|
||||
xs{x>2301:np,m>2490:A,A}
|
||||
dnc{a>2667:ltx,R}
|
||||
pm{m>1660:R,R}
|
||||
xkx{x<1469:A,s<2105:A,A}
|
||||
zqk{s>2813:zs,m>2905:xx,a<3613:dzc,cms}
|
||||
qh{m>2483:R,a<1940:R,A}
|
||||
nm{a>2194:A,R}
|
||||
dhl{a>214:R,R}
|
||||
kr{x>2730:A,A}
|
||||
nzs{a<3692:R,R}
|
||||
hc{s<3500:R,jqz}
|
||||
mt{s<1112:dgs,cs}
|
||||
jnc{x>2611:A,x>2231:R,R}
|
||||
txn{x>2227:A,s<2060:R,R}
|
||||
tvz{a<2131:A,m<3205:R,m<3641:R,A}
|
||||
bsh{a<439:R,a<528:R,s>2648:A,A}
|
||||
hb{m<340:pmp,x>1343:smn,R}
|
||||
gxh{m<1015:A,x<1686:A,x<2151:R,R}
|
||||
xxf{x>3458:A,x>3396:R,A}
|
||||
ks{s<3753:A,s<3790:R,a<1055:A,A}
|
||||
bdb{m>1085:kql,qk}
|
||||
gkn{s<3173:A,R}
|
||||
qq{m<1365:R,s>2565:A,m<2907:R,A}
|
||||
dzc{m<2655:vng,zlb}
|
||||
hdq{s<878:R,A}
|
||||
vxm{s>304:A,a>3262:R,a>2961:R,R}
|
||||
jfr{a<3476:qt,m<2328:tm,a<3734:zqk,nhh}
|
||||
zzx{m>3167:R,a>2911:R,s>1986:R,R}
|
||||
cj{s<2777:mkt,m<1946:R,x<2175:A,R}
|
||||
nlh{m<3735:A,x<878:R,a>3519:R,R}
|
||||
bs{s<2559:R,s<2678:A,R}
|
||||
jzx{a<2939:A,A}
|
||||
mhd{a>3461:lbp,x>1754:dn,R}
|
||||
bf{x<1514:A,R}
|
||||
qzg{m>765:R,x<1881:A,m<429:A,A}
|
||||
tzj{m<3544:A,A}
|
||||
lt{a>3048:R,s<241:ht,s>399:dk,R}
|
||||
sjv{s<303:A,A}
|
||||
gv{x>1712:A,x>1145:R,A}
|
||||
hx{x>2863:A,A}
|
||||
bbv{x<3854:xjn,a>2553:A,R}
|
||||
rd{m>1904:A,a>3229:rb,a>3201:zbq,qzx}
|
||||
xdc{s<3559:qkk,x<2257:A,R}
|
||||
jpj{a<2122:pxj,m<815:R,R}
|
||||
hpx{x<3160:A,R}
|
||||
vkp{m<3498:vc,kk}
|
||||
vq{s>3849:A,R}
|
||||
kc{a<2487:lxs,s>2074:ffm,zzx}
|
||||
nhj{s<1677:R,x<754:A,kkh}
|
||||
jmv{s>3095:R,m>2659:A,A}
|
||||
ngp{x>318:A,R}
|
||||
rn{m>3717:mv,ld}
|
||||
rr{x>2077:lcs,a<2564:vp,x<1783:kdm,xd}
|
||||
vv{m<2492:A,R}
|
||||
jgs{x<1311:td,x>1970:fkr,lkd}
|
||||
zbq{x>1251:A,x>741:R,a<3214:R,A}
|
||||
vr{s>1490:fkj,s>1418:R,a<3021:rdh,A}
|
||||
js{m>3168:R,m>3015:A,A}
|
||||
mh{x<676:dxn,s>1709:jzc,nhj}
|
||||
rv{a>3103:sjv,s<282:kvc,vns}
|
||||
sg{x>1921:rqz,m<1545:xt,fdx}
|
||||
bdv{s>3015:A,x>563:R,a<2129:R,A}
|
||||
kb{a<2399:dnv,a<3059:mmb,m<1918:mrc,gx}
|
||||
ht{a<2799:A,x>3399:A,A}
|
||||
vrs{a<3462:A,A}
|
||||
ch{s<2743:R,m>1149:tfz,m<558:xpr,A}
|
||||
lrq{x<3098:R,s<3332:R,R}
|
||||
mzn{s<1938:R,R}
|
||||
jq{m>2374:A,x<1425:A,R}
|
||||
nhh{x<3487:gnz,s>3018:jgn,tk}
|
||||
kqv{a>1168:R,R}
|
||||
mfv{a>1367:R,a>767:gv,njr}
|
||||
tn{x<1082:R,s<1473:A,A}
|
||||
cl{a<2428:cqv,skk}
|
||||
smn{m<704:R,s>1557:R,A}
|
||||
vs{s<2752:jtg,A}
|
||||
ndp{m>1613:R,a>1668:tqk,a>756:A,rtk}
|
||||
mm{x<2841:A,x>2991:R,R}
|
||||
gfc{s<2651:A,a>87:A,R}
|
||||
fc{s<3768:A,x>2927:A,s>3872:R,A}
|
||||
qd{s<1986:A,a<562:A,R}
|
||||
vtv{x<2948:cj,s<2996:gq,mfk}
|
||||
pc{m<2563:R,s>308:R,A}
|
||||
db{x>1182:R,s>2330:A,R}
|
||||
lj{a>1208:A,sn}
|
||||
vxv{s<3093:R,R}
|
||||
pkk{s<3012:A,m>2572:A,a>3749:R,R}
|
||||
phs{s<3862:R,m<1390:R,kcm}
|
||||
xt{m<784:R,s<3171:R,R}
|
||||
gkl{x>556:A,R}
|
||||
gvq{a<3510:A,m>3254:A,A}
|
||||
qx{s<248:jjm,kp}
|
||||
jjm{x<2448:A,m>2222:A,R}
|
||||
kt{s>1768:ps,kb}
|
||||
std{a>1196:R,a>1080:R,a>1034:R,R}
|
||||
lhp{m<2508:xtc,x>1732:vkp,a>1157:ln,xq}
|
||||
pxj{m>793:R,a>1699:R,A}
|
||||
bpf{s<2850:A,A}
|
||||
fkr{x>2275:A,m<2337:A,x<2147:zls,A}
|
||||
mv{m>3870:A,m>3778:A,R}
|
||||
zh{m<1090:rmv,zt}
|
||||
pj{s>2079:R,gd}
|
||||
tl{a<3073:A,m>2621:A,lq}
|
||||
mcb{x>890:A,s<1455:A,R}
|
||||
nqk{a<2608:A,m<3138:mls,bgh}
|
||||
sr{m<2392:R,m>2540:A,s<1933:R,A}
|
||||
jzc{a<2239:ptk,a<3339:A,a>3605:A,zcf}
|
||||
tfz{x<779:A,a<3380:A,m<1541:A,R}
|
||||
pvj{x<2020:R,x>2348:A,R}
|
||||
bv{a<3884:R,x>825:A,A}
|
||||
hcf{a<3816:jgs,s<2909:rbd,x>1198:sg,nvv}
|
||||
nl{a>1904:tzv,R}
|
||||
rl{s>2541:A,m>2863:R,m>2346:A,R}
|
||||
bg{x>524:R,m>927:R,a>2391:R,R}
|
||||
xsp{m>2367:zg,a>3232:zp,x>2987:qhv,A}
|
||||
nv{m>1136:jr,x<974:mn,s<299:qg,bf}
|
||||
dnv{x<3133:xz,s>1612:cx,fxp}
|
||||
tv{s<2030:A,A}
|
||||
bvx{x>3807:A,m<1978:A,a<829:R,kzn}
|
||||
fg{x>1393:A,s<1322:A,m>3693:A,A}
|
||||
vn{x>1743:bmx,s>3133:pjc,x>797:rfd,dtf}
|
||||
sn{a<720:R,m>2407:A,s>2263:R,R}
|
||||
dn{a>3435:A,A}
|
||||
pxn{s<3897:A,a<3216:A,R}
|
||||
bkf{a>800:rzg,hb}
|
||||
bpx{a<141:A,jhh}
|
||||
zls{x>2037:R,m>2919:R,A}
|
||||
xzr{a>1432:A,m>3471:A,m>2878:rqk,R}
|
||||
png{s<3217:R,A}
|
||||
lzp{s>2935:lnf,hbj}
|
||||
fxs{m<2298:A,m>3023:R,A}
|
||||
rds{x<2136:jcz,gxf}
|
||||
mc{s>3407:jb,a>1580:tks,dhr}
|
||||
lh{m<777:A,s>959:A,R}
|
||||
fq{a>3243:zzg,x<1126:rht,m<680:cl,cpk}
|
||||
cgs{m<3539:R,R}
|
||||
dtf{x<432:A,m<2598:zb,A}
|
||||
sgd{m<377:R,a<1360:A,s>2105:A,A}
|
||||
fxp{s<1476:A,a>1446:R,A}
|
||||
cgv{s>2832:A,a>3725:R,a<3721:R,R}
|
||||
rb{x>1583:R,A}
|
||||
sxb{s<2865:mhd,a<3463:tgc,s>3096:ngz,cv}
|
||||
flz{a<3242:A,A}
|
||||
hf{s<1198:A,m<1745:A,R}
|
||||
xff{a<2470:R,a<2902:R,brk}
|
||||
pq{m<1019:R,a<3493:xbh,tcn}
|
||||
qxh{s<3830:jx,a<3002:xcg,a<3523:pxn,dqt}
|
||||
ccr{a>1369:A,x<540:ngp,R}
|
||||
lx{a>3856:R,A}
|
||||
gls{s>2827:R,x>1450:A,m>760:R,R}
|
||||
fs{m>2698:hd,m<1866:A,R}
|
||||
qt{m>1524:xsp,a>3264:bz,x<2990:lcq,ddp}
|
||||
zsb{s<1967:R,x>1869:txn,s>2038:R,nf}
|
||||
xz{a>1278:A,A}
|
||||
brk{s<2250:R,A}
|
||||
xcg{a>2310:A,x>589:A,m<1935:A,A}
|
||||
gxd{a>1760:R,x<1932:R,R}
|
||||
vt{s>2550:R,std}
|
||||
mjp{a>3129:R,x>2733:R,s<2923:A,R}
|
||||
zzg{m>522:zrf,x<1493:R,x>2078:ff,A}
|
||||
fkj{x>1280:R,m>2156:R,A}
|
||||
jhc{m>746:R,a>1003:A,R}
|
||||
lz{x<2241:A,x>2443:R,A}
|
||||
cb{s<3619:cfc,a>1549:mdc,dj}
|
||||
qm{s<3512:zc,R}
|
||||
cpk{s<1607:bm,A}
|
||||
fhh{a>2658:jz,s<2865:R,s>3109:A,R}
|
||||
tgc{m>1755:A,s<3212:qzg,cp}
|
||||
cgm{s<2172:pfs,m>3075:R,A}
|
||||
jgf{a>1369:R,a>1337:A,s>2964:R,R}
|
||||
cms{m<2570:A,m<2752:vg,m<2837:R,nzs}
|
||||
jx{x>548:R,m<2561:R,x<242:A,R}
|
||||
mrc{x<3340:hx,m<1213:rpn,hvc}
|
||||
mnx{x>791:A,A}
|
||||
qzx{x>1193:A,R}
|
||||
mdc{x<3104:jdd,x<3684:hjb,phs}
|
||||
cf{m<2776:vr,x<1619:fnq,s<1471:dnf,sd}
|
||||
ds{a<815:A,tq}
|
||||
vmd{s>3862:bj,qb}
|
||||
mfc{m>3159:R,s>2590:A,s<2498:A,A}
|
||||
jrk{m<3157:sp,zhj}
|
||||
vng{m>2487:R,a<3537:A,R}
|
||||
pjc{s<3295:R,x>730:cz,R}
|
||||
pp{m>1152:R,a>708:R,A}
|
||||
lkd{a<3716:A,a>3760:bcs,a>3739:pkk,cgv}
|
||||
tks{a<2969:pxf,x>2465:jfr,a<3555:gp,hcf}
|
||||
mp{x>1865:A,R}
|
||||
jbz{a<220:A,A}
|
||||
ltx{x<3669:A,m<611:R,R}
|
||||
fb{x>527:R,m<1341:A,a<2542:R,th}
|
||||
gzj{a<3308:A,R}
|
||||
kbg{a<2673:A,x>3099:A,R}
|
||||
rtk{x<1207:R,s<322:R,m>673:R,A}
|
||||
jd{s<1420:kbg,sxd}
|
||||
bxz{m<2876:R,R}
|
||||
dfs{a<3210:A,x>3369:R,x<3277:A,A}
|
||||
np{a>2152:R,A}
|
||||
hbt{x<2680:R,a<3145:R,R}
|
||||
tx{a>3904:R,m>746:A,a>3848:R,R}
|
||||
fdx{x<1567:vxv,a<3936:ktv,jmv}
|
||||
mjv{m<2079:A,a>2843:A,x>3591:A,qhp}
|
||||
zps{m>3233:A,m<2936:R,A}
|
||||
vm{s<1569:tn,bdb}
|
||||
pch{m<1670:sms,a>1946:dm,jrk}
|
||||
br{x>3300:zxx,R}
|
||||
zf{s>242:A,R}
|
||||
ntk{s<3864:R,jhz}
|
||||
hs{s>2686:gls,x>1247:A,tx}
|
||||
xth{m<1407:bsh,a>466:hpx,xf}
|
||||
kv{m>2674:kqv,m<2325:A,x<1277:rzt,lhz}
|
||||
hfh{s<3895:A,A}
|
||||
lxc{x<1519:jjt,s<2121:zn,x<2064:bpq,nqk}
|
||||
xvp{a<1815:pj,cgm}
|
||||
rbd{m<1497:hs,dv}
|
||||
pdn{a<3048:st,s>1293:mj,s<1267:A,R}
|
||||
pxt{m<1410:R,dx}
|
||||
lg{s>413:A,s<242:A,a<1899:A,R}
|
||||
bgh{s>2275:A,R}
|
||||
gr{x<1477:R,R}
|
||||
bj{a>787:R,m<3108:A,s<3930:A,R}
|
||||
zs{m<3026:dfv,x>3208:R,s<3193:gt,R}
|
||||
vg{x<3353:R,s<2614:R,x<3633:R,R}
|
||||
lpv{s>2284:A,m<3804:A,s<2215:A,R}
|
||||
frf{a<1568:R,pf}
|
||||
lhz{x>1406:A,s>3831:R,m>2485:A,R}
|
||||
kfl{s>3825:hfh,x<675:ks,x>1039:A,pp}
|
||||
bmf{a<1331:A,R}
|
||||
sms{s>2156:sf,a>1737:rpb,a>748:lcp,zh}
|
||||
qb{s>3774:R,s<3744:A,s>3763:R,R}
|
||||
ggl{a>648:R,a>619:A,pm}
|
||||
pn{a>2902:A,s<1543:R,A}
|
||||
fkp{a>782:R,zcb}
|
||||
kgt{a<2588:pvj,m<2228:A,sr}
|
||||
fh{m<3554:R,A}
|
||||
ktl{s<3936:A,A}
|
||||
pxf{a>2341:dpm,x>1629:vtv,nxd}
|
||||
zb{m>1090:R,x<661:A,s<2926:A,A}
|
||||
bk{m>1591:hrf,m>843:frf,x<3052:nlx,br}
|
||||
xv{s<419:A,x<508:R,R}
|
||||
ngz{s>3296:fvk,A}
|
||||
jp{x<1768:R,m<1125:R,a<3381:R,R}
|
||||
rzh{s>2837:R,m>1393:A,A}
|
||||
dcs{a>1227:A,x<3362:R,R}
|
||||
fcc{m>419:A,m>228:A,A}
|
||||
ddp{a>3072:A,R}
|
||||
chk{x>988:R,lrb}
|
||||
bcs{a<3795:A,R}
|
||||
nq{x<2015:R,s>362:R,m<203:A,R}
|
||||
jhh{a<214:A,A}
|
||||
crg{a>3600:A,x>3090:sj,x<2861:R,R}
|
||||
gt{m>3484:A,R}
|
||||
jr{s>251:A,x<711:A,R}
|
||||
sp{s>2177:lj,x<890:fkp,a<1241:hgz,zsb}
|
||||
ntz{s>2967:R,x>686:R,A}
|
||||
lk{x<1915:ndp,x>2905:rks,a>1647:fd,qx}
|
||||
mr{a<3298:A,a<3316:kls,crs}
|
||||
dfv{a<3566:A,x>3241:A,a>3665:A,R}
|
||||
ncf{a>1373:R,a>908:R,R}
|
||||
dd{m>2969:A,s>3581:R,R}
|
||||
vxx{a<251:R,A}
|
||||
hgz{s>1957:kh,a<472:sdx,m<2611:A,R}
|
||||
jdd{a<2697:fc,m<1777:A,glg}
|
||||
xq{a>1074:chk,a<1022:mps,xhj}
|
||||
ts{x>3265:A,m<3294:R,A}
|
||||
zc{s>3447:A,s>3429:R,m<2140:A,R}
|
||||
bx{x<3604:xxf,a<484:fxs,R}
|
||||
hjb{s>3819:A,x<3453:R,x<3591:kz,A}
|
||||
njr{x>1531:A,s<1460:R,R}
|
||||
lhx{a<2491:mt,m>1715:dl,s<1110:rds,sz}
|
||||
jlp{m>455:R,s<3610:R,R}
|
||||
rhx{m<2943:A,R}
|
||||
ptn{a<2505:lk,m<2031:lbz,cxv}
|
||||
ndq{s<2335:R,R}
|
||||
ng{s>2739:A,x>3185:A,R}
|
||||
lbp{s<2669:R,m<1543:R,x>1794:R,R}
|
||||
zxx{m>350:A,s>2187:A,x<3431:A,R}
|
||||
hqq{a<808:A,s>2584:ms,A}
|
||||
czc{x<1439:R,R}
|
||||
pf{s>2070:A,a>2463:R,m<1154:R,A}
|
||||
mfk{a<1948:R,png}
|
||||
vns{m<2846:R,s>422:R,A}
|
||||
jmk{x<2178:A,a>3930:R,A}
|
||||
ss{s>1952:R,x>1315:A,A}
|
||||
bc{x<1955:A,a>119:R,m<1469:A,R}
|
||||
kvc{a>2746:R,a>2606:A,R}
|
||||
ptd{x<1467:A,x<2037:A,A}
|
||||
svb{s>1963:md,dhh}
|
||||
zmc{s>1542:lx,m<3249:R,a>3822:R,dmf}
|
||||
dcm{x>3146:sv,x>2890:R,bsv}
|
||||
dnf{m<3282:R,s>1413:A,fh}
|
||||
qg{m<1048:R,s>179:A,R}
|
||||
tf{x>2891:A,A}
|
||||
pg{s>3693:qxh,m<2372:fb,fqd}
|
||||
sxd{x>3164:R,A}
|
||||
lgh{m>2281:R,A}
|
||||
fnq{s<1485:A,a<3295:pn,A}
|
||||
jb{x<1564:hm,x>2605:cb,rr}
|
||||
sz{s<1235:pq,m>756:lnz,pdn}
|
||||
zt{x<1498:R,a>306:qd,a<198:bc,A}
|
||||
fvk{a<3520:A,R}
|
||||
mfn{x<2646:A,A}
|
||||
gfp{s>2804:jp,s<2578:bt,A}
|
||||
jmb{a<3416:R,R}
|
||||
tzv{a<2166:R,m<2437:A,R}
|
||||
vc{a<1314:R,a<1410:jgf,a>1491:A,A}
|
||||
vk{m<995:A,m<1328:R,R}
|
||||
pt{m>1440:R,x>1184:A,m<1238:A,A}
|
||||
txb{s>1786:zz,x<172:R,s<1766:A,qh}
|
||||
llc{s>1503:R,s>1417:A,x>2946:R,R}
|
||||
tj{x>1826:A,a>2662:A,A}
|
||||
xh{s<1993:R,a>1164:R,R}
|
||||
jzf{x>3174:A,x<2760:A,A}
|
||||
zn{a<2350:tvz,x<2058:bb,A}
|
||||
pfs{x<3298:R,s>1993:R,R}
|
||||
pmp{a<531:A,R}
|
||||
xtc{x<1755:lcn,s>2778:jnc,vt}
|
||||
kql{s>1670:A,R}
|
||||
ktq{s<3229:A,s<3320:A,m<3284:A,A}
|
||||
zcf{a>3429:R,m<2504:A,R}
|
||||
kz{m>1758:A,A}
|
||||
gps{a>1924:bdv,s<2811:bs,R}
|
||||
ms{a<887:R,A}
|
||||
sh{m>1213:A,m<628:R,a<278:A,A}
|
||||
jtg{a<2615:A,x<1428:R,A}
|
||||
qkk{s<3538:R,A}
|
||||
sj{a>3576:A,s>3252:R,x>3403:A,R}
|
||||
lnz{x>2017:flz,a>3320:R,a<3030:R,R}
|
||||
svk{s<1269:A,x<2459:fg,x>3335:R,xxr}
|
||||
dk{x>3445:A,m>2894:A,a>2714:R,A}
|
||||
ck{a>820:R,s<1878:R,A}
|
||||
mzl{m<1102:qj,x<626:rcn,s<2282:A,pt}
|
||||
cm{m>2496:R,A}
|
||||
in{s<2403:pxm,mc}
|
||||
mgr{x>1261:A,s<2247:A,s>2332:R,R}
|
||||
rpb{x<1235:gf,a>3150:svb,xlg}
|
||||
rzt{s<3861:R,R}
|
||||
fcp{a<391:sm,x>658:R,x<235:A,R}
|
||||
mz{a>3217:R,x<568:pc,a<2806:R,R}
|
||||
gnz{m>3220:R,x>3030:bpf,m>2804:R,kr}
|
||||
lcn{a<1364:bfc,x>713:mx,R}
|
||||
ld{a>1185:R,A}
|
||||
tk{x<3736:hzl,a>3880:R,x<3854:pd,A}
|
||||
qst{s<1649:R,x>1581:A,s>1662:R,A}
|
||||
zzn{s>1422:lb,a>2822:ts,A}
|
||||
sq{a>2419:cf,xn}
|
||||
dl{s<1027:hdq,m<3118:jmb,s>1207:svk,cgs}
|
||||
dgs{s>933:R,a>1219:hmn,R}
|
||||
tcn{m<1316:R,A}
|
||||
dx{m<2691:R,R}
|
||||
mj{a>3607:R,a<3295:R,R}
|
||||
cp{x>1744:R,R}
|
||||
gp{a<3265:xtn,a<3409:vlr,x<874:vj,sxb}
|
||||
ffm{m<2925:A,tzj}
|
||||
sv{x<3623:R,x<3865:A,x>3953:A,A}
|
||||
vjh{s<696:ptn,lhx}
|
||||
kh{m<2223:A,x>1640:A,R}
|
||||
sl{x>3116:R,m<1100:A,m<1681:mm,tf}
|
||||
jv{x>3205:R,A}
|
||||
rf{a<2331:tzd,s<1687:kqp,lf}
|
||||
zg{m>3278:A,m<2822:R,x>3249:R,R}
|
||||
nkt{m<3763:R,a<3625:R,a>3767:R,R}
|
||||
lcp{m<816:nk,s<2030:zgf,cq}
|
||||
hvc{x<3758:pvh,m<1480:A,s<1575:R,A}
|
||||
rks{x<3595:R,m<2372:A,A}
|
||||
lrb{x<621:A,x<843:A,x>898:A,A}
|
||||
zx{m>2405:A,x>1653:R,bmg}
|
||||
nnf{m>536:A,A}
|
||||
bfc{x<991:A,R}
|
||||
hd{a>2374:R,R}
|
||||
zrf{x<1430:R,A}
|
||||
qk{m<1019:R,x<994:R,m<1047:R,A}
|
||||
bsv{s<3158:R,x<2672:R,a>3513:R,A}
|
||||
ff{x<2379:A,A}
|
||||
pxm{s<1369:vjh,x>2564:kt,s>1811:pch,hsx}
|
||||
gxf{a>3398:A,x<3277:bq,lh}
|
||||
kls{m<1031:A,s>2876:R,s>2644:A,R}
|
||||
qqh{x<3795:A,R}
|
||||
nvv{s<3241:znz,bnl}
|
||||
cqk{s<3859:R,ncf}
|
||||
jjt{s<2037:ss,mgr}
|
||||
qzb{s>2804:R,df}
|
||||
rht{s>1650:R,bg}
|
||||
rmv{a<459:A,m>488:A,A}
|
||||
bmx{m>1850:A,sh}
|
||||
ptk{m>2955:R,R}
|
||||
tg{x<3192:llc,a>3346:R,x<3633:dfs,qqh}
|
||||
bnl{s>3326:dmm,m>2318:jc,a<3895:R,R}
|
||||
cfc{x<3480:qm,a<1363:bvx,x<3745:mjv,bbv}
|
||||
xlp{x>460:A,m<2590:rzh,R}
|
||||
bb{s<1924:R,A}
|
||||
shq{x>1246:A,a>3207:tpb,x<826:xv,jzx}
|
||||
lp{s>1698:R,a<1429:R,R}
|
||||
kkh{a<1643:A,A}
|
||||
rzg{s<1629:sdm,a>1245:lp,a>1083:R,A}
|
||||
xgv{x<2900:R,xb}
|
||||
bh{m>2126:R,s<1916:A,x>3791:A,A}
|
||||
cs{s>1272:mfn,a<1174:hf,R}
|
||||
lbz{m<921:jg,x>2079:xgv,m<1295:nv,shq}
|
||||
lxg{x<826:R,A}
|
||||
rdh{x>982:R,A}
|
||||
kcm{x>3875:A,m>2918:A,m>2407:A,R}
|
||||
rqz{a<3893:A,m>1449:jmk,x>2106:A,A}
|
||||
vl{x>3363:zjn,x>3065:jv,A}
|
||||
tt{x>1484:R,m>2484:A,a<1512:A,A}
|
||||
dhr{a<597:xrs,a>941:lhp,lzp}
|
||||
crs{a>3323:R,m>1119:A,x>1452:R,A}
|
||||
rcn{m>1445:R,x>347:A,a>1485:A,R}
|
||||
tzd{x<1859:tt,A}
|
||||
lcs{s>3607:cqk,s<3524:xs,xdc}
|
||||
tqk{x>1006:R,a<2151:A,A}
|
||||
tpb{a>3497:R,A}
|
||||
xj{a<3083:A,m>1619:R,x<1091:A,gxh}
|
||||
xd{x>1933:pxt,mfl}
|
||||
fd{x<2466:cm,a>2195:R,x<2715:lg,R}
|
||||
xb{m<1347:A,A}
|
||||
mkt{x>2312:A,R}
|
||||
vj{x<379:tp,x>561:thj,xlp}
|
||||
|
||||
{x=380,m=329,a=917,s=255}
|
||||
{x=486,m=681,a=11,s=452}
|
||||
{x=893,m=376,a=51,s=1662}
|
||||
{x=1223,m=1194,a=1038,s=92}
|
||||
{x=267,m=299,a=9,s=2591}
|
||||
{x=65,m=557,a=1437,s=1063}
|
||||
{x=1147,m=46,a=258,s=1255}
|
||||
{x=198,m=1186,a=151,s=291}
|
||||
{x=2758,m=1247,a=177,s=616}
|
||||
{x=470,m=1001,a=876,s=79}
|
||||
{x=704,m=2422,a=1273,s=2345}
|
||||
{x=927,m=2901,a=95,s=2889}
|
||||
{x=1241,m=221,a=1151,s=444}
|
||||
{x=1604,m=1310,a=58,s=160}
|
||||
{x=229,m=438,a=548,s=733}
|
||||
{x=1024,m=946,a=406,s=1582}
|
||||
{x=1083,m=277,a=1599,s=1926}
|
||||
{x=472,m=612,a=638,s=925}
|
||||
{x=1344,m=833,a=276,s=2381}
|
||||
{x=6,m=2045,a=1033,s=3120}
|
||||
{x=1204,m=699,a=1281,s=310}
|
||||
{x=262,m=689,a=314,s=2847}
|
||||
{x=526,m=107,a=1469,s=1423}
|
||||
{x=475,m=723,a=485,s=1011}
|
||||
{x=114,m=1049,a=2058,s=885}
|
||||
{x=254,m=1238,a=401,s=1120}
|
||||
{x=1259,m=1158,a=113,s=889}
|
||||
{x=802,m=43,a=1178,s=1081}
|
||||
{x=93,m=1964,a=849,s=27}
|
||||
{x=1657,m=24,a=480,s=94}
|
||||
{x=609,m=198,a=2318,s=682}
|
||||
{x=341,m=435,a=228,s=347}
|
||||
{x=3411,m=15,a=739,s=575}
|
||||
{x=360,m=2780,a=322,s=3534}
|
||||
{x=106,m=295,a=3151,s=993}
|
||||
{x=121,m=292,a=24,s=1042}
|
||||
{x=464,m=246,a=377,s=662}
|
||||
{x=1060,m=919,a=992,s=631}
|
||||
{x=562,m=1532,a=1579,s=2957}
|
||||
{x=484,m=61,a=500,s=1107}
|
||||
{x=551,m=2370,a=515,s=146}
|
||||
{x=370,m=248,a=519,s=1796}
|
||||
{x=1945,m=299,a=49,s=921}
|
||||
{x=2324,m=2780,a=2268,s=17}
|
||||
{x=267,m=223,a=871,s=786}
|
||||
{x=66,m=3536,a=1272,s=446}
|
||||
{x=1450,m=591,a=14,s=1961}
|
||||
{x=1107,m=1181,a=2033,s=451}
|
||||
{x=1197,m=519,a=1782,s=561}
|
||||
{x=1174,m=548,a=1494,s=123}
|
||||
{x=496,m=3050,a=812,s=407}
|
||||
{x=2824,m=638,a=2378,s=508}
|
||||
{x=1215,m=1033,a=1816,s=607}
|
||||
{x=768,m=2648,a=2255,s=1314}
|
||||
{x=1518,m=2155,a=2,s=1036}
|
||||
{x=1923,m=83,a=661,s=409}
|
||||
{x=2019,m=850,a=1935,s=477}
|
||||
{x=27,m=1351,a=1634,s=530}
|
||||
{x=488,m=356,a=310,s=16}
|
||||
{x=1321,m=533,a=814,s=519}
|
||||
{x=393,m=625,a=3304,s=1848}
|
||||
{x=1286,m=111,a=1070,s=1201}
|
||||
{x=991,m=704,a=195,s=2104}
|
||||
{x=3191,m=42,a=888,s=195}
|
||||
{x=13,m=2580,a=1811,s=417}
|
||||
{x=27,m=373,a=126,s=559}
|
||||
{x=280,m=1062,a=681,s=445}
|
||||
{x=894,m=1350,a=670,s=3477}
|
||||
{x=100,m=290,a=236,s=255}
|
||||
{x=1809,m=2398,a=239,s=1972}
|
||||
{x=678,m=222,a=1015,s=990}
|
||||
{x=1821,m=547,a=46,s=142}
|
||||
{x=852,m=316,a=3201,s=43}
|
||||
{x=19,m=1365,a=49,s=1051}
|
||||
{x=451,m=302,a=2964,s=591}
|
||||
{x=1505,m=1563,a=565,s=38}
|
||||
{x=1799,m=299,a=241,s=475}
|
||||
{x=157,m=1206,a=341,s=30}
|
||||
{x=2577,m=893,a=2531,s=1317}
|
||||
{x=499,m=1354,a=613,s=1068}
|
||||
{x=3862,m=302,a=640,s=681}
|
||||
{x=22,m=1499,a=2658,s=837}
|
||||
{x=1168,m=2431,a=36,s=1560}
|
||||
{x=982,m=954,a=523,s=506}
|
||||
{x=637,m=1894,a=1012,s=47}
|
||||
{x=2671,m=53,a=164,s=2067}
|
||||
{x=87,m=1059,a=3603,s=1182}
|
||||
{x=144,m=506,a=3266,s=292}
|
||||
{x=25,m=1339,a=2362,s=567}
|
||||
{x=2684,m=286,a=287,s=16}
|
||||
{x=493,m=1200,a=1136,s=549}
|
||||
{x=115,m=2243,a=1228,s=1609}
|
||||
{x=1142,m=155,a=2571,s=2808}
|
||||
{x=1129,m=66,a=1762,s=1055}
|
||||
{x=2105,m=1083,a=579,s=286}
|
||||
{x=90,m=1196,a=1372,s=2115}
|
||||
{x=198,m=2277,a=794,s=1768}
|
||||
{x=87,m=2331,a=707,s=654}
|
||||
{x=2068,m=112,a=230,s=1648}
|
||||
{x=612,m=716,a=66,s=124}
|
||||
{x=1935,m=256,a=2203,s=251}
|
||||
{x=2117,m=1,a=71,s=255}
|
||||
{x=1244,m=842,a=1714,s=1013}
|
||||
{x=91,m=186,a=909,s=3282}
|
||||
{x=1062,m=614,a=285,s=2007}
|
||||
{x=1414,m=1555,a=781,s=3500}
|
||||
{x=109,m=568,a=1996,s=50}
|
||||
{x=96,m=1032,a=876,s=1297}
|
||||
{x=2351,m=516,a=2179,s=89}
|
||||
{x=385,m=1162,a=1858,s=6}
|
||||
{x=1035,m=8,a=27,s=2352}
|
||||
{x=1604,m=201,a=14,s=273}
|
||||
{x=5,m=304,a=809,s=170}
|
||||
{x=1806,m=690,a=87,s=1015}
|
||||
{x=1277,m=609,a=2236,s=3938}
|
||||
{x=1687,m=834,a=2969,s=28}
|
||||
{x=288,m=1255,a=457,s=60}
|
||||
{x=363,m=2289,a=333,s=1596}
|
||||
{x=334,m=233,a=1967,s=806}
|
||||
{x=239,m=23,a=1101,s=1689}
|
||||
{x=536,m=1102,a=317,s=3}
|
||||
{x=710,m=755,a=206,s=2276}
|
||||
{x=458,m=2985,a=20,s=2107}
|
||||
{x=1582,m=785,a=594,s=888}
|
||||
{x=188,m=3154,a=337,s=1770}
|
||||
{x=148,m=1575,a=2032,s=434}
|
||||
{x=1240,m=134,a=431,s=2672}
|
||||
{x=884,m=539,a=1963,s=206}
|
||||
{x=1418,m=1822,a=3680,s=261}
|
||||
{x=1240,m=1333,a=901,s=248}
|
||||
{x=601,m=3123,a=1399,s=374}
|
||||
{x=314,m=63,a=325,s=256}
|
||||
{x=911,m=1106,a=146,s=70}
|
||||
{x=1003,m=3328,a=608,s=1374}
|
||||
{x=180,m=415,a=2814,s=1821}
|
||||
{x=330,m=411,a=982,s=1378}
|
||||
{x=3315,m=8,a=505,s=2292}
|
||||
{x=312,m=2130,a=168,s=574}
|
||||
{x=690,m=762,a=348,s=691}
|
||||
{x=1483,m=81,a=2107,s=16}
|
||||
{x=1390,m=60,a=1620,s=3}
|
||||
{x=1612,m=38,a=776,s=1259}
|
||||
{x=138,m=12,a=145,s=1061}
|
||||
{x=350,m=571,a=22,s=1209}
|
||||
{x=488,m=1476,a=1086,s=1916}
|
||||
{x=1223,m=3412,a=1776,s=1521}
|
||||
{x=1509,m=11,a=1185,s=756}
|
||||
{x=14,m=965,a=350,s=3055}
|
||||
{x=342,m=38,a=1161,s=818}
|
||||
{x=1423,m=745,a=613,s=365}
|
||||
{x=552,m=508,a=1445,s=2403}
|
||||
{x=54,m=543,a=1924,s=157}
|
||||
{x=172,m=59,a=1575,s=1378}
|
||||
{x=2066,m=818,a=2385,s=1163}
|
||||
{x=2368,m=1694,a=465,s=1568}
|
||||
{x=1266,m=133,a=2497,s=240}
|
||||
{x=663,m=683,a=2924,s=2232}
|
||||
{x=537,m=1355,a=187,s=1305}
|
||||
{x=2555,m=2010,a=177,s=845}
|
||||
{x=1065,m=209,a=49,s=264}
|
||||
{x=840,m=102,a=2234,s=2890}
|
||||
{x=137,m=144,a=1454,s=5}
|
||||
{x=39,m=63,a=2040,s=281}
|
||||
{x=92,m=331,a=3823,s=1301}
|
||||
{x=1017,m=2377,a=147,s=2734}
|
||||
{x=2217,m=1176,a=1067,s=704}
|
||||
{x=2061,m=1184,a=1660,s=375}
|
||||
{x=580,m=3270,a=1203,s=637}
|
||||
{x=1445,m=1059,a=181,s=1158}
|
||||
{x=374,m=311,a=206,s=76}
|
||||
{x=2672,m=2024,a=441,s=2436}
|
||||
{x=63,m=32,a=26,s=3041}
|
||||
{x=579,m=603,a=129,s=195}
|
||||
{x=2619,m=235,a=867,s=730}
|
||||
{x=452,m=250,a=1665,s=1948}
|
||||
{x=1592,m=117,a=2253,s=1474}
|
||||
{x=567,m=1601,a=559,s=263}
|
||||
{x=3698,m=156,a=115,s=3232}
|
||||
{x=149,m=1580,a=302,s=61}
|
||||
{x=165,m=702,a=2321,s=822}
|
||||
{x=1158,m=991,a=1549,s=1155}
|
||||
{x=793,m=689,a=1205,s=2663}
|
||||
{x=81,m=1059,a=1142,s=1921}
|
||||
{x=1414,m=946,a=860,s=1350}
|
||||
{x=1521,m=1125,a=359,s=1496}
|
||||
{x=250,m=1164,a=3446,s=594}
|
||||
{x=1580,m=41,a=164,s=130}
|
||||
{x=2469,m=1196,a=1060,s=472}
|
||||
{x=98,m=1444,a=1226,s=2154}
|
||||
{x=86,m=1948,a=1124,s=1944}
|
||||
{x=1592,m=618,a=1459,s=22}
|
||||
{x=866,m=1120,a=1696,s=508}
|
||||
{x=371,m=1236,a=1553,s=1166}
|
||||
{x=2679,m=2544,a=1114,s=2995}
|
||||
{x=761,m=1377,a=1002,s=24}
|
||||
{x=2122,m=2991,a=883,s=75}
|
||||
{x=685,m=687,a=516,s=214}
|
||||
{x=1014,m=1270,a=263,s=1107}
|
||||
{x=153,m=209,a=16,s=946}
|
||||
{x=1529,m=191,a=865,s=2634}
|
17
19/input_test
Normal file
17
19/input_test
Normal file
@@ -0,0 +1,17 @@
|
||||
px{a<2006:qkq,m>2090:A,rfg}
|
||||
pv{a>1716:R,A}
|
||||
lnx{m>1548:A,A}
|
||||
rfg{s<537:gd,x>2440:R,A}
|
||||
qs{s>3448:A,lnx}
|
||||
qkq{x<1416:A,crn}
|
||||
crn{x>2662:A,R}
|
||||
in{s<1351:px,qqz}
|
||||
qqz{s>2770:qs,m<1801:hdj,R}
|
||||
gd{a>3333:R,R}
|
||||
hdj{m>838:A,pv}
|
||||
|
||||
{x=787,m=2655,a=1222,s=2876}
|
||||
{x=1679,m=44,a=2067,s=496}
|
||||
{x=2036,m=264,a=79,s=2244}
|
||||
{x=2461,m=1339,a=466,s=291}
|
||||
{x=2127,m=1623,a=2188,s=1013}
|
407
19/main.s
Normal file
407
19/main.s
Normal file
@@ -0,0 +1,407 @@
|
||||
%include "utils.s"
|
||||
|
||||
global _start
|
||||
[bits 32]
|
||||
[section .text]
|
||||
|
||||
%define FILENAME "input"
|
||||
;%define FILENAME "input_test"
|
||||
|
||||
_start:
|
||||
|
||||
mov esi, file
|
||||
load_rule:
|
||||
xor ebx, ebx ; id
|
||||
.get_id:
|
||||
lodsb
|
||||
cmp al, '{'
|
||||
je .got_id
|
||||
shl ebx, 8
|
||||
mov bl, al ; add new byte
|
||||
jmp .get_id
|
||||
.got_id:
|
||||
call id_to_idx ; idx in EDX
|
||||
shl edx, 4 ; *16
|
||||
lea edi, [rules+edx] ; rule ptr
|
||||
.get_rules:
|
||||
; --- rule format ---
|
||||
; [ 16 ]
|
||||
; [ 4 ][ 4 ][ 4 ][ 4 ]
|
||||
; [ 2 ] [ 2 ][ 2 ] [ 2 ][ 2 ] [ 2 ][ 2 ] [ 2 ]
|
||||
; [bound] [ vdr ][bound] [ vdr ][bound] [ vdr ][bound] [ vdr ]
|
||||
|
||||
; var, dir, & res
|
||||
; FEDCBA9876543210
|
||||
; --- var --- 76543210
|
||||
; ...............1 -> Always
|
||||
; .............00. -> a (ASCII .1100...)
|
||||
; .............01. -> m (ASCII .1101...)
|
||||
; .............10. -> s (ASCII .1110...)
|
||||
; .............11. -> x (ASCII .1111...)
|
||||
; --- dir ---
|
||||
; ............0... -> < (ASCII .0....0.)
|
||||
; ............1... -> > (ASCII .0....1.)
|
||||
; --- res ---
|
||||
; 111111111111.... -> R (ASCII .10....0 bit 0 - 1 -> ..111)
|
||||
; 000000000000.... -> A (ASCII .10....1 bit 0 - 1 -> ..000)
|
||||
; NNNNNNNNNNNN.... -> eval
|
||||
|
||||
xor ecx, ecx ; output vdr & bound
|
||||
xor eax, eax ; input byte
|
||||
lodsb ; lowercase alpha or RA
|
||||
bt ax, 5 ; low for RA, high for alpha
|
||||
jc .alpha
|
||||
; immediately finish with R or A
|
||||
or cx, 1 ; Always
|
||||
and ax, 1 ; bit 0 of ASCII
|
||||
dec ax ; R -> -1, A -> 0
|
||||
shl ax, 4 ; correct position
|
||||
or cx, ax
|
||||
jmp .done
|
||||
.alpha: ; either [xmas][><] or a multi-char ID
|
||||
mov ebx, eax ; save last input
|
||||
lodsb ; next byte
|
||||
bt ax, 6 ; bit 6 low for ><
|
||||
jnc .is_check
|
||||
; immediately finish by evaluating ID
|
||||
.imm_got_id_byte:
|
||||
shl ebx, 8
|
||||
mov bl, al
|
||||
.imm_get_full_id:
|
||||
lodsb
|
||||
cmp al, ',' ; ends , or }
|
||||
je .imm_got_id
|
||||
cmp al, '}'
|
||||
jne .imm_got_id_byte
|
||||
.imm_got_id:
|
||||
call id_to_idx ; idx in EDX
|
||||
or cx, 1 ; out.var <- Always
|
||||
shl edx, 4 ; correct position
|
||||
or cx, dx ; out.res <- idx
|
||||
jmp .done
|
||||
.is_check:
|
||||
and bx, 3<<3
|
||||
shr bx, 2
|
||||
or cx, bx ; out.var <- bits 3&4 of last
|
||||
and ax, 1<<1
|
||||
shl ax, 2
|
||||
or cx, ax ; out.dir <- bit 1 of ASCII
|
||||
call dec_parse
|
||||
mov bx, cx
|
||||
mov cx, ax
|
||||
shl ecx, 16
|
||||
mov cx, bx ; out.bound <- parse_dec
|
||||
; parse_dec skips the : so get the res
|
||||
lodsb
|
||||
bt ax, 5
|
||||
jc .chk_id
|
||||
; res is R or A
|
||||
and ax, 1
|
||||
dec ax
|
||||
shl ax, 4
|
||||
or cx, ax ; out.res <- bit 0 of ASCII - 1
|
||||
jmp .done
|
||||
.chk_id: ; res is ID
|
||||
xor ebx, ebx
|
||||
jmp .chk_got_id_byte
|
||||
.chk_next_byte:
|
||||
lodsb
|
||||
cmp al, ',' ; ends ,
|
||||
je .chk_got_id
|
||||
.chk_got_id_byte:
|
||||
shl ebx, 8
|
||||
mov bl, al
|
||||
jmp .chk_next_byte
|
||||
.chk_got_id:
|
||||
call id_to_idx ; idx in EDX
|
||||
shl edx, 4
|
||||
or cx, dx ; out.res <- idx
|
||||
.done:
|
||||
mov eax, ecx
|
||||
stosd
|
||||
cmp byte [esi-1], ','
|
||||
je .get_rules
|
||||
cmp byte [esi], ','
|
||||
je .next_rule
|
||||
cmp byte [esi-1], '}'
|
||||
je .next_line
|
||||
cmp byte [esi], '}'
|
||||
je .next_line
|
||||
cmp byte [esi-1], 10
|
||||
je .check_rules_over
|
||||
call newline
|
||||
.wtf: p_string wtf
|
||||
jmp .wtf
|
||||
.next_rule:
|
||||
inc esi
|
||||
jmp .get_rules
|
||||
.next_line:
|
||||
lodsb
|
||||
cmp al, 10 ; \n
|
||||
jne .next_line
|
||||
.check_rules_over:
|
||||
cmp byte [esi], 10
|
||||
jne load_rule
|
||||
|
||||
rules_over:
|
||||
mov eax, [next_rule_idx]
|
||||
dec eax
|
||||
call print_dec
|
||||
call newline
|
||||
|
||||
; find rule 'in'
|
||||
mov ebx, 'ni'
|
||||
call id_to_idx
|
||||
mov [in_idx], edx
|
||||
mov eax, edx
|
||||
call print_dec
|
||||
call space
|
||||
shl edx, 4
|
||||
movzx eax, word [rules+edx]
|
||||
call print_dec
|
||||
call space
|
||||
movzx eax, word [rules+edx+2]
|
||||
call print_dec
|
||||
call newline
|
||||
|
||||
proc_next_input:
|
||||
; go through the rules
|
||||
mov ebx, [in_idx]
|
||||
push 1 ; x min
|
||||
push 4001 ; x max (exclusive)
|
||||
push 1 ; m min
|
||||
push 4001 ; m max (exclusive)
|
||||
push 1 ; a min
|
||||
push 4001 ; a max (exclusive)
|
||||
push 1 ; s min
|
||||
push 4001 ; s max (exclusive)
|
||||
call check_rule
|
||||
jmp game_over
|
||||
|
||||
|
||||
; rule idx in EBX, xmas ranges on stack (args)
|
||||
; ebp+36 x min
|
||||
; ebp+32 x max (exclusive)
|
||||
; ebp+28 m min
|
||||
; ebp+24 m max (exclusive)
|
||||
; ebp+20 a min
|
||||
; ebp+16 a max (exclusive)
|
||||
; ebp+12 s min
|
||||
; ebp+ 8 s max (exclusive)
|
||||
; ebp+ 4 return loc
|
||||
; ebp+ 0 ebp
|
||||
; ebp- 4 rule ptr
|
||||
check_rule:
|
||||
push ebp
|
||||
mov ebp, esp ; a proper C-like stackframe!? egads!
|
||||
sub esp, 4
|
||||
.inner:
|
||||
shl ebx, 4
|
||||
lea esi, [rules+ebx] ; rule ptr
|
||||
mov [esp], esi
|
||||
.next_rule:
|
||||
mov esi, [esp]
|
||||
lodsd ; rule
|
||||
mov [esp], esi
|
||||
bt ax, 0 ; always
|
||||
jc .always
|
||||
; .............00. -> a
|
||||
; .............01. -> m
|
||||
; .............10. -> s
|
||||
; .............11. -> x
|
||||
; ............0... -> <
|
||||
; ............1... -> >
|
||||
mov esi, eax
|
||||
shr esi, 16 ; bound
|
||||
mov ebx, eax
|
||||
and bl, 0b1110 ; dir & var
|
||||
cmp bl, 0b0110
|
||||
je .xl
|
||||
cmp bl, 0b0010
|
||||
je .ml
|
||||
cmp bl, 0b0000
|
||||
je .al
|
||||
cmp bl, 0b0100
|
||||
je .sl
|
||||
cmp bl, 0b1110
|
||||
je .xg
|
||||
cmp bl, 0b1010
|
||||
je .mg
|
||||
cmp bl, 0b1000
|
||||
je .ag
|
||||
cmp bl, 0b1100
|
||||
je .sg
|
||||
mov eax, [0] ; something is horribly wrong
|
||||
.xl: ; matched x range is x min to bound, inverse is bound to x max
|
||||
xchg esi, [ebp+32] ; bound -> our max, our old max -> esi
|
||||
call .internal_thing
|
||||
xchg esi, [ebp+32] ; restore old max
|
||||
mov [ebp+36], esi ; bound -> our min
|
||||
jmp .next_rule
|
||||
.ml: ; matched m range is m min to bound, inverse is bound to m max
|
||||
xchg esi, [ebp+24] ; bound -> our max, our old max -> esi
|
||||
call .internal_thing
|
||||
xchg esi, [ebp+24] ; restore old max
|
||||
mov [ebp+28], esi ; bound -> our min
|
||||
jmp .next_rule
|
||||
.al: ; matched a range is a min to bound, inverse is bound to a max
|
||||
xchg esi, [ebp+16] ; bound -> our max, our old max -> esi
|
||||
call .internal_thing
|
||||
xchg esi, [ebp+16] ; restore old max
|
||||
mov [ebp+20], esi ; bound -> our min
|
||||
jmp .next_rule
|
||||
.sl: ; matched s range is s min to bound, inverse is bound to s max
|
||||
xchg esi, [ebp+ 8] ; bound -> our max, our old max -> esi
|
||||
call .internal_thing
|
||||
xchg esi, [ebp+ 8] ; restore old max
|
||||
mov [ebp+12], esi ; bound -> our min
|
||||
jmp .next_rule
|
||||
.xg: ; matched x range is bound+1 to x max, inverse is x min to bound+1
|
||||
inc esi
|
||||
xchg esi, [ebp+36] ; bound+1 -> our min, our old min -> esi
|
||||
call .internal_thing
|
||||
xchg esi, [ebp+36] ; restore old min
|
||||
mov [ebp+32], esi ; bound+1 -> our max
|
||||
jmp .next_rule
|
||||
.mg: ; matched m range is bound+1 to m max, inverse is m min to bound+1
|
||||
inc esi
|
||||
xchg esi, [ebp+28] ; bound+1 -> our min, our old min -> esi
|
||||
call .internal_thing
|
||||
xchg esi, [ebp+28] ; restore old min
|
||||
mov [ebp+24], esi ; bound+1 -> our max
|
||||
jmp .next_rule
|
||||
.ag: ; matched a range is bound+1 to a max, inverse is a min to bound+1
|
||||
inc esi
|
||||
xchg esi, [ebp+20] ; bound+1 -> our min, our old min -> esi
|
||||
call .internal_thing
|
||||
xchg esi, [ebp+20] ; restore old min
|
||||
mov [ebp+16], esi ; bound+1 -> our max
|
||||
jmp .next_rule
|
||||
.sg: ; matched a range is bound+1 to s max, inverse is s min to bound+1
|
||||
inc esi
|
||||
xchg esi, [ebp+12] ; bound+1 -> our min, our old min -> esi
|
||||
call .internal_thing
|
||||
xchg esi, [ebp+12] ; restore old min
|
||||
mov [ebp+ 8], esi ; bound+1 -> our max
|
||||
jmp .next_rule
|
||||
.always:
|
||||
shr ax, 4 ; rule.res
|
||||
test ax, ax
|
||||
jz .return_res_A
|
||||
cmp ax, 0x0FFF
|
||||
je .return_res_R
|
||||
; nested rule
|
||||
movzx ebx, ax
|
||||
jmp .inner
|
||||
.return_res_A:
|
||||
call .A
|
||||
.return_res_R:
|
||||
add esp, 4 ; stackframe gone :c
|
||||
pop ebp
|
||||
ret
|
||||
.internal_thing:
|
||||
mov ebx, eax
|
||||
shr ax, 4 ; rule.res
|
||||
test ax, ax
|
||||
jz .A
|
||||
cmp ax, 0x0FFF
|
||||
je .R
|
||||
; we need to make a recursive call, set up args
|
||||
push esi
|
||||
movzx ebx, ax
|
||||
push dword [ebp+36] ; x min
|
||||
push dword [ebp+32] ; x max
|
||||
push dword [ebp+28] ; m min
|
||||
push dword [ebp+24] ; m max
|
||||
push dword [ebp+20] ; a min
|
||||
push dword [ebp+16] ; a max
|
||||
push dword [ebp+12] ; s min
|
||||
push dword [ebp+ 8] ; s max
|
||||
call check_rule
|
||||
add esp, 4*8
|
||||
pop esi
|
||||
jmp .R
|
||||
.A:
|
||||
pushad
|
||||
sub esp, 8 ; scratch memory
|
||||
; final_value += (xMax-xMin)*
|
||||
; (mMax-mMin)*
|
||||
; (aMax-aMin)*
|
||||
; (sMax-sMin);
|
||||
mov eax, [ebp+32]
|
||||
sub eax, [ebp+36]
|
||||
js .no_add
|
||||
xor edx, edx
|
||||
mov ecx, [ebp+24]
|
||||
sub ecx, [ebp+28]
|
||||
js .no_add
|
||||
imul edx, ecx
|
||||
mov [esp], edx
|
||||
mul ecx
|
||||
mov ecx, edx
|
||||
mov edx, [esp]
|
||||
add ecx, edx
|
||||
mov edx, [ebp+16]
|
||||
sub edx, [ebp+20]
|
||||
js .no_add
|
||||
imul ecx, edx
|
||||
mul edx
|
||||
add edx, ecx
|
||||
mov ecx, [ebp+ 8]
|
||||
sub ecx, [ebp+12]
|
||||
js .no_add
|
||||
imul edx, ecx
|
||||
mov [esp+4], edx
|
||||
mul ecx
|
||||
mov esi, eax
|
||||
mov eax, [esp+4]
|
||||
add edx, eax
|
||||
add [final_value], esi
|
||||
adc [final_value+4], edx
|
||||
.no_add:
|
||||
add esp,8
|
||||
popad
|
||||
|
||||
.R: ; done, return to place to inverse range
|
||||
ret
|
||||
|
||||
|
||||
|
||||
game_over:
|
||||
mov eax, [final_value]
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, [final_value+4]
|
||||
call print_dec
|
||||
call newline
|
||||
jmp exit
|
||||
|
||||
; ID in EBX, IDX return in EDX
|
||||
id_to_idx:
|
||||
xor edx, edx
|
||||
.test:
|
||||
cmp [rule_idx_to_id+edx*4], ebx
|
||||
je .found
|
||||
inc edx
|
||||
cmp edx, [next_rule_idx]
|
||||
jb .test
|
||||
; new ID
|
||||
mov [rule_idx_to_id+edx*4], ebx
|
||||
inc dword [next_rule_idx]
|
||||
.found:
|
||||
ret
|
||||
|
||||
[section .data]
|
||||
next_rule_idx: dd 1
|
||||
in_idx: dd 0
|
||||
final_value: dd 0, 0
|
||||
file: incbin FILENAME
|
||||
.over:
|
||||
|
||||
[section .bss]
|
||||
rules: resd 1024*4
|
||||
rule_idx_to_id: resd 1024
|
||||
|
||||
[section .rodata]
|
||||
wtf: db "WTF"
|
||||
.over:
|
304
19/main_part1.s
Normal file
304
19/main_part1.s
Normal file
@@ -0,0 +1,304 @@
|
||||
%include "utils.s"
|
||||
|
||||
global _start
|
||||
[bits 32]
|
||||
[section .text]
|
||||
|
||||
%define FILENAME "input"
|
||||
;%define FILENAME "input_test"
|
||||
|
||||
_start:
|
||||
|
||||
mov esi, file
|
||||
load_rule:
|
||||
xor ebx, ebx ; id
|
||||
.get_id:
|
||||
lodsb
|
||||
cmp al, '{'
|
||||
je .got_id
|
||||
shl ebx, 8
|
||||
mov bl, al ; add new byte
|
||||
jmp .get_id
|
||||
.got_id:
|
||||
call id_to_idx ; idx in EDX
|
||||
shl edx, 4 ; *16
|
||||
lea edi, [rules+edx] ; rule ptr
|
||||
.get_rules:
|
||||
; --- rule format ---
|
||||
; [ 16 ]
|
||||
; [ 4 ][ 4 ][ 4 ][ 4 ]
|
||||
; [ 2 ] [ 2 ][ 2 ] [ 2 ][ 2 ] [ 2 ][ 2 ] [ 2 ]
|
||||
; [bound] [ vdr ][bound] [ vdr ][bound] [ vdr ][bound] [ vdr ]
|
||||
|
||||
; var, dir, & res
|
||||
; FEDCBA9876543210
|
||||
; --- var --- 76543210
|
||||
; ...............1 -> Always
|
||||
; .............00. -> a (ASCII .1100...)
|
||||
; .............01. -> m (ASCII .1101...)
|
||||
; .............10. -> s (ASCII .1110...)
|
||||
; .............11. -> x (ASCII .1111...)
|
||||
; --- dir ---
|
||||
; ............0... -> < (ASCII .0....0.)
|
||||
; ............1... -> > (ASCII .0....1.)
|
||||
; --- res ---
|
||||
; 111111111111.... -> R (ASCII .10....0 bit 0 - 1 -> ..111)
|
||||
; 000000000000.... -> A (ASCII .10....1 bit 0 - 1 -> ..000)
|
||||
; NNNNNNNNNNNN.... -> eval
|
||||
|
||||
xor ecx, ecx ; output vdr & bound
|
||||
xor eax, eax ; input byte
|
||||
lodsb ; lowercase alpha or RA
|
||||
bt ax, 5 ; low for RA, high for alpha
|
||||
jc .alpha
|
||||
; immediately finish with R or A
|
||||
or cx, 1 ; Always
|
||||
and ax, 1 ; bit 0 of ASCII
|
||||
dec ax ; R -> -1, A -> 0
|
||||
shl ax, 4 ; correct position
|
||||
or cx, ax
|
||||
jmp .done
|
||||
.alpha: ; either [xmas][><] or a multi-char ID
|
||||
mov ebx, eax ; save last input
|
||||
lodsb ; next byte
|
||||
bt ax, 6 ; bit 6 low for ><
|
||||
jnc .is_check
|
||||
; immediately finish by evaluating ID
|
||||
.imm_got_id_byte:
|
||||
shl ebx, 8
|
||||
mov bl, al
|
||||
.imm_get_full_id:
|
||||
lodsb
|
||||
cmp al, ',' ; ends , or }
|
||||
je .imm_got_id
|
||||
cmp al, '}'
|
||||
jne .imm_got_id_byte
|
||||
.imm_got_id:
|
||||
call id_to_idx ; idx in EDX
|
||||
or cx, 1 ; out.var <- Always
|
||||
shl edx, 4 ; correct position
|
||||
or cx, dx ; out.res <- idx
|
||||
jmp .done
|
||||
.is_check:
|
||||
and bx, 3<<3
|
||||
shr bx, 2
|
||||
or cx, bx ; out.var <- bits 3&4 of last
|
||||
and ax, 1<<1
|
||||
shl ax, 2
|
||||
or cx, ax ; out.dir <- bit 1 of ASCII
|
||||
call dec_parse
|
||||
mov bx, cx
|
||||
mov cx, ax
|
||||
shl ecx, 16
|
||||
mov cx, bx ; out.bound <- parse_dec
|
||||
; parse_dec skips the : so get the res
|
||||
lodsb
|
||||
bt ax, 5
|
||||
jc .chk_id
|
||||
; res is R or A
|
||||
and ax, 1
|
||||
dec ax
|
||||
shl ax, 4
|
||||
or cx, ax ; out.res <- bit 0 of ASCII - 1
|
||||
jmp .done
|
||||
.chk_id: ; res is ID
|
||||
xor ebx, ebx
|
||||
jmp .chk_got_id_byte
|
||||
.chk_next_byte:
|
||||
lodsb
|
||||
cmp al, ',' ; ends ,
|
||||
je .chk_got_id
|
||||
.chk_got_id_byte:
|
||||
shl ebx, 8
|
||||
mov bl, al
|
||||
jmp .chk_next_byte
|
||||
.chk_got_id:
|
||||
call id_to_idx ; idx in EDX
|
||||
shl edx, 4
|
||||
or cx, dx ; out.res <- idx
|
||||
.done:
|
||||
mov eax, ecx
|
||||
stosd
|
||||
cmp byte [esi-1], ','
|
||||
je .get_rules
|
||||
cmp byte [esi], ','
|
||||
je .next_rule
|
||||
cmp byte [esi-1], '}'
|
||||
je .next_line
|
||||
cmp byte [esi], '}'
|
||||
je .next_line
|
||||
cmp byte [esi-1], 10
|
||||
je .check_rules_over
|
||||
call newline
|
||||
.wtf: p_string wtf
|
||||
jmp .wtf
|
||||
.next_rule:
|
||||
inc esi
|
||||
jmp .get_rules
|
||||
.next_line:
|
||||
lodsb
|
||||
cmp al, 10 ; \n
|
||||
jne .next_line
|
||||
.check_rules_over:
|
||||
cmp byte [esi], 10
|
||||
jne load_rule
|
||||
|
||||
rules_over:
|
||||
mov eax, [next_rule_idx]
|
||||
dec eax
|
||||
call print_dec
|
||||
call newline
|
||||
|
||||
; find rule 'in'
|
||||
mov ebx, 'ni'
|
||||
call id_to_idx
|
||||
mov [in_idx], edx
|
||||
mov eax, edx
|
||||
call print_dec
|
||||
call space
|
||||
shl edx, 4
|
||||
movzx eax, word [rules+edx]
|
||||
call print_dec
|
||||
call space
|
||||
movzx eax, word [rules+edx+2]
|
||||
call print_dec
|
||||
call newline
|
||||
|
||||
; we're now reading in the inputs to test
|
||||
; find the next {
|
||||
proc_next_input:
|
||||
mov ecx, 32
|
||||
mov al, '{'
|
||||
xchg edi, esi
|
||||
repne scasb
|
||||
xchg edi, esi
|
||||
cmp esi, file.over
|
||||
jae game_over
|
||||
; get 4 nums, x m a s (ecx edx edi ebp)
|
||||
.get_x:
|
||||
call dec_parse
|
||||
jc .get_x
|
||||
mov ecx, eax
|
||||
.get_m:
|
||||
call dec_parse
|
||||
jc .get_m
|
||||
mov edx, eax
|
||||
.get_a:
|
||||
call dec_parse
|
||||
jc .get_a
|
||||
mov edi, eax
|
||||
.get_s:
|
||||
call dec_parse
|
||||
jc .get_s
|
||||
mov ebp, eax
|
||||
; go through the rules
|
||||
push esi
|
||||
mov ebx, [in_idx]
|
||||
call check_rule
|
||||
add ecx, edx
|
||||
add ecx, edi
|
||||
add ecx, ebp
|
||||
not eax
|
||||
movzx eax, al
|
||||
test eax, eax
|
||||
cmovnz eax, ecx
|
||||
add [final_value], eax
|
||||
pop esi
|
||||
jmp proc_next_input
|
||||
|
||||
|
||||
|
||||
; rule idx in EBX, xmas in ecx edx edi ebp
|
||||
; return in EAX
|
||||
check_rule:
|
||||
sub esp, 4
|
||||
.inner:
|
||||
shl ebx, 4
|
||||
lea esi, [rules+ebx] ; rule ptr
|
||||
mov [esp], esi
|
||||
.next_rule:
|
||||
mov esi, [esp]
|
||||
lodsd ; rule
|
||||
mov [esp], esi
|
||||
bt ax, 0 ; always
|
||||
jc .always
|
||||
; .............00. -> a
|
||||
; .............01. -> m
|
||||
; .............10. -> s
|
||||
; .............11. -> x
|
||||
; ............0... -> <
|
||||
; ............1... -> >
|
||||
mov esi, eax
|
||||
mov ebx, eax
|
||||
and bl, 0b110 ; var
|
||||
cmp bl, 0b000
|
||||
cmove eax, edi
|
||||
cmp bl, 0b010
|
||||
cmove eax, edx
|
||||
cmp bl, 0b100
|
||||
cmove eax, ebp
|
||||
cmp bl, 0b110
|
||||
cmove eax, ecx
|
||||
mov ebx, esi
|
||||
shr ebx, 16 ; rule.bound
|
||||
bt esi, 3 ; rule.dir
|
||||
jnc .less
|
||||
cmp eax, ebx
|
||||
jg .match
|
||||
jmp .next_rule
|
||||
.less:
|
||||
cmp eax, ebx
|
||||
jge .next_rule
|
||||
.match:
|
||||
mov eax, esi
|
||||
.always:
|
||||
shr ax, 4 ; rule.res
|
||||
test ax, ax
|
||||
jz .return_res
|
||||
cmp ax, 0x0FFF
|
||||
je .return_res
|
||||
; nested rule
|
||||
movzx ebx, ax
|
||||
jmp .inner
|
||||
.return_res:
|
||||
movzx eax, ax
|
||||
add esp, 4
|
||||
ret
|
||||
|
||||
|
||||
|
||||
game_over:
|
||||
mov eax, [final_value]
|
||||
call print_dec
|
||||
call newline
|
||||
jmp exit
|
||||
|
||||
; ID in EBX, IDX return in EDX
|
||||
id_to_idx:
|
||||
xor edx, edx
|
||||
.test:
|
||||
cmp [rule_idx_to_id+edx*4], ebx
|
||||
je .found
|
||||
inc edx
|
||||
cmp edx, [next_rule_idx]
|
||||
jb .test
|
||||
; new ID
|
||||
mov [rule_idx_to_id+edx*4], ebx
|
||||
inc dword [next_rule_idx]
|
||||
.found:
|
||||
ret
|
||||
|
||||
[section .data]
|
||||
next_rule_idx: dd 1
|
||||
final_value: dd 0
|
||||
in_idx: dd 0
|
||||
file: incbin FILENAME
|
||||
.over:
|
||||
|
||||
[section .bss]
|
||||
rule_idx_to_id: resd 1024
|
||||
rules: resd 1024*4
|
||||
|
||||
[section .rodata]
|
||||
wtf: db "WTF"
|
||||
.over:
|
285
19/utils.s
Normal file
285
19/utils.s
Normal file
@@ -0,0 +1,285 @@
|
||||
[bits 32]
|
||||
[section .text]
|
||||
; call # val val2
|
||||
; int $0x80 eax eax edx -
|
||||
;
|
||||
; arg1 arg2 arg3 arg4 arg5 arg6 arg7
|
||||
; ebx ecx edx esi edi ebp -
|
||||
|
||||
exit:
|
||||
mov eax, 1 ; exit
|
||||
int 0x80
|
||||
|
||||
; filename in EBX
|
||||
; return handle in EBX
|
||||
; read only
|
||||
open_file:
|
||||
push eax
|
||||
push ecx
|
||||
mov eax, 5 ; open
|
||||
xor ecx, ecx ; read only
|
||||
int 0x80
|
||||
mov ebx, eax
|
||||
pop ecx
|
||||
pop eax
|
||||
ret
|
||||
|
||||
; file handle in EBX
|
||||
; buffer in ECX
|
||||
; count of bytes to read in EDX
|
||||
; return bytes actually read in EAX
|
||||
; exits on error
|
||||
read_file:
|
||||
mov eax, 3 ; read
|
||||
int 0x80
|
||||
test eax, eax
|
||||
js .err
|
||||
ret
|
||||
.err:
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov ecx, .err_str
|
||||
mov edx, 21
|
||||
int 0x80
|
||||
jmp exit
|
||||
.err_str: db `Could not read file.\n`
|
||||
|
||||
; string input in ESI
|
||||
; value in EAX
|
||||
; CF set if none, clear if some
|
||||
; ESI set past checked area
|
||||
dec_parse:
|
||||
push ebx
|
||||
push edx
|
||||
push edi
|
||||
xor eax, eax
|
||||
xor edi, edi
|
||||
mov ebx, 10 ; base
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .no_input
|
||||
cmp al, 9
|
||||
jle .got_char
|
||||
.no_input:
|
||||
stc ; set CF
|
||||
jmp .done
|
||||
.loop:
|
||||
xor eax,eax
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .dec_done
|
||||
cmp al, 9
|
||||
jg .dec_done
|
||||
.got_char:
|
||||
xchg edi,eax
|
||||
mul ebx
|
||||
add edi,eax
|
||||
jmp .loop
|
||||
.dec_done:
|
||||
clc ; clear CF
|
||||
.done:
|
||||
mov eax,edi
|
||||
pop edi
|
||||
pop edx
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; string input in ESI
|
||||
; value in EAX
|
||||
; CF set if none, clear if some
|
||||
; ESI set past checked area
|
||||
sign_dec_parse:
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
push edi
|
||||
xor eax, eax
|
||||
xor edi, edi
|
||||
xor ecx, ecx ; neg flag
|
||||
mov ebx, 10 ; base
|
||||
cmp byte [esi], '-'
|
||||
jne .no_minus
|
||||
inc esi
|
||||
mov cl, 1
|
||||
.no_minus:
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .no_input
|
||||
cmp al, 9
|
||||
jle .got_char
|
||||
.no_input:
|
||||
stc ; set CF
|
||||
jmp .done
|
||||
.loop:
|
||||
xor eax,eax
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .dec_done
|
||||
cmp al, 9
|
||||
jg .dec_done
|
||||
.got_char:
|
||||
xchg edi,eax
|
||||
mul ebx
|
||||
add edi,eax
|
||||
jmp .loop
|
||||
.dec_done:
|
||||
test ecx, ecx
|
||||
jz .not_neg
|
||||
neg edi
|
||||
.not_neg:
|
||||
clc ; clear CF
|
||||
.done:
|
||||
mov eax,edi
|
||||
pop edi
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; modifies no regs
|
||||
newline:
|
||||
pushad
|
||||
push 10
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov ecx, esp ; string
|
||||
mov edx, 1 ; length
|
||||
int 0x80
|
||||
add esp, 4
|
||||
popad
|
||||
ret
|
||||
; modifies no regs
|
||||
space:
|
||||
pushad
|
||||
push 9
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov ecx, esp ; string
|
||||
mov edx, 1 ; length
|
||||
int 0x80
|
||||
add esp, 4
|
||||
popad
|
||||
ret
|
||||
|
||||
; input in EAX, all regs unmodified
|
||||
print_dec:
|
||||
pushad ; save regs
|
||||
; max 4294967296 is 10 chars
|
||||
; round to nearest 32-bit boundary
|
||||
sub esp, 12
|
||||
; string in ECX, length in EDX
|
||||
lea ecx, [esp+11] ; last possible byte
|
||||
; check for 0
|
||||
test eax, eax
|
||||
jz .zero
|
||||
mov ebx, 10 ; base 10
|
||||
xor esi, esi ; counter
|
||||
.div_shit:
|
||||
xor edx, edx
|
||||
; divide
|
||||
div ebx
|
||||
dec ecx ; next char
|
||||
inc esi
|
||||
; store
|
||||
add dl, '0'
|
||||
mov byte [ecx], dl
|
||||
; check if done
|
||||
test eax, eax
|
||||
jnz .div_shit ; continue
|
||||
mov edx, esi ; counter in edx
|
||||
jmp .write
|
||||
.zero:
|
||||
mov byte [ecx], '0'
|
||||
mov edx, 1 ; length
|
||||
.write:
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
int 0x80
|
||||
add esp, 12 ; restore stack
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; input in EAX, all regs unmodified
|
||||
print_sign_dec:
|
||||
pushad ; save regs
|
||||
; range -2147483648 to 2147483647 is 11 chars
|
||||
; round to nearest 32-bit boundary
|
||||
sub esp, 12
|
||||
; string in ECX, length in EDX
|
||||
lea ecx, [esp+11] ; last possible byte
|
||||
; check for 0, negative
|
||||
xor ebp, ebp
|
||||
test eax, eax
|
||||
jz .zero
|
||||
jns .positive
|
||||
neg eax
|
||||
mov ebp, 1
|
||||
.positive:
|
||||
mov ebx, 10 ; base 10
|
||||
xor esi, esi ; counter
|
||||
.div_shit:
|
||||
xor edx, edx
|
||||
; divide
|
||||
div ebx
|
||||
dec ecx ; next char
|
||||
inc esi
|
||||
; store
|
||||
add dl, '0'
|
||||
mov byte [ecx], dl
|
||||
; check if done
|
||||
test eax, eax
|
||||
jnz .div_shit ; continue
|
||||
mov edx, esi ; counter in edx
|
||||
jmp .write
|
||||
.zero:
|
||||
mov byte [ecx], '0'
|
||||
mov edx, 1 ; length
|
||||
.write:
|
||||
test ebp, ebp
|
||||
jz .no_minus
|
||||
dec ecx
|
||||
inc edx
|
||||
mov byte [ecx], '-'
|
||||
.no_minus:
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
int 0x80
|
||||
add esp, 12 ; restore stack
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; input in ESI, len in ECX, all regs unmodified
|
||||
print_string:
|
||||
pushad ; save regs
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov edx, ecx ; length
|
||||
mov ecx, esi ; string
|
||||
int 0x80
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; input in AL, all regs unmodified
|
||||
print_char:
|
||||
pushad ; save regs
|
||||
push eax
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov edx, 1 ; length
|
||||
mov ecx, esp ; string
|
||||
int 0x80
|
||||
add esp, 4
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; --- MACROS ---
|
||||
%define len(x) x %+ .over - x
|
||||
%macro p_string 1
|
||||
push esi
|
||||
push ecx
|
||||
mov esi, %1
|
||||
mov ecx, len(%1)
|
||||
call print_string
|
||||
pop ecx
|
||||
pop esi
|
||||
%endmacro
|
3
20/Makefile
Normal file
3
20/Makefile
Normal file
@@ -0,0 +1,3 @@
|
||||
all:
|
||||
nasm -g -felf32 main.s && ld -melf_i386 -g main.o
|
||||
|
58
20/input
Normal file
58
20/input
Normal file
@@ -0,0 +1,58 @@
|
||||
%cd -> jx, gh
|
||||
%bk -> jp, cn
|
||||
%px -> xc, hg
|
||||
%tv -> gh, xl
|
||||
&xc -> bm, zq, jf, hg, bd, hn
|
||||
%bd -> px
|
||||
&bh -> mf
|
||||
%dx -> cn, rb
|
||||
%vv -> pp, gh
|
||||
broadcaster -> cx, zq, tv, rh
|
||||
%rb -> cn, qr
|
||||
&jf -> mf
|
||||
%jd -> mm
|
||||
%cx -> xd, cn
|
||||
%zs -> cz
|
||||
%hn -> bm
|
||||
%xr -> bd, xc
|
||||
&mf -> rx
|
||||
%zq -> kg, xc
|
||||
&cn -> sh, jd, cx, tc, xd
|
||||
%cs -> xj
|
||||
%fb -> tc, cn
|
||||
%mm -> cn, bk
|
||||
%sq -> th, hz
|
||||
%sz -> vx
|
||||
%xl -> gh, sz
|
||||
%vm -> gh, vv
|
||||
%jp -> cn
|
||||
%qr -> cn, jd
|
||||
%bq -> xc, zv
|
||||
&sh -> mf
|
||||
%gz -> gs, hz
|
||||
%qc -> qg, xc
|
||||
%hg -> bq
|
||||
%dt -> sq, hz
|
||||
%xj -> fz
|
||||
%qs -> gh
|
||||
%fz -> hz, zs
|
||||
%qg -> xc
|
||||
%pp -> qs, gh
|
||||
%zv -> xc, qc
|
||||
%rh -> hz, mr
|
||||
&gh -> tv, lk, sz, bh, vx
|
||||
%th -> hz
|
||||
&mz -> mf
|
||||
%bm -> xr
|
||||
%lk -> pg
|
||||
%jx -> lk, gh
|
||||
&hz -> xj, cs, zs, rh, mz
|
||||
%tc -> dx
|
||||
%mr -> hz, gz
|
||||
%xd -> jk
|
||||
%pg -> vm, gh
|
||||
%kg -> hn, xc
|
||||
%gs -> cs, hz
|
||||
%vx -> cd
|
||||
%cz -> hz, dt
|
||||
%jk -> cn, fb
|
5
20/input_test
Normal file
5
20/input_test
Normal file
@@ -0,0 +1,5 @@
|
||||
broadcaster -> aa, bb, cc
|
||||
%aa -> bb
|
||||
%bb -> cc
|
||||
%cc -> iv
|
||||
&iv -> aa
|
5
20/input_test2
Normal file
5
20/input_test2
Normal file
@@ -0,0 +1,5 @@
|
||||
broadcaster -> aa
|
||||
%aa -> iv, cn
|
||||
&iv -> bb
|
||||
%bb -> cn
|
||||
&cn -> ou
|
278
20/main.s
Normal file
278
20/main.s
Normal file
@@ -0,0 +1,278 @@
|
||||
%include "utils.s"
|
||||
|
||||
global _start
|
||||
[bits 32]
|
||||
[section .text]
|
||||
|
||||
%define FILENAME "input"
|
||||
;%define FILENAME "input_test"
|
||||
;%define FILENAME "input_test2"
|
||||
|
||||
;%define DBG
|
||||
|
||||
_start:
|
||||
|
||||
; read in modules
|
||||
; module data (16 bytes):
|
||||
; 0
|
||||
; bit 1: type (0: flipflop, 1: conj) bit 0: state (0: low, 1: high)
|
||||
; 1 2 3 4 5 6
|
||||
; destination IDX list
|
||||
; 7 8 9 A B C D E F
|
||||
; input states (for conj modules)
|
||||
; bit 0 is remembered state, higher is index
|
||||
|
||||
mov esi, file
|
||||
read_modules:
|
||||
lodsb
|
||||
cmp al, '%'
|
||||
je .flipflop
|
||||
cmp al, '&'
|
||||
je .conjunc
|
||||
; broadcaster
|
||||
%ifdef DBG
|
||||
mov al, 'B'
|
||||
call print_char
|
||||
mov al, 'R'
|
||||
call print_char
|
||||
call space
|
||||
%endif
|
||||
mov ch, 1<<1
|
||||
mov al, 1
|
||||
%ifdef DBG
|
||||
call print_hex_byte
|
||||
call space
|
||||
%endif
|
||||
mov cl, -1 ; broadcaster is special
|
||||
add esi, 14
|
||||
mov edi, modules+16 ; module 1 is broadcast
|
||||
jmp .get_dests
|
||||
.flipflop:
|
||||
mov cl, 0b00 ; low, flipflop
|
||||
jmp .get_idx
|
||||
.conjunc:
|
||||
mov cl, 0b10 ; low, conj
|
||||
jmp .get_idx
|
||||
.get_idx:
|
||||
; get ID
|
||||
lodsb
|
||||
%ifdef DBG
|
||||
call print_char
|
||||
%endif
|
||||
mov bh, al
|
||||
lodsb
|
||||
%ifdef DBG
|
||||
call print_char
|
||||
call space
|
||||
%endif
|
||||
mov bl, al
|
||||
call id_to_idx ; idx in edx
|
||||
mov ch, dl
|
||||
%ifdef DBG
|
||||
mov al, dl
|
||||
call print_hex_byte
|
||||
call space
|
||||
%endif
|
||||
shl ch, 1
|
||||
shl edx, 4 ; * 16
|
||||
lea edi, [modules+edx]
|
||||
add esi, 4
|
||||
.get_dests:
|
||||
; type/state in CL
|
||||
mov [edi], cl
|
||||
inc edi
|
||||
.next_dest:
|
||||
; get dest ID
|
||||
lodsb
|
||||
%ifdef DBG
|
||||
call print_char
|
||||
%endif
|
||||
mov bh, al
|
||||
lodsb
|
||||
%ifdef DBG
|
||||
call print_char
|
||||
call space
|
||||
%endif
|
||||
mov bl, al
|
||||
call id_to_idx
|
||||
cmp bx, 'fm'
|
||||
jne .not_rx
|
||||
mov [mf_idx], dx
|
||||
.not_rx:
|
||||
mov al, dl
|
||||
%ifdef DBG
|
||||
call print_hex_byte
|
||||
call space
|
||||
%endif
|
||||
stosb
|
||||
; store our idx<<1 in dest inputs
|
||||
shl edx, 4 ; * 16
|
||||
lea edx, [modules+edx+7]
|
||||
.store_input:
|
||||
cmp byte [edx], 0
|
||||
jnz .check_next_input
|
||||
mov byte [edx], ch
|
||||
jmp .input_stored
|
||||
.check_next_input:
|
||||
inc edx
|
||||
jmp .store_input
|
||||
.input_stored:
|
||||
; check if more
|
||||
lodsb
|
||||
cmp al, ','
|
||||
jne .cont ; no more
|
||||
inc esi ; space
|
||||
jmp .next_dest
|
||||
.cont:
|
||||
%ifdef DBG
|
||||
call newline
|
||||
%endif
|
||||
cmp esi, file.over
|
||||
jb read_modules
|
||||
|
||||
main:
|
||||
; start an iteration, broadcaster (1) sends low to everything
|
||||
mov dword [queue_head], 0
|
||||
mov dword [queue_tail], 2
|
||||
mov word [queue], 0b10 ; low to index 1
|
||||
call do_iters
|
||||
inc dword [final_value]
|
||||
jmp main
|
||||
|
||||
do_iters:
|
||||
; get head of queue
|
||||
mov eax, [queue_head]
|
||||
mov ax, [eax+queue]
|
||||
%ifdef DBG
|
||||
call print_hex_word
|
||||
call newline
|
||||
%endif
|
||||
mov cl, ah ; sender
|
||||
movzx eax, al
|
||||
shr eax, 1 ; get pulse
|
||||
setc bl
|
||||
jnc .not_high
|
||||
cmp al, [mf_idx]
|
||||
jne .not_high
|
||||
push eax
|
||||
mov al, cl
|
||||
call print_hex_byte
|
||||
call space
|
||||
mov eax, [final_value]
|
||||
call print_dec
|
||||
call newline
|
||||
pop eax
|
||||
.not_high:
|
||||
; get module
|
||||
mov bh, al ; idx
|
||||
shl eax, 4 ; * 16
|
||||
lea edi, [modules+eax]
|
||||
mov al, [edi]
|
||||
cmp al, -1
|
||||
je .broadcast
|
||||
bt ax, 1
|
||||
jc .conj
|
||||
.flipflop:
|
||||
; if high, do nothing
|
||||
test bl, bl
|
||||
jnz .cont
|
||||
; if low, flip and send result
|
||||
xor al, 1
|
||||
bt ax, 0
|
||||
setc bl
|
||||
mov [edi], al
|
||||
jmp add_cmds
|
||||
.conj:
|
||||
mov dl, 1
|
||||
mov esi, 7
|
||||
.check_mem:
|
||||
mov al, [edi+esi]
|
||||
test al, al
|
||||
jz .mem_done
|
||||
shr al, 1
|
||||
setc dh
|
||||
cmp al, cl
|
||||
jne .mem_cont
|
||||
shr bl, 1
|
||||
setc dh
|
||||
rcl al, 1
|
||||
mov [edi+esi], al
|
||||
.mem_cont:
|
||||
and dl, dh
|
||||
inc esi
|
||||
cmp esi, 0xF
|
||||
jbe .check_mem
|
||||
.mem_done:
|
||||
; send high if not all were high
|
||||
xor dl, 1
|
||||
mov bl, dl
|
||||
jmp add_cmds
|
||||
.broadcast:
|
||||
jmp add_cmds ; just add commands with same pulse
|
||||
.cont:
|
||||
mov eax, [queue_head]
|
||||
add eax, 2
|
||||
and eax, 511
|
||||
mov [queue_head], eax
|
||||
cmp eax, [queue_tail]
|
||||
jne do_iters
|
||||
ret
|
||||
; BH: module IDX, BL: pulse, EDI: *module
|
||||
add_cmds:
|
||||
mov dx, bx ; save
|
||||
mov ecx, 1
|
||||
.loop:
|
||||
mov al, [edi+ecx]
|
||||
test al, al
|
||||
jz .done
|
||||
mov bx, dx
|
||||
shl al, 1
|
||||
or bl, al
|
||||
%ifdef DBG
|
||||
call space
|
||||
mov ax, bx
|
||||
call print_hex_word
|
||||
call newline
|
||||
%endif
|
||||
; add to queue
|
||||
mov eax, [queue_tail]
|
||||
mov [eax+queue], bx
|
||||
add eax, 2
|
||||
and eax, 511
|
||||
mov [queue_tail], eax
|
||||
inc ecx
|
||||
cmp ecx, 6
|
||||
jbe .loop
|
||||
.done:
|
||||
jmp do_iters.cont
|
||||
|
||||
; ID in BX, IDX return in EDX
|
||||
id_to_idx:
|
||||
xor edx, edx
|
||||
.test:
|
||||
cmp [module_idx_to_id+edx*2], bx
|
||||
je .found
|
||||
inc dx
|
||||
cmp dx, [next_module_idx]
|
||||
jb .test
|
||||
; new ID
|
||||
mov [module_idx_to_id+edx*2], bx
|
||||
inc word [next_module_idx]
|
||||
.found:
|
||||
ret
|
||||
|
||||
[section .data]
|
||||
final_value: dd 1
|
||||
next_module_idx: dw 2 ; 1 reserved for broadcaster
|
||||
mf_idx: dw 0
|
||||
queue_head: dd queue
|
||||
queue_tail: dd queue
|
||||
file: incbin FILENAME
|
||||
.over: db 0 ; EOF
|
||||
|
||||
[section .bss]
|
||||
modules: resb 64*16
|
||||
module_idx_to_id: resw 64
|
||||
queue: resw 64*8
|
||||
|
||||
[section .rodata]
|
296
20/main_part1.s
Normal file
296
20/main_part1.s
Normal file
@@ -0,0 +1,296 @@
|
||||
%include "utils.s"
|
||||
|
||||
global _start
|
||||
[bits 32]
|
||||
[section .text]
|
||||
|
||||
%define FILENAME "input"
|
||||
;%define FILENAME "input_test"
|
||||
;%define FILENAME "input_test2"
|
||||
|
||||
;%define DBG
|
||||
;%define DBG_ITERS 1000
|
||||
|
||||
_start:
|
||||
|
||||
; read in modules
|
||||
; module data (16 bytes):
|
||||
; 0
|
||||
; bit 1: type (0: flipflop, 1: conj) bit 0: state (0: low, 1: high)
|
||||
; 1 2 3 4 5 6
|
||||
; destination IDX list
|
||||
; 7 8 9 A B C D E F
|
||||
; input states (for conj modules)
|
||||
; bit 0 is remembered state, higher is index
|
||||
|
||||
mov esi, file
|
||||
read_modules:
|
||||
lodsb
|
||||
cmp al, '%'
|
||||
je .flipflop
|
||||
cmp al, '&'
|
||||
je .conjunc
|
||||
; broadcaster
|
||||
%ifdef DBG
|
||||
mov al, 'B'
|
||||
call print_char
|
||||
mov al, 'R'
|
||||
call print_char
|
||||
call space
|
||||
%endif
|
||||
mov ch, 1<<1
|
||||
mov al, 1
|
||||
%ifdef DBG
|
||||
call print_hex_byte
|
||||
call space
|
||||
%endif
|
||||
mov cl, -1 ; broadcaster is special
|
||||
add esi, 14
|
||||
mov edi, modules+16 ; module 1 is broadcast
|
||||
jmp .get_dests
|
||||
.flipflop:
|
||||
mov cl, 0b00 ; low, flipflop
|
||||
jmp .get_idx
|
||||
.conjunc:
|
||||
mov cl, 0b10 ; low, conj
|
||||
jmp .get_idx
|
||||
.get_idx:
|
||||
; get ID
|
||||
lodsb
|
||||
%ifdef DBG
|
||||
call print_char
|
||||
%endif
|
||||
mov bh, al
|
||||
lodsb
|
||||
%ifdef DBG
|
||||
call print_char
|
||||
call space
|
||||
%endif
|
||||
mov bl, al
|
||||
call id_to_idx ; idx in edx
|
||||
mov ch, dl
|
||||
%ifdef DBG
|
||||
mov al, dl
|
||||
call print_hex_byte
|
||||
call space
|
||||
%endif
|
||||
shl ch, 1
|
||||
shl edx, 4 ; * 16
|
||||
lea edi, [modules+edx]
|
||||
add esi, 4
|
||||
.get_dests:
|
||||
; type/state in CL
|
||||
mov [edi], cl
|
||||
inc edi
|
||||
.next_dest:
|
||||
; get dest ID
|
||||
lodsb
|
||||
%ifdef DBG
|
||||
call print_char
|
||||
%endif
|
||||
mov bh, al
|
||||
lodsb
|
||||
%ifdef DBG
|
||||
call print_char
|
||||
call space
|
||||
%endif
|
||||
mov bl, al
|
||||
call id_to_idx
|
||||
mov al, dl
|
||||
%ifdef DBG
|
||||
call print_hex_byte
|
||||
call space
|
||||
%endif
|
||||
stosb
|
||||
; store our idx<<1 in dest inputs
|
||||
shl edx, 4 ; * 16
|
||||
lea edx, [modules+edx+7]
|
||||
.store_input:
|
||||
cmp byte [edx], 0
|
||||
jnz .check_next_input
|
||||
mov byte [edx], ch
|
||||
jmp .input_stored
|
||||
.check_next_input:
|
||||
inc edx
|
||||
jmp .store_input
|
||||
.input_stored:
|
||||
; check if more
|
||||
lodsb
|
||||
cmp al, ','
|
||||
jne .cont ; no more
|
||||
inc esi ; space
|
||||
jmp .next_dest
|
||||
.cont:
|
||||
%ifdef DBG
|
||||
call newline
|
||||
%endif
|
||||
cmp esi, file.over
|
||||
jb read_modules
|
||||
|
||||
main:
|
||||
mov ecx, 1000
|
||||
%ifdef DBG
|
||||
mov ecx, DBG_ITERS
|
||||
%endif
|
||||
.loop:
|
||||
push ecx
|
||||
; start an iteration, broadcaster (1) sends low to everything
|
||||
mov dword [queue_head], 0
|
||||
mov dword [queue_tail], 2
|
||||
mov word [queue], 0b10 ; low to index 1
|
||||
call do_iters
|
||||
pop ecx
|
||||
loop .loop
|
||||
jmp game_over
|
||||
|
||||
do_iters:
|
||||
; get head of queue
|
||||
mov eax, [queue_head]
|
||||
mov ax, [eax+queue]
|
||||
%ifdef DBG
|
||||
call print_hex_word
|
||||
call newline
|
||||
%endif
|
||||
mov cl, ah ; sender
|
||||
movzx eax, al
|
||||
shr eax, 1 ; get pulse
|
||||
setc bl
|
||||
jc .got_high
|
||||
inc dword [low_count]
|
||||
jmp .add_done
|
||||
.got_high:
|
||||
inc dword [high_count]
|
||||
.add_done:
|
||||
; get module
|
||||
mov bh, al ; idx
|
||||
shl eax, 4 ; * 16
|
||||
lea edi, [modules+eax]
|
||||
mov al, [edi]
|
||||
cmp al, -1
|
||||
je .broadcast
|
||||
bt ax, 1
|
||||
jc .conj
|
||||
.flipflop:
|
||||
; if high, do nothing
|
||||
test bl, bl
|
||||
jnz .cont
|
||||
; if low, flip and send result
|
||||
xor al, 1
|
||||
bt ax, 0
|
||||
setc bl
|
||||
mov [edi], al
|
||||
jmp add_cmds
|
||||
.conj:
|
||||
mov dl, 1
|
||||
mov esi, 7
|
||||
.check_mem:
|
||||
mov al, [edi+esi]
|
||||
test al, al
|
||||
jz .mem_done
|
||||
shr al, 1
|
||||
setc dh
|
||||
cmp al, cl
|
||||
jne .mem_cont
|
||||
shr bl, 1
|
||||
setc dh
|
||||
rcl al, 1
|
||||
mov [edi+esi], al
|
||||
.mem_cont:
|
||||
and dl, dh
|
||||
inc esi
|
||||
cmp esi, 0xF
|
||||
jbe .check_mem
|
||||
.mem_done:
|
||||
; send high if not all were high
|
||||
xor dl, 1
|
||||
mov bl, dl
|
||||
jmp add_cmds
|
||||
.broadcast:
|
||||
jmp add_cmds ; just add commands with same pulse
|
||||
.cont:
|
||||
mov eax, [queue_head]
|
||||
add eax, 2
|
||||
and eax, 511
|
||||
mov [queue_head], eax
|
||||
cmp eax, [queue_tail]
|
||||
jne do_iters
|
||||
ret
|
||||
; BH: module IDX, BL: pulse, EDI: *module
|
||||
add_cmds:
|
||||
mov dx, bx ; save
|
||||
mov ecx, 1
|
||||
.loop:
|
||||
mov al, [edi+ecx]
|
||||
test al, al
|
||||
jz .done
|
||||
mov bx, dx
|
||||
shl al, 1
|
||||
or bl, al
|
||||
%ifdef DBG
|
||||
call space
|
||||
mov ax, bx
|
||||
call print_hex_word
|
||||
call newline
|
||||
%endif
|
||||
; add to queue
|
||||
mov eax, [queue_tail]
|
||||
mov [eax+queue], bx
|
||||
add eax, 2
|
||||
and eax, 511
|
||||
mov [queue_tail], eax
|
||||
inc ecx
|
||||
cmp ecx, 6
|
||||
jbe .loop
|
||||
.done:
|
||||
jmp do_iters.cont
|
||||
|
||||
game_over:
|
||||
mov eax, [low_count]
|
||||
call print_dec
|
||||
call space
|
||||
mov eax, [high_count]
|
||||
call print_dec
|
||||
call newline
|
||||
p_string info
|
||||
mul dword [low_count]
|
||||
call print_dec
|
||||
mov al, ':'
|
||||
call print_char
|
||||
mov eax, edx
|
||||
call print_dec
|
||||
call newline
|
||||
jmp exit
|
||||
|
||||
; ID in BX, IDX return in EDX
|
||||
id_to_idx:
|
||||
xor edx, edx
|
||||
.test:
|
||||
cmp [module_idx_to_id+edx*2], bx
|
||||
je .found
|
||||
inc dx
|
||||
cmp dx, [next_module_idx]
|
||||
jb .test
|
||||
; new ID
|
||||
mov [module_idx_to_id+edx*2], bx
|
||||
inc word [next_module_idx]
|
||||
.found:
|
||||
ret
|
||||
|
||||
[section .data]
|
||||
low_count: dd 0
|
||||
high_count: dd 0
|
||||
next_module_idx: dw 2 ; 1 reserved for broadcaster
|
||||
in_idx: dw 0
|
||||
queue_head: dd queue
|
||||
queue_tail: dd queue
|
||||
file: incbin FILENAME
|
||||
.over: db 0 ; EOF
|
||||
|
||||
[section .bss]
|
||||
modules: resb 64*16
|
||||
module_idx_to_id: resw 64
|
||||
queue: resw 64*8
|
||||
|
||||
[section .rodata]
|
||||
info: db `LOW:HIGH\n`
|
||||
.over:
|
336
20/utils.s
Normal file
336
20/utils.s
Normal file
@@ -0,0 +1,336 @@
|
||||
[bits 32]
|
||||
[section .text]
|
||||
; call # val val2
|
||||
; int $0x80 eax eax edx -
|
||||
;
|
||||
; arg1 arg2 arg3 arg4 arg5 arg6 arg7
|
||||
; ebx ecx edx esi edi ebp -
|
||||
|
||||
exit:
|
||||
mov eax, 1 ; exit
|
||||
int 0x80
|
||||
|
||||
; filename in EBX
|
||||
; return handle in EBX
|
||||
; read only
|
||||
open_file:
|
||||
push eax
|
||||
push ecx
|
||||
mov eax, 5 ; open
|
||||
xor ecx, ecx ; read only
|
||||
int 0x80
|
||||
mov ebx, eax
|
||||
pop ecx
|
||||
pop eax
|
||||
ret
|
||||
|
||||
; file handle in EBX
|
||||
; buffer in ECX
|
||||
; count of bytes to read in EDX
|
||||
; return bytes actually read in EAX
|
||||
; exits on error
|
||||
read_file:
|
||||
mov eax, 3 ; read
|
||||
int 0x80
|
||||
test eax, eax
|
||||
js .err
|
||||
ret
|
||||
.err:
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov ecx, .err_str
|
||||
mov edx, 21
|
||||
int 0x80
|
||||
jmp exit
|
||||
.err_str: db `Could not read file.\n`
|
||||
|
||||
; string input in ESI
|
||||
; value in EAX
|
||||
; CF set if none, clear if some
|
||||
; ESI set past checked area
|
||||
dec_parse:
|
||||
push ebx
|
||||
push edx
|
||||
push edi
|
||||
xor eax, eax
|
||||
xor edi, edi
|
||||
mov ebx, 10 ; base
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .no_input
|
||||
cmp al, 9
|
||||
jle .got_char
|
||||
.no_input:
|
||||
stc ; set CF
|
||||
jmp .done
|
||||
.loop:
|
||||
xor eax,eax
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .dec_done
|
||||
cmp al, 9
|
||||
jg .dec_done
|
||||
.got_char:
|
||||
xchg edi,eax
|
||||
mul ebx
|
||||
add edi,eax
|
||||
jmp .loop
|
||||
.dec_done:
|
||||
clc ; clear CF
|
||||
.done:
|
||||
mov eax,edi
|
||||
pop edi
|
||||
pop edx
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; string input in ESI
|
||||
; value in EAX
|
||||
; CF set if none, clear if some
|
||||
; ESI set past checked area
|
||||
sign_dec_parse:
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
push edi
|
||||
xor eax, eax
|
||||
xor edi, edi
|
||||
xor ecx, ecx ; neg flag
|
||||
mov ebx, 10 ; base
|
||||
cmp byte [esi], '-'
|
||||
jne .no_minus
|
||||
inc esi
|
||||
mov cl, 1
|
||||
.no_minus:
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .no_input
|
||||
cmp al, 9
|
||||
jle .got_char
|
||||
.no_input:
|
||||
stc ; set CF
|
||||
jmp .done
|
||||
.loop:
|
||||
xor eax,eax
|
||||
lodsb
|
||||
sub al, '0'
|
||||
js .dec_done
|
||||
cmp al, 9
|
||||
jg .dec_done
|
||||
.got_char:
|
||||
xchg edi,eax
|
||||
mul ebx
|
||||
add edi,eax
|
||||
jmp .loop
|
||||
.dec_done:
|
||||
test ecx, ecx
|
||||
jz .not_neg
|
||||
neg edi
|
||||
.not_neg:
|
||||
clc ; clear CF
|
||||
.done:
|
||||
mov eax,edi
|
||||
pop edi
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; modifies no regs
|
||||
newline:
|
||||
pushad
|
||||
push 10
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov ecx, esp ; string
|
||||
mov edx, 1 ; length
|
||||
int 0x80
|
||||
add esp, 4
|
||||
popad
|
||||
ret
|
||||
; modifies no regs
|
||||
space:
|
||||
pushad
|
||||
push 9
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov ecx, esp ; string
|
||||
mov edx, 1 ; length
|
||||
int 0x80
|
||||
add esp, 4
|
||||
popad
|
||||
ret
|
||||
|
||||
; input in EAX, all regs unmodified
|
||||
print_dec:
|
||||
pushad ; save regs
|
||||
; max 4294967296 is 10 chars
|
||||
; round to nearest 32-bit boundary
|
||||
sub esp, 12
|
||||
; string in ECX, length in EDX
|
||||
lea ecx, [esp+11] ; last possible byte
|
||||
; check for 0
|
||||
test eax, eax
|
||||
jz .zero
|
||||
mov ebx, 10 ; base 10
|
||||
xor esi, esi ; counter
|
||||
.div_shit:
|
||||
xor edx, edx
|
||||
; divide
|
||||
div ebx
|
||||
dec ecx ; next char
|
||||
inc esi
|
||||
; store
|
||||
add dl, '0'
|
||||
mov byte [ecx], dl
|
||||
; check if done
|
||||
test eax, eax
|
||||
jnz .div_shit ; continue
|
||||
mov edx, esi ; counter in edx
|
||||
jmp .write
|
||||
.zero:
|
||||
mov byte [ecx], '0'
|
||||
mov edx, 1 ; length
|
||||
.write:
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
int 0x80
|
||||
add esp, 12 ; restore stack
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; input in EAX, all regs unmodified
|
||||
print_sign_dec:
|
||||
pushad ; save regs
|
||||
; range -2147483648 to 2147483647 is 11 chars
|
||||
; round to nearest 32-bit boundary
|
||||
sub esp, 12
|
||||
; string in ECX, length in EDX
|
||||
lea ecx, [esp+11] ; last possible byte
|
||||
; check for 0, negative
|
||||
xor ebp, ebp
|
||||
test eax, eax
|
||||
jz .zero
|
||||
jns .positive
|
||||
neg eax
|
||||
mov ebp, 1
|
||||
.positive:
|
||||
mov ebx, 10 ; base 10
|
||||
xor esi, esi ; counter
|
||||
.div_shit:
|
||||
xor edx, edx
|
||||
; divide
|
||||
div ebx
|
||||
dec ecx ; next char
|
||||
inc esi
|
||||
; store
|
||||
add dl, '0'
|
||||
mov byte [ecx], dl
|
||||
; check if done
|
||||
test eax, eax
|
||||
jnz .div_shit ; continue
|
||||
mov edx, esi ; counter in edx
|
||||
jmp .write
|
||||
.zero:
|
||||
mov byte [ecx], '0'
|
||||
mov edx, 1 ; length
|
||||
.write:
|
||||
test ebp, ebp
|
||||
jz .no_minus
|
||||
dec ecx
|
||||
inc edx
|
||||
mov byte [ecx], '-'
|
||||
.no_minus:
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
int 0x80
|
||||
add esp, 12 ; restore stack
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; input in EAX, all regs unmodified
|
||||
print_hex:
|
||||
pushad
|
||||
mov ebx, eax
|
||||
shr eax, 16
|
||||
call print_hex_word
|
||||
mov eax, ebx
|
||||
call print_hex_word
|
||||
popad
|
||||
ret
|
||||
|
||||
; input in AX, all regs unmodified
|
||||
print_hex_word:
|
||||
pushad
|
||||
mov bx, ax
|
||||
mov al, ah
|
||||
call print_hex_byte
|
||||
mov ax, bx
|
||||
call print_hex_byte
|
||||
popad
|
||||
ret
|
||||
|
||||
; input in AL, all regs unmodified
|
||||
print_hex_byte:
|
||||
pushad
|
||||
push '0000'
|
||||
mov bl, al
|
||||
shr bl, 4
|
||||
mov dx, '0'
|
||||
mov cx, 'A' - 10
|
||||
cmp bl, 9
|
||||
cmovg dx, cx
|
||||
add bl, dl
|
||||
mov [esp], bl
|
||||
mov bl, al
|
||||
and bl, 0xF
|
||||
mov dx, '0'
|
||||
mov cx, 'A' - 10
|
||||
cmp bl, 9
|
||||
cmovg dx, cx
|
||||
add bl, dl
|
||||
mov [esp+1], bl
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov edx, 2 ; length
|
||||
mov ecx, esp ; string
|
||||
int 0x80
|
||||
add esp, 4
|
||||
popad
|
||||
ret
|
||||
|
||||
; input in ESI, len in ECX, all regs unmodified
|
||||
print_string:
|
||||
pushad ; save regs
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov edx, ecx ; length
|
||||
mov ecx, esi ; string
|
||||
int 0x80
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; input in AL, all regs unmodified
|
||||
print_char:
|
||||
pushad ; save regs
|
||||
push eax
|
||||
mov eax, 4 ; write
|
||||
mov ebx, 1 ; stdout
|
||||
mov edx, 1 ; length
|
||||
mov ecx, esp ; string
|
||||
int 0x80
|
||||
add esp, 4
|
||||
popad ; restore regs
|
||||
ret
|
||||
|
||||
; --- MACROS ---
|
||||
%define len(x) x %+ .over - x
|
||||
%macro p_string 1
|
||||
push esi
|
||||
push ecx
|
||||
mov esi, %1
|
||||
mov ecx, len(%1)
|
||||
call print_string
|
||||
pop ecx
|
||||
pop esi
|
||||
%endmacro
|
Reference in New Issue
Block a user