day 19 part 1

This commit is contained in:
Lucia Ceionia 2023-12-19 21:20:26 -06:00
parent 0785e7ccd0
commit d59671e54c
5 changed files with 1389 additions and 0 deletions

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}

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