Compare commits

...

6 Commits

Author SHA1 Message Date
Lucia Ceionia
7a9bd95804 day 20 part 2 im tired 2023-12-23 03:29:03 -06:00
Lucia Ceionia
9f5df0a65c day 20 part 1 2023-12-23 02:56:15 -06:00
Lucia Ceionia
2598b444f8 day 19 part 2 2023-12-20 01:40:44 -06:00
Lucia Ceionia
d59671e54c day 19 part 1 2023-12-19 21:20:26 -06:00
Lucia Ceionia
0785e7ccd0 day 18 part 2 2023-12-18 14:04:47 -06:00
Lucia Ceionia
5db47a3fcc day 18 part 1 2023-12-18 12:51:44 -06:00
20 changed files with 4197 additions and 0 deletions

6
18/Makefile Normal file
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View File

@@ -0,0 +1,3 @@
all:
nasm -g -felf32 main.s && ld -melf_i386 -g main.o

780
19/input Normal file
View 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
View 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
View 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
View 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
View 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
View File

@@ -0,0 +1,3 @@
all:
nasm -g -felf32 main.s && ld -melf_i386 -g main.o

58
20/input Normal file
View 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
View File

@@ -0,0 +1,5 @@
broadcaster -> aa, bb, cc
%aa -> bb
%bb -> cc
%cc -> iv
&iv -> aa

5
20/input_test2 Normal file
View File

@@ -0,0 +1,5 @@
broadcaster -> aa
%aa -> iv, cn
&iv -> bb
%bb -> cn
&cn -> ou

278
20/main.s Normal file
View 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
View 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
View 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