day 10 parts 1&2
This commit is contained in:
parent
fa953385d9
commit
fa4a9b3efd
3
10/Makefile
Normal file
3
10/Makefile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
all:
|
||||||
|
nasm -g -felf32 main.s && ld -melf_i386 -g main.o
|
||||||
|
|
140
10/input
Normal file
140
10/input
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
J.7--J-.LL77FJ-F7FLJ-7.|FFF.F7FL-7F-7.L-FF77.-F-L7.F-L--7FL7..LF|J.7FF7.FLJ.-7-F7F-J77F77.|7.777FJ7FL7F-|.FFJ7|-|7FL-.LL7F77.|J7.|JJ-7-7|-|7
|
||||||
|
J.|.FJ|FJ.-|LJ|L7FJ|.F.7-|J7L-J|L7|..-JF-JL77-|F|JL||.|L|J7L.|F7J-F-77--L|.-JF7F|JJ-|J||F7-77.|||L-FJ7J-|--7.F|7|LF|F--JF-F.LJ|.F|L|.|||7JL|
|
||||||
|
|.|-JJFJL|LJ.FLJ-|-FJL-|L|||.|-F-F7-F7|7|F-|L-FF.|.-7FJ.|7F.F-|-7--JL..FLF-J|LLLJJ..J.LL.|L.-.L--J|L||JF|J||F-|L|LL|JJ.L7J.77L|-L|7--L7|||.|
|
||||||
|
F-J..FL--F--L7LJ7L||.|.|FFL|-F-FJ.LFJ77FJJ.L7.-J|-7L-J.F|||-FLF--.L-J7F7F-7||-|J||.FL|.F--.FLJLL-L7.LL-FJ.FLJ.|-7-7..LF-J|-J7.|FJJ|7.7.LL7.|
|
||||||
|
||F77F7--|LJ|F|F7-J7F-F-.|JF.|-7LJF77|J||.|-JFL-F-|.L..FJFJ7J.|F|.L7.FLJ7L|---J-F7|77|FJ7F-FF|L|LF-LJ7--J.L.L7JF-7L|-FL7LF7L7.F-|-F--L-|7F.7
|
||||||
|
|---J7.|LJJFF-LJLF|--7|.LLFLF-7J.LLJLL-7.--7J-JF|7|-7L---J--.FFFF7L|-LJ.--77LF.|FL7--J-JL|.||--L7J7|LL7|.777.|.LJ|.|LF7F-JL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||FJLJLJF-7||FJ||F7FL..L7|
|
||||||
|
LJ.LJJ-7FFJF7F--J|F7||.F7||L-7LJ|LJ||||||F7||||FJL7||F-7||FJ|F-J||||L7||||||||F-J|||FJ|F--J||||L7|L7FJ||L-JL-JL---JLJF7F-7|LLJLJ|FF7.F-J-L|7
|
||||||
|
|L-7FF7.7LFJ|L---J|LJ|FJLJ|F7L-7|F7||||||||||||L77||||FJ|LJ|||F-J|||FJ|||||||||F-J||L7|L7F-J|||.LJFJ|FJ|-F7F---------JLJJLJF7F7FFFJ|F77JF|LF
|
||||||
|
77-L-L77FFL7|F7F-7|F-JL7F7LJL7FJLJLJLJ||LJ|||||FJFJ|||L7L-7FJ|L7FJ|||FJ||LJ|||||F7||FJ|FJ|F7|||F--JFJ|FJFJLJF-7F7F---------JLJL7FL7LJL7L-J||
|
||||||
|
|L-7FF7-F-7||||L7LJL7F-J||F-7LJF-----7|L7FJ|LJ|L7L7|||FJF7|L7L7||FJ|||FJL7LLJLJLJLJ||FJL7LJ||LJ|F-7L7||FL---JFJ|LJF--7F7F------JF7|F--J.L|7|
|
||||||
|
7J7FFJ|FL7LJLJL7|F--JL-7|||FJF-JJF---J|FJL7L-7|FJ-LJLJ|FJLJFJFJ||L7||||F7L-------77|||F7||FJL7FJ|FJFJ||F----7L-JF7|F7LJLJF------JLJL--77FLF7
|
||||||
|
|L--L7L7|L----7|LJF7F7FJ|LJ|FJ|F-JF--7|L7LL7FJLJF7F---JL--7|FJ-LJFJ|||LJL7F-7F--7L7||LJ|L7L7FJL7|L7L7LJL---7|F7FJLJ||F---JF7F--7F7F7F7|.F-77
|
||||||
|
L7J|FL7L-7F7F7|L7FJ|||L-JF7LJF-JF7|F-JL-JF-JL-7FJLJF-7F7F-J|L-7F7L7||L-7L||FJL-7L7||L7FJFJ-LJF7||FL-JF----7||||L---JLJF-7FJ|L-7LJLJ||LJ7JLLJ
|
||||||
|
.|FF--JF-J|LJLJFJL7||L7F-JL7FJF-JLJL7F7F7L---7|L--7L7|||L-7L7FJ|L-J|L7FJFJ|L-7FJFJ|L-J|FJ.F--JLJL-7F7L---7LJLJL----7F-JFJ|.L-7L--7L||.FJ7LJ.
|
||||||
|
FLFL7F7L7FJF7F7L--JLJFJL-7FJL-J.F7F-J|||L--7FJL-7FJFJ||L7FJ.||FL7F7||||FJFJF-J|7L7L--7LJF7L--7F7F-J||F7F7L7F7F----7|L-7L7L-7J|F-7|-|L7-LJ-JF
|
||||||
|
7JL.||L7LJFJLJL-7F--7||F-J|F7F--J|L--JLJF7FJL7F-JL7L7||J||F-JL7FJ||L7||L7L7L-7L7FJF7FJ.FJL---J||L-7|||LJ|FJ|||F---J|F-JF|F7L7LJ7|L7L-JF7-|.|
|
||||||
|
77LF||F|F7|F-7F-J|-FJL7|F7|||L--7L---7F-J||.|LJJF7|FJ|L7LJL7F7|L7|L-JLJ|L7L-7|FJL7||L7FJF----7|L--J||L-7||FJLJL7F7JLJFF-J|L7L--7|FJJ|-F--J7J
|
||||||
|
|7JLLJ-||||L7|L-7|FJF7|LJ|LJL---JF-7FLJF7|L7F---JLJL7L7L--7||||FJL-7F----JF7||L7FJ|L7|L7L7F--J|7F7|||LFJ|||F---J||F7F7L-7L7|F7FJ||J7|-|L|L|7
|
||||||
|
.--FFLFLJLJFJL--J|L-J|L--JF--7F7FJJL---J||FJL7F--7F7L7L7F7|||||L7F-JL-7F7FJ||L7|L7|FJ||L7|L--7|FJL7|L7L7|LJL-7F7|LJLJL-7|FJ||LJ-||.F77|-LJL|
|
||||||
|
7J--|.LL-F7L--7F-JF--JF---JF7LJLJF|F7F7FJLJF7||F-J|L7||LJLJLJ|L7||F---J||L7||FJL7||L7|F-J||F-J|L-7|L7L-JL----J|LJF-----JLJ.LJJ|-LJFJL--7.--J
|
||||||
|
L--7..FLFJL-7-LJF7L---JF---JL-7F-7FJLJLJF7J||||L-7|7|L---7F-7|FJLJ|F7F7||FJ||L7FJ|L7||L-7|FJF7|F-JL-JF------7FJF7L-7F--7F---7FFF-7|F---J7-FJ
|
||||||
|
-|F7-L77L--7L7|FJL-----JF7F-7FJL7|L-----JL-J|LJF7|L7|F7F7LJFJ|L--7LJ|||||L7|L7||FJFJ||F-J|L-J||L-7F-7L7F----J|FJL7FJ|F-J|F--J7JL7LJL-7LLJ-L-
|
||||||
|
|FLJ.L-7L|.L7L-JF--7F-7FJLJFJL--JL----------JF7|LJFJ|||||F7L7|F7FJF-J||||FJL-JLJL7L7LJL7FJF-7LJF-JL7L-JL-----JL-7||7|L--JL7F7-F7L-7F-J.L7.FJ
|
||||||
|
7|L|7J...F7FL7F7L7LLJJ||F--JF7F7F7F---------7|||F7L7||LJ||L-JLJLJJL-7|LJ|L---7L|F|FJF7.LJJL7|F-JF7FJF7F7F---7F--JLJFJF7F7FJ|L7|L7FJL-7..LJ7|
|
||||||
|
.|-LL.|-FF---J|L7L7F7FJ|L---J||LJ||F-------7|||LJL7||L-7|L--------7FJL-7|F-7FJF--J||||F7F7-||L-7|LJFJLJ|L--7LJF7F7-|FJLJLJ.L7LJFJL7F-J7.|-|7
|
||||||
|
J|-FJF|-LL7F--JJL7|||L7L7F---J|F-J|L--7FF7FLJ|L7F-J|L-7|L7F7F7F7F-JL7F7||L7LJLL--7|FJLJ|||FJL--JL7FL7F7L---JF-J||L7|L------7L7FJF7||FLF--7L-
|
||||||
|
|--JFLF-|J||F---7LJ||J|FJ|F-7FJL--JF-7L-JL7F-JFJL-7L-7|L7LJLJ|||L-7FJ|LJL7|-|JJFFJ|L--7||LJF-----JF7LJL7F---JF7LJFJ|F---7F7L-JL-JLJL7-|F-JLJ
|
||||||
|
77FLF-F-7J||L7F7L--JL-J|FJ|FJ|F----J7L----JL-7L--7|F7|L7L7F7-LJ|F-JL7L7JJ|L-7-F-L-JF--JLJF7|F---7FJL---J|F-7FJ|F7L-JL--7|||F-7F7F7F7L-JL--7|
|
||||||
|
F-F-J.|7F-LJ7LJL-----7FJ|FJL7|L-------------7|F--JLJ|L7|FJ||F77LJ-LLL-J|L|F-JF7|F7.L-----J||L-7FJ|F7F---JL7LJ||||F-7F--JLJLJ.|||||||F7F---J7
|
||||||
|
|||J|FLLJ7L||.F7F--7|LJFJL77LJFF--7F7F7F----J|L----7L-J||FJ|||F7F7JFLJFL.LJ-FJL7|L--7F7-F7LJF-JL-J|||F----JF-7||||FJL-7F7F7F7LJLJ||LJ|L-7|J|
|
||||||
|
F|..FJ.L-F7F7FJLJF7L---JF-JF---JF7LJ||LJF7-F7|F----J|F7LJL7LJLJLJ|-LJ.-.LJLFL-7|L--7LJL-JL--JF7F-7|LJL-----JFJLJLJL7F-J|LJ|||F--7|L7|L-7L77.
|
||||||
|
LL777|7-FJLJ|L-7FJL-7F7FJF-JF---JL-7|L--JL-JLJL------JL7F7|F----7|JLF-F77LFF--JL---JF7F7F7F7FJ|L7||F--------JF7F7-FJL--JF-J||L7FJL7L--7|FJ|7
|
||||||
|
L||L77|-L--7|F7LJF7JLJLJ-L--JF--7|FJL7F-7F7F7F---7F-7F7LJ||L---7LJ-JL7-LFFJL--7F-7F7|||LJLJLJFJFJ|||F7F------JLJL7L-----JF7|L-JL-7|F--J||JL7
|
||||||
|
.L7FL-JFF--JLJ|F7||F-7FF7F7F-JF7L7L-7LJJ||LJ|L--7LJFJ||F7LJF---J-|.7J|7||.FJFFJ||LJLJLJF-----JFJ|LJLJLJF--7F7F7F7L7-F----JLJF7F7FJLJ-F7LJ|.L
|
||||||
|
F-LF.FFFJF---7LJLJ|L7L-JLJ|L--JL7L--JF-7|L-7|F-7L-7L-J||L7FJ|7.JL|F|.7---7.LLL-JF-----7|F--7F7|.F7F---7L-7LJLJLJL7L-JF---7F-J|||L----JL7-|7J
|
||||||
|
.LL|7J7L-J-F7L7F-7L7L7F--7|F7FF7L--7F|FJ|F7|||FJF7L--7LJF|L-7-J7LLL.-|.JJJ7-|F--JF-7F7LJL-7LJLJFJ|L--7|F7L----7F7L--7L-7FJL7|||L7F-----JFJJ7
|
||||||
|
--F-|.FL7F-J|.LJ7L7|7LJLFJLJ|FJL--7L7|L7LJLJLJL7|L--7L7F-JF-J.|L7||J|LFJ||J|FL--7|.LJL----JF--7L7L---JLJL-----J|L--7|F7||F7L7LJJ|L----7----L
|
||||||
|
|F-JL-JJFJF-JF--7|||F7F7L--7|L-7F7L-J|FJF7-F7.FJL--7L-J|F7L---7J||J|||L-7FF-L7FLLJF7F-----7L7FJFL--------7F-7F-JF--JLJLJ|||FJF7F|F-7F-J7|.L|
|
||||||
|
||-J|LJ.L7L7L|F-JFJLJ|||F7FJL--J|L-7.|L-JL-JL7L--7FJ|F7LJ|F---J7|JJ-LL7-L7L-7F|-LFJLJF---7L-J|F7F7F------J|FJ|F-JF7F---7|||L7|L7|L7LJJ--7.F|
|
||||||
|
|7.F|7F7FL7|FJ|F7L-7FJ||||L7F7F-JF7L-JF7F----JF-7LJFFJL-7|L7F7J7F7.F7-|FL-7L7JLF|L---J|F7L7F7LJ|||L7F7F7F7|||||F7|||F--JLJL7LJFJ|FJJL||.F|FJ
|
||||||
|
L.77LJ-F--JLJFJ|L--JL7|LJL-J|||F-J|F7FJ|L----7|FJF7FJF7FJL7LJ|FFJLF-|--||LL--7-7-FF----JL-J|L-7LJ|FJ|||||LJL-JLJLJLJL-----7|F7|7|||LLFF7-FL.
|
||||||
|
J7|.FL.L--7F7L-JF-7F7LJF-7F7|LJL-7LJLJLL7F7F7LJ|FJ||FJLJF7L--JF7-|.|LF.|-F7FLL7JLFJF--7F---JF7L-7|L-JLJLJF---7F7F--7F7F7F-JLJLJFJ|7-.|L-J||J
|
||||||
|
||LFJLFLLFJ||F--JFJ||F7L7||||F---JF7F7F7LJLJL--J|FJ||F|FJL-7F7FF-7-L-7|7LLJJ-7F-FL-JF7LJF7F7|L--JL7LF77F7L--7|||L-7LJLJLJF7F--7L-J|||77|.-JJ
|
||||||
|
FJFL7.|.||FJ||F--JFJLJ|FJLJLJL----JLJ||L---7F7|FJ|FJL7FJF--J|L7|FJJLLJLFJL.|FL|JLLF7||F-J|||L--7F7L7|L-JL-7FJLJ|F-JF-----JLJF-JFJJ|JJLJJ-|LF
|
||||||
|
F-7JLFF7FJ|FJ||F--JF--J|F--------7F--J|F---J|L7|FJ|F-J|FJF7FJFJ||JF7.LF-7J-J-JLF--JLJLJF7LJL---J||FJL-7F-7LJF-7||F7L7F------JF77-F--7-|J7F-|
|
||||||
|
L-J|.L|LJFJ|FJLJLF7L7F-JL----7F-7|L---JL----JFJ|L7|L-7||FJ||FJFJL7J||.F|JF77F7L|F---7F-J|F------J||F7FLJ-L--JFJLJ|L-JL------7||F-7LFL7L--J-J
|
||||||
|
.L-JFLL-7L7LJL|F-JL-J|F----7-LJFJL--7F-------JFJFJ|F-J|||FJ|L-JF7|FLFF77.|L-7.F||.|.LJ7FJ|F------JLJ|F7F7F---JF--JF-7F7F----J|LJFJFJL-JJ|JFJ
|
||||||
|
||.|L-J-L7|.F7FJF7F--JL---7L7F7L---7LJF--7F7F7L7L-JL--JLJL-JF--JLJ7FL||L|J|LL-LLJ-L7F--JFJL-7F--7F-7LJLJ|L---7|F--JFLJLJF7JF7|F7|L7.F|FL|.||
|
||||||
|
.LL7JJL-LLJFJLJFJ||F7.F7F-JFJ|L----JF-JF7LJLJL-JF-7F----7F-7|F---7JJL|L7|-J7|JF||.LFL---JF-7LJF-J|FL---7L-7F7||L7F--77F7|L-JLJ|LJ|L-7FJFJ777
|
||||||
|
J..|7L7.LLFJF-7|FJ||L7|LJF7L7L---7F7L7FJ|F-7F7F7|FJL7F-7|L7|LJF7FJ|.F|FJJ||L7-L7-F7F7F7F7|FJF-JF7|F----JF7LJ|LJFJ|F-JFJLJF-7F7|F77.LLLJL-LLJ
|
||||||
|
F-LLL-LF7L|FJJLJL7|L7LJF7|L7L----J|L-JL7|||LJLJ|||F-J|FJL-JL7FJLJF7-FJ|L||-FJL.|J|||||||LJ|FJF7||||F7F7FJL-7L--JFJL--JF7FJ-LJLJ||77FJ||7|.LF
|
||||||
|
FJ-LLF--|JLJF-7F7LJF|F7||L7L7F----JF7F-J|L----7|||L--JL---7FJL--7|L7L7|L7|LJ|LFF7|LJLJ|L-7LJFJLJLJLJ||||F--JF--7|F---7|||F-----JL7.L7L--.F.-
|
||||||
|
L7FFLJJL|7L|L7||L---J||||FJLLJF----JLJF7L--7F7|||L7F-7F7F-JL--7FJL7|FJ|-JF-F7.FJ||F7F7|F7L--JF------J|LJL---JF-J|L--7LJLJ|F-7F-7FJJL-|J.F-.|
|
||||||
|
L777J|J.L||F7||L-----JLJLJ|F-7L-------JL--7LJLJLJ-|L7||LJ-F7F7||F-JLJFJLF7|LF-JFJLJLJ|LJ|.F7FL--7F---JF7-F7F7|F-JF--JF7.FJL7|L7LJJ-F7L7FJJF7
|
||||||
|
F||||.F7F|-||||F7FF--7F7JF7L7L---------7F7|F7F7F-7|FJ|L7F7||||LJL---7L7FJL7LL-7|F7|F7|F7L-JL7F7-LJF-7FJL-JLJ|LJF7L---JL-JF7|L-JJF7-LF7L|JJJJ
|
||||||
|
|FJ--7LJ||.|LJLJL-JF7LJL7|L7L---------7|||LJLJLJFJ|L7L7LJ||||L7JF--7L7LJF-JF77||||FJ|LJL7F7FJ|L-7.L7|L-----7L7FJL7F----7FJLJLF7F|JFLLJLF7L7|
|
||||||
|
.L|J|FFJ|JFL-7F7F--JL--7||FJF---------JLJL--7F--J-L-JFJF7LJLJFJFJF-JF|F-JF-J|FJ||||FJJF7LJ|L7|F7L--JL------JJ|L-7|L---7|L-7F-JL----7FJ-LJ7|7
|
||||||
|
F.L77-F--7JF-J||L7F----JLJL7L--7F----7F7JF-7|L------7L7||F7F-J.|FJF|FJL7||F-JL7||||L7FJL7FJFJLJL----7F-7F---7L--JL----JL--J|F------J7J||L-.F
|
||||||
|
L|.||JL|LF.L-7|L-JL-------7|LF7LJF---J||FJFJL7F----7L7LJ|||||F-J|F7FJF7L-JL77FJLJ||FJL-7|L7L7F7F7F7LLJFLJF--J|F7F---7LF7.F-JL-7F--7L-JL7J|-|
|
||||||
|
FJJ----J7LF7JLJF7F-------7||FJL7FL----JLJFJF-JL---7L-JF7LJLJFJF-J|||FJL7F-7L7L-7FJ||F7FJL-JFJ||||||F--7F-JF7F7|||F--JFJL-JF---J|F-J7JF--7L7|
|
||||||
|
7|.LJLF.F7JLF7|||L---7F-7LJLJF7L--7F7F---JLL-7F---JF7FJL7FF7L7|F7||LJF-J|LL-JF7||FJLJ|L-7F7L7||||||L-7|L-7|LJLJLJL---JF7F7L7F-7|L-7F--7FJ.|J
|
||||||
|
L7.FL-J-|-7-|L-JL7F7.LJFJF-7FJL--7||LJF---7F7||F7F7||L-7L7|L-JSJ||L-7L-7|F7F-J|||L7F-JF7LJL7LJLJLJL7FJL--J|F-7F7F7F---JLJL-J|FJ|F-J|F-J7.F|J
|
||||||
|
|L-7-|7L|L.LL-7F7LJL--7|FJFJ|F7F7||L7FJF--J||LJ|LJ|||F7L7||F7F7FJL-7|7FJLJ|L-7||L7||-FJ|F7|L--7F--7LJF----JL7|||||L-----7F--J|FJL--JL7-7JJJ7
|
||||||
|
LF-7-7-77J-7JLLJL----7LJL7L-J|||LJL-J|FJF--J|F-JF-J|LJL7|LJ|||LJF--JL7L-7FJ|FJ|L7LJL7L7||L7F--JL7|L--JF7JF-7||||||F7F---JL7F-J|F-7F--J7J|.L|
|
||||||
|
|L7J-J.|-7-JF|LF7F7F7L---JF--JLJF----JL-JF--JL-7|F7L--7|L7FJLJF7L---7L7FJ|F7L7L7L7F7L7||L7|L-7F7L7-F--JL-J7LJLJLJLJ|L-7F7FJL--JL7LJ|F-77.FF|
|
||||||
|
JJ.|.FFL-|.FJLFJLJLJ|F-7F7L-----JF------7L7F7F7|LJL7JFJ|FJL7F7||F7F-JFJL7|||FJFJ7LJ|FJ|L7||F7||L-JFJF----7F------7FJF7LJLJF-7F-7L--7L7L7F7-.
|
||||||
|
LFF-777|FL-J7.L---7FJL7||L-------JF----7L7LJLJ|L-7FJFJFJ|F-J|||LJ|L-7|F7|||||FJF7F7|L7|FJ|||||L7F-JFJF---JL7F----JL7|L7F7FJL|L7|F7FJFJFJ|||7
|
||||||
|
F|L-J.LL|.FLFF7F--J|F7||L---------JF7F7L7|F---JF7|L-JFJFJL--J||F7L7FJLJLJ||LJL-J||||FJ||FJ|||L-J|F-J||F----JL-7-F77LJFLJ|L-7|FJ|||L-JFJFJL77
|
||||||
|
F-J|.F7.L---FJ|L--7|||||F--7JF-----J||L-JLJF-7J||L7F-J7L7F---JLJL7|L-7F7FJL-7F--J|||L7||L7||L7F-J|F-7LJF--7F7FJFJL-7F7F7L7FJ|L7||L7F7L-JF7L7
|
||||||
|
|L7JF|-77L7FL7|F--JLJLJ|L-7L7|F7F--7LJF7F7-L7L-JL-JL-7F7||FF-7-F7||F7LJ|L-77|L7F7|LJFJ||FJ||FJL--JL7L--JF7LJ|L7|F-7|||||7LJ.L7|||F|||F7FJL7|
|
||||||
|
-JF7LJJJF.F77||L------7|F7|FJLJ||F7L7FJLJL-7|F7F--7F7||||L7L7L7|LJLJ|F7L-7|FJFJ||L-7L7|||FJ|L-7F-7FJF---JL-7L7LJL7|LJLJL----7|||L7LJLJ|L7-LJ
|
||||||
|
.L7L77J.F-JL-JL-------JLJLJL7F7LJ|L-JL7F---JLJ||F7LJLJ|||FJJL7|L--7FJ||F7||L7L-JL7.L7LJ|||FJF-J|FJL-JF-----JFL---J|F--7F7F--J||L7|J|7LL7|-J|
|
||||||
|
L.L7--JLL-------7F----7F7F-7LJL-7L---7||LF-77FJLJ|F7F7||||JF7||F7FJ|FJ||LJL-JF---JF7L-7||||FJJFJL7-F7L---7LF7F7F7.|L-7|||L--7|L7LJF7J-FJ|JFJ
|
||||||
|
.F7L-|7JFLF-----J||F7LLJLJ-L-7F-JF---J|L7L7L7L7F-J|||||||L-JLJ|||L7|L7|L--7F-JF7F7||JFJLJ|||F-JF-JFJ|F7F7L-JLJLJL7L--JLJL-7FJL-J7.LL-FL-JF||
|
||||||
|
7LJ|F7J||-|F----7|FJL---7F7F7||F7L-7F7|FJFJFJF||F7||||||L--7F-J|L7|L7||F-7|L-7|||||L7L7F-J||L-7|F7|FJ|||L--7F7F--J.F7FF--7|L7-F--7.|.||J.F7|
|
||||||
|
77.FF7LF--J|F---J|L7F7F7LJLJLJLJL--J||||-|FJF7||||||||||F7J||F7L7||FJ|||FJL7FJ||||L7|L||F7||F7||||||7||L-7|LJ|L--7FJL-JF-JL-JFJF-J7.F--7.7--
|
||||||
|
F-F7||-L---JL7F-7||LJLJL-7F-7F-7F7F7||||FJ|FJ||||||||||||L7||||FJ||L7||||F7|L7||||FJL7|||||||||LJ||L7||F7L--7|F-7LJF--7L-7F-7L7|F7-FLJLJ7|-J
|
||||||
|
L-JL|J7LF---7|||LJF7F----JL7||FJ|LJ||||LJFJL7||||||||LJLJFJ|||||FJ|FJ|LJLJ|L7||LJ|L-7||||||LJ|L7FJL7LJ|||F7FJ|L7|F7L-7|F-JL7|FJLJ|-J-F7.|7-|
|
||||||
|
F|-LJ.L-L--7|LJF--J|L---7F7|||L-J-FJ||L-7|F-JLJ|||||L--7FJFJ|||||FJL7|F7F-JFJ|L7J|F-JLJLJ||F-JFJL7FJF7||LJ|L7|FJLJL--JLJF7FJLJF--JJ.F7-7LL-7
|
||||||
|
FL.L7.|.F--J|F7L--7|F---J|||LJ|F7FJFJ|F-J|L7F--J||||F7FJL7|FJ|||||-FJLJ|L-7|FL-JFJL---7F-J|L-7L-7|L-J||L-7|FJ|L----7F-77||L7F-JF7|.F7JL.77F|
|
||||||
|
77FJ|F--JF-7LJL---JLJF7F7|||F--JLJFJF|L-7|FJ|F7FJ||||LJF7LJL7|LJ|L7|F7FJF-JL--7L|F-7F7|L-7L7FJF7|L7F7||F7|||FJF----JL7|FJL-JL--JL7-F7.FJL7-7
|
||||||
|
|FF-LL7F7|.L-7F7F---7|LJLJ||L----7|7FJF7||L7||||FJ||L-7|||F-J|F-JFJ||||FJF7F7FJFJL7||||F-JFJ|FJ|L7||||||LJ||L7L------JLJF-7F7F---JF|L-J-7J7|
|
||||||
|
FJ||.L||LJF--J|||F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FJLJ.L|JLJ7-F-FJ-7-J.-J-LJ7JL7-J.J7JJ|J|L-|.7-|
|
231
10/main.s
Normal file
231
10/main.s
Normal file
@ -0,0 +1,231 @@
|
|||||||
|
global _start
|
||||||
|
[bits 32]
|
||||||
|
[section .text]
|
||||||
|
|
||||||
|
%include "utils.s"
|
||||||
|
|
||||||
|
_start:
|
||||||
|
|
||||||
|
; find line length
|
||||||
|
mov edi, file
|
||||||
|
mov ecx, file.over - file
|
||||||
|
mov al, 10 ; \n
|
||||||
|
repne scasb
|
||||||
|
mov eax, edi
|
||||||
|
sub eax, file
|
||||||
|
mov [line_len], eax
|
||||||
|
|
||||||
|
call print_dec
|
||||||
|
call newline
|
||||||
|
|
||||||
|
; find S
|
||||||
|
mov edi, file
|
||||||
|
mov ecx, file.over - file
|
||||||
|
mov al, 'S' ; \n
|
||||||
|
repne scasb
|
||||||
|
mov eax, edi
|
||||||
|
sub eax, file
|
||||||
|
dec eax
|
||||||
|
mov [s_idx], eax
|
||||||
|
mov ebx, [line_len]
|
||||||
|
div ebx
|
||||||
|
mov [s_line], eax
|
||||||
|
call print_dec
|
||||||
|
call space
|
||||||
|
mov [s_col], edx
|
||||||
|
mov eax, edx
|
||||||
|
call print_dec
|
||||||
|
call newline
|
||||||
|
|
||||||
|
mov ecx, (1024*64)/141
|
||||||
|
mov edi, new_f
|
||||||
|
fill_new_f:
|
||||||
|
push ecx
|
||||||
|
mov al, '.'
|
||||||
|
mov ecx, 140
|
||||||
|
rep stosb
|
||||||
|
mov al, 10
|
||||||
|
stosb
|
||||||
|
pop ecx
|
||||||
|
loop fill_new_f
|
||||||
|
|
||||||
|
; walk the loop
|
||||||
|
mov esi, file
|
||||||
|
add esi, [s_idx]
|
||||||
|
mov edx, esi ; last loc
|
||||||
|
mov ebx, [line_len]
|
||||||
|
; downs
|
||||||
|
lea edi, [esi+ebx]
|
||||||
|
cmp byte [edi], '|'
|
||||||
|
je walking_loop
|
||||||
|
cmp byte [edi], 'J'
|
||||||
|
je walking_loop
|
||||||
|
cmp byte [edi], 'L'
|
||||||
|
je walking_loop
|
||||||
|
; ups
|
||||||
|
neg ebx
|
||||||
|
lea edi, [esi+ebx]
|
||||||
|
cmp byte [edi], '|'
|
||||||
|
je walking_loop
|
||||||
|
cmp byte [edi], 'F'
|
||||||
|
je walking_loop
|
||||||
|
cmp byte [edi], '7'
|
||||||
|
je walking_loop
|
||||||
|
; lefts
|
||||||
|
lea edi, [esi-1]
|
||||||
|
cmp byte [edi], '-'
|
||||||
|
je walking_loop
|
||||||
|
cmp byte [edi], 'L'
|
||||||
|
je walking_loop
|
||||||
|
cmp byte [edi], 'F'
|
||||||
|
je walking_loop
|
||||||
|
; rights
|
||||||
|
lea edi, [esi+1]
|
||||||
|
cmp byte [edi], '-'
|
||||||
|
je walking_loop
|
||||||
|
cmp byte [edi], 'J'
|
||||||
|
je walking_loop
|
||||||
|
cmp byte [edi], '7'
|
||||||
|
je walking_loop
|
||||||
|
jmp fucked_up
|
||||||
|
|
||||||
|
; | - 7 J L F
|
||||||
|
walking_loop:
|
||||||
|
pushad
|
||||||
|
xor edx, edx
|
||||||
|
mov eax, edi
|
||||||
|
sub eax, file
|
||||||
|
mov ebx, [line_len]
|
||||||
|
div ebx
|
||||||
|
call print_dec
|
||||||
|
call space
|
||||||
|
mov eax, edx
|
||||||
|
call print_dec
|
||||||
|
call newline
|
||||||
|
popad
|
||||||
|
inc dword [final_value]
|
||||||
|
mov ebx, edi
|
||||||
|
sub ebx, file
|
||||||
|
mov al, [edi]
|
||||||
|
mov [ebx+new_f], al
|
||||||
|
cmp byte [edi], 'S'
|
||||||
|
je done_walking
|
||||||
|
c_pipe:
|
||||||
|
cmp byte [edi], '|'
|
||||||
|
jne c_hyphen
|
||||||
|
mov eax, edi
|
||||||
|
add eax, [line_len]
|
||||||
|
cmp eax, edx ; last loc
|
||||||
|
je .other_dir
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
mov edi, eax
|
||||||
|
jmp walking_loop
|
||||||
|
.other_dir:
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
sub edi, [line_len]
|
||||||
|
jmp walking_loop
|
||||||
|
c_hyphen:
|
||||||
|
cmp byte [edi], '-'
|
||||||
|
jne c_7
|
||||||
|
mov eax, edi
|
||||||
|
add eax, 1
|
||||||
|
cmp eax, edx ; last loc
|
||||||
|
je .other_dir
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
mov edi, eax
|
||||||
|
jmp walking_loop
|
||||||
|
.other_dir:
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
sub edi, 1
|
||||||
|
jmp walking_loop
|
||||||
|
c_7:
|
||||||
|
cmp byte [edi], '7'
|
||||||
|
jne c_J
|
||||||
|
mov eax, edi
|
||||||
|
add eax, [line_len] ; down
|
||||||
|
cmp eax, edx ; last loc
|
||||||
|
je .other_dir
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
mov edi, eax
|
||||||
|
jmp walking_loop
|
||||||
|
.other_dir:
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
sub edi, 1 ; left
|
||||||
|
jmp walking_loop
|
||||||
|
c_J:
|
||||||
|
cmp byte [edi], 'J'
|
||||||
|
jne c_L
|
||||||
|
mov eax, edi
|
||||||
|
sub eax, [line_len] ; up
|
||||||
|
cmp eax, edx ; last loc
|
||||||
|
je .other_dir
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
mov edi, eax
|
||||||
|
jmp walking_loop
|
||||||
|
.other_dir:
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
sub edi, 1 ; left
|
||||||
|
jmp walking_loop
|
||||||
|
c_L:
|
||||||
|
cmp byte [edi], 'L'
|
||||||
|
jne c_F
|
||||||
|
mov eax, edi
|
||||||
|
sub eax, [line_len] ; up
|
||||||
|
cmp eax, edx ; last loc
|
||||||
|
je .other_dir
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
mov edi, eax
|
||||||
|
jmp walking_loop
|
||||||
|
.other_dir:
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
add edi, 1 ; right
|
||||||
|
jmp walking_loop
|
||||||
|
c_F:
|
||||||
|
cmp byte [edi], 'F'
|
||||||
|
jne fucked_up
|
||||||
|
mov eax, edi
|
||||||
|
add eax, [line_len] ; down
|
||||||
|
cmp eax, edx ; last loc
|
||||||
|
je .other_dir
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
mov edi, eax
|
||||||
|
jmp walking_loop
|
||||||
|
.other_dir:
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
add edi, 1 ; right
|
||||||
|
jmp walking_loop
|
||||||
|
|
||||||
|
done_walking:
|
||||||
|
mov eax, [final_value]
|
||||||
|
inc eax
|
||||||
|
shr eax, 1
|
||||||
|
mov [final_value], eax
|
||||||
|
|
||||||
|
game_over:
|
||||||
|
mov eax, [final_value]
|
||||||
|
call print_dec
|
||||||
|
call newline
|
||||||
|
; go get an image editor and fill
|
||||||
|
; and ready for lots of counting :3
|
||||||
|
mov esi, new_f
|
||||||
|
mov ecx, file.over - file
|
||||||
|
call print_string
|
||||||
|
call newline
|
||||||
|
jmp exit
|
||||||
|
|
||||||
|
fucked_up:
|
||||||
|
mov eax, 999999999
|
||||||
|
call print_dec
|
||||||
|
jmp exit
|
||||||
|
|
||||||
|
[section .data]
|
||||||
|
line_len: dd 0
|
||||||
|
s_idx: dd 0
|
||||||
|
s_line: dd 0
|
||||||
|
s_col: dd 0
|
||||||
|
final_value: dd 0
|
||||||
|
file: incbin "input"
|
||||||
|
.over:
|
||||||
|
|
||||||
|
[section .bss]
|
||||||
|
new_f: resb 1024*64
|
208
10/main_part1.s
Normal file
208
10/main_part1.s
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
global _start
|
||||||
|
[bits 32]
|
||||||
|
[section .text]
|
||||||
|
|
||||||
|
%include "utils.s"
|
||||||
|
|
||||||
|
_start:
|
||||||
|
|
||||||
|
; find line length
|
||||||
|
mov edi, file
|
||||||
|
mov ecx, file_lim - file
|
||||||
|
mov al, 10 ; \n
|
||||||
|
repne scasb
|
||||||
|
mov eax, edi
|
||||||
|
sub eax, file
|
||||||
|
mov [line_len], eax
|
||||||
|
|
||||||
|
call print_dec
|
||||||
|
call newline
|
||||||
|
|
||||||
|
; find S
|
||||||
|
mov edi, file
|
||||||
|
mov ecx, file_lim - file
|
||||||
|
mov al, 'S' ; \n
|
||||||
|
repne scasb
|
||||||
|
mov eax, edi
|
||||||
|
sub eax, file
|
||||||
|
dec eax
|
||||||
|
mov [s_idx], eax
|
||||||
|
mov ebx, [line_len]
|
||||||
|
div ebx
|
||||||
|
mov [s_line], eax
|
||||||
|
call print_dec
|
||||||
|
call space
|
||||||
|
mov [s_col], edx
|
||||||
|
mov eax, edx
|
||||||
|
call print_dec
|
||||||
|
call newline
|
||||||
|
|
||||||
|
; walk the loop
|
||||||
|
mov esi, file
|
||||||
|
add esi, [s_idx]
|
||||||
|
mov edx, esi ; last loc
|
||||||
|
mov ebx, [line_len]
|
||||||
|
; downs
|
||||||
|
lea edi, [esi+ebx]
|
||||||
|
cmp byte [edi], '|'
|
||||||
|
je walking_loop
|
||||||
|
cmp byte [edi], 'J'
|
||||||
|
je walking_loop
|
||||||
|
cmp byte [edi], 'L'
|
||||||
|
je walking_loop
|
||||||
|
; ups
|
||||||
|
neg ebx
|
||||||
|
lea edi, [esi+ebx]
|
||||||
|
cmp byte [edi], '|'
|
||||||
|
je walking_loop
|
||||||
|
cmp byte [edi], 'F'
|
||||||
|
je walking_loop
|
||||||
|
cmp byte [edi], '7'
|
||||||
|
je walking_loop
|
||||||
|
; lefts
|
||||||
|
lea edi, [esi-1]
|
||||||
|
cmp byte [edi], '-'
|
||||||
|
je walking_loop
|
||||||
|
cmp byte [edi], 'L'
|
||||||
|
je walking_loop
|
||||||
|
cmp byte [edi], 'F'
|
||||||
|
je walking_loop
|
||||||
|
; rights
|
||||||
|
lea edi, [esi+1]
|
||||||
|
cmp byte [edi], '-'
|
||||||
|
je walking_loop
|
||||||
|
cmp byte [edi], 'J'
|
||||||
|
je walking_loop
|
||||||
|
cmp byte [edi], '7'
|
||||||
|
je walking_loop
|
||||||
|
jmp fucked_up
|
||||||
|
|
||||||
|
; | - 7 J L F
|
||||||
|
walking_loop:
|
||||||
|
pushad
|
||||||
|
xor edx, edx
|
||||||
|
mov eax, edi
|
||||||
|
sub eax, file
|
||||||
|
mov ebx, [line_len]
|
||||||
|
div ebx
|
||||||
|
call print_dec
|
||||||
|
call space
|
||||||
|
mov eax, edx
|
||||||
|
call print_dec
|
||||||
|
call newline
|
||||||
|
popad
|
||||||
|
inc dword [final_value]
|
||||||
|
cmp byte [edi], 'S'
|
||||||
|
je done_walking
|
||||||
|
c_pipe:
|
||||||
|
cmp byte [edi], '|'
|
||||||
|
jne c_hyphen
|
||||||
|
mov eax, edi
|
||||||
|
add eax, [line_len]
|
||||||
|
cmp eax, edx ; last loc
|
||||||
|
je .other_dir
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
mov edi, eax
|
||||||
|
jmp walking_loop
|
||||||
|
.other_dir:
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
sub edi, [line_len]
|
||||||
|
jmp walking_loop
|
||||||
|
c_hyphen:
|
||||||
|
cmp byte [edi], '-'
|
||||||
|
jne c_7
|
||||||
|
mov eax, edi
|
||||||
|
add eax, 1
|
||||||
|
cmp eax, edx ; last loc
|
||||||
|
je .other_dir
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
mov edi, eax
|
||||||
|
jmp walking_loop
|
||||||
|
.other_dir:
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
sub edi, 1
|
||||||
|
jmp walking_loop
|
||||||
|
c_7:
|
||||||
|
cmp byte [edi], '7'
|
||||||
|
jne c_J
|
||||||
|
mov eax, edi
|
||||||
|
add eax, [line_len] ; down
|
||||||
|
cmp eax, edx ; last loc
|
||||||
|
je .other_dir
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
mov edi, eax
|
||||||
|
jmp walking_loop
|
||||||
|
.other_dir:
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
sub edi, 1 ; left
|
||||||
|
jmp walking_loop
|
||||||
|
c_J:
|
||||||
|
cmp byte [edi], 'J'
|
||||||
|
jne c_L
|
||||||
|
mov eax, edi
|
||||||
|
sub eax, [line_len] ; up
|
||||||
|
cmp eax, edx ; last loc
|
||||||
|
je .other_dir
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
mov edi, eax
|
||||||
|
jmp walking_loop
|
||||||
|
.other_dir:
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
sub edi, 1 ; left
|
||||||
|
jmp walking_loop
|
||||||
|
c_L:
|
||||||
|
cmp byte [edi], 'L'
|
||||||
|
jne c_F
|
||||||
|
mov eax, edi
|
||||||
|
sub eax, [line_len] ; up
|
||||||
|
cmp eax, edx ; last loc
|
||||||
|
je .other_dir
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
mov edi, eax
|
||||||
|
jmp walking_loop
|
||||||
|
.other_dir:
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
add edi, 1 ; right
|
||||||
|
jmp walking_loop
|
||||||
|
c_F:
|
||||||
|
cmp byte [edi], 'F'
|
||||||
|
jne fucked_up
|
||||||
|
mov eax, edi
|
||||||
|
add eax, [line_len] ; down
|
||||||
|
cmp eax, edx ; last loc
|
||||||
|
je .other_dir
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
mov edi, eax
|
||||||
|
jmp walking_loop
|
||||||
|
.other_dir:
|
||||||
|
mov edx, edi ; last loc = loc
|
||||||
|
add edi, 1 ; right
|
||||||
|
jmp walking_loop
|
||||||
|
|
||||||
|
done_walking:
|
||||||
|
mov eax, [final_value]
|
||||||
|
inc eax
|
||||||
|
shr eax, 1
|
||||||
|
mov [final_value], eax
|
||||||
|
|
||||||
|
game_over:
|
||||||
|
mov eax, [final_value]
|
||||||
|
call print_dec
|
||||||
|
jmp exit
|
||||||
|
|
||||||
|
fucked_up:
|
||||||
|
mov eax, 999999999
|
||||||
|
call print_dec
|
||||||
|
jmp exit
|
||||||
|
|
||||||
|
[section .data]
|
||||||
|
line_len: dd 0
|
||||||
|
s_idx: dd 0
|
||||||
|
s_line: dd 0
|
||||||
|
s_col: dd 0
|
||||||
|
final_value: dd 0
|
||||||
|
file_lim: dd file.over - file
|
||||||
|
file: incbin "input"
|
||||||
|
.over:
|
||||||
|
|
||||||
|
[section .bss]
|
BIN
10/solution.png
Normal file
BIN
10/solution.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
258
10/utils.s
Normal file
258
10/utils.s
Normal file
@ -0,0 +1,258 @@
|
|||||||
|
; 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
|
Loading…
Reference in New Issue
Block a user