From 630ea6662368d0e09f1e82d7b9131905ea29f1fa Mon Sep 17 00:00:00 2001 From: marketideas Date: Wed, 20 Nov 2019 07:59:02 -0800 Subject: [PATCH] adding script to create M32 output files --- Makefile | 1 + asm.cpp | 1 + asm.h | 34 ++++++++++++----- merlintests.sh | 35 ++++++++++++++++++ runtests.sh | 4 +- testdata/M32_expected/1000-allops-value-65816 | Bin 588 -> 0 bytes testdata/M32_expected/1001-allops-zero-65816 | Bin 588 -> 0 bytes .../M32_expected/1002-embedded-instructions | Bin 101 -> 0 bytes testdata/M32_expected/1003-flags-and-branches | Bin 311 -> 0 bytes testdata/M32_expected/1004-data-recognition | Bin 196 -> 0 bytes testdata/M32_expected/2000-allops-value-6502 | Bin 598 -> 0 bytes testdata/M32_expected/2001-allops-zero-6502 | Bin 598 -> 0 bytes testdata/M32_expected/2002-allops-value-65C02 | Bin 489 -> 0 bytes testdata/M32_expected/2003-allops-zero-65C02 | Bin 489 -> 0 bytes testdata/M32_expected/2004-numeric-types | Bin 1024 -> 0 bytes testdata/M32_expected/2005-string-types | Bin 3132 -> 0 bytes testdata/M32_expected/2006-operand-formats | Bin 133 -> 0 bytes testdata/M32_expected/2007-labels-and-symbols | Bin 695 -> 0 bytes testdata/M32_expected/2008-address-changes | Bin 203 -> 0 bytes testdata/M32_expected/2010-target-adjustment | Bin 191 -> 0 bytes testdata/M32_expected/2011-hinting | 2 - testdata/M32_expected/2012-label-localizer | Bin 103 -> 0 bytes testdata/M32_expected/2013-notes-and-comments | Bin 98 -> 0 bytes testdata/M32_expected/2014-label-dp | Bin 601 -> 0 bytes testdata/M32_expected/2019-local-variables | Bin 151 -> 0 bytes testdata/M32_expected/2020-cycle-counts-65816 | Bin 126 -> 0 bytes testdata/M32_expected/2021-external-symbols | Bin 329 -> 0 bytes testdata/M32_expected/2022-extension-scripts | Bin 213 -> 0 bytes 28 files changed, 63 insertions(+), 14 deletions(-) create mode 100755 merlintests.sh delete mode 100644 testdata/M32_expected/1000-allops-value-65816 delete mode 100644 testdata/M32_expected/1001-allops-zero-65816 delete mode 100644 testdata/M32_expected/1002-embedded-instructions delete mode 100644 testdata/M32_expected/1003-flags-and-branches delete mode 100644 testdata/M32_expected/1004-data-recognition delete mode 100644 testdata/M32_expected/2000-allops-value-6502 delete mode 100644 testdata/M32_expected/2001-allops-zero-6502 delete mode 100644 testdata/M32_expected/2002-allops-value-65C02 delete mode 100644 testdata/M32_expected/2003-allops-zero-65C02 delete mode 100644 testdata/M32_expected/2004-numeric-types delete mode 100644 testdata/M32_expected/2005-string-types delete mode 100644 testdata/M32_expected/2006-operand-formats delete mode 100644 testdata/M32_expected/2007-labels-and-symbols delete mode 100644 testdata/M32_expected/2008-address-changes delete mode 100644 testdata/M32_expected/2010-target-adjustment delete mode 100644 testdata/M32_expected/2011-hinting delete mode 100644 testdata/M32_expected/2012-label-localizer delete mode 100644 testdata/M32_expected/2013-notes-and-comments delete mode 100644 testdata/M32_expected/2014-label-dp delete mode 100644 testdata/M32_expected/2019-local-variables delete mode 100644 testdata/M32_expected/2020-cycle-counts-65816 delete mode 100644 testdata/M32_expected/2021-external-symbols delete mode 100644 testdata/M32_expected/2022-extension-scripts diff --git a/Makefile b/Makefile index 75353fe..98d38ea 100644 --- a/Makefile +++ b/Makefile @@ -34,6 +34,7 @@ debug: distclean: rm -rf ./build -rm -rf ./testout + -rm -rf ./m32out clean: -rm -rf ./build diff --git a/asm.cpp b/asm.cpp index 9324727..b57ae41 100644 --- a/asm.cpp +++ b/asm.cpp @@ -1554,6 +1554,7 @@ void CLASS::initpass(void) truncdata = 0; variables.clear(); // clear the variables for each pass + macros.clear(); while (!PCstack.empty()) { PCstack.pop(); diff --git a/asm.h b/asm.h index aa0e88e..5a9573c 100644 --- a/asm.h +++ b/asm.h @@ -280,11 +280,12 @@ public: { clear(); } - void clear(void) { - lupct=0; - lupoffset=0; - luprunning=0; - lupskip=false; + void clear(void) + { + lupct = 0; + lupoffset = 0; + luprunning = 0; + lupskip = false; } uint16_t lupct; bool lupskip; @@ -299,9 +300,10 @@ public: { clear(); } - void clear(void) { - doskip=false; - value=0; + void clear(void) + { + doskip = false; + value = 0; } uint32_t value; bool doskip; @@ -334,7 +336,7 @@ public: value = 0; used = false; //text = ""; - var_text=""; + var_text = ""; name = ""; namelc = ""; stype = 0; @@ -343,6 +345,17 @@ public: } }; + +class TMacro +{ +public: + std::string name; + std::string lcname; + uint32_t currentline; + std::vector lines; + std::vector variables; +}; + class TPsuedoOp; class T65816Asm : public TFileProcessor @@ -371,8 +384,8 @@ public: std::string currentsymstr; std::vector lines; + Poco::HashMap macros; Poco::HashMapopcodes; - Poco::HashMap macros; Poco::HashMap symbols; Poco::HashMap variables; @@ -386,6 +399,7 @@ public: std::stack LUPstack; std::stack DOstack; std::stack LSTstack; + std::stack curMacro; TPsuedoOp *psuedoops; diff --git a/merlintests.sh b/merlintests.sh new file mode 100755 index 0000000..6f39cd2 --- /dev/null +++ b/merlintests.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +OUTDIR=./m32out + +rm -rf $OUTDIR +mkdir -p $OUTDIR + +SRC=`ls ./testdata | grep -E '^([0-9]+)(.*)\.[Ss]'` + +#SRC=`ls ./testdata | grep -E '^([0-9]+)(.*)\.[Ss]' | grep -i 2007` + +for S in $SRC ; do + + S1=$S + S1=${S1/.S/} + S1=${S1/.s/} + + BASE=${S/.S/} + BASE=${BASE/.s/} + cd ./testdata + #merlin32 $S 2>/dev/null >/dev/null + merlin32 . $S 2>/dev/null + + R=?$ + cd - >/dev/null + cp ./testdata/$S1 $OUTDIR/$S1.bin 2>/dev/null + rm -f ./testdata/*.txt 2>/dev/null + rm -f ./testdata/$S1 2>/dev/null + R=?$ + +done +ls $OUTDIR + + + diff --git a/runtests.sh b/runtests.sh index 6e4ae83..044b44b 100755 --- a/runtests.sh +++ b/runtests.sh @@ -40,8 +40,8 @@ for S in $SRC ; do MSHA="Q" QSHA="M" - if [ -f ./testdata/M32_expected/$BASE ] ; then - MSHA=`sha256sum ./testdata/M32_expected/$BASE | awk '{ print $1;}'` 2>/dev/null >/dev/null + if [ -f ./m32out/$BASE.bin ] ; then + MSHA=`sha256sum ./m32out/$BASE.bin | awk '{ print $1;}'` 2>/dev/null >/dev/null fi if [ -f $OUTDIR/$BASE.bin ] ; then diff --git a/testdata/M32_expected/1000-allops-value-65816 b/testdata/M32_expected/1000-allops-value-65816 deleted file mode 100644 index 204a57bf01c9a3ffe9401651388e6a830e531aec..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 588 zcmWN{b9k0v07mgAtrp)edvDgVmTlX%ZMS9HcFQ)FZJVnvFRrco^!#_O>-+*DTtCMR zcHA(>_3^mA9@pRFhI`ydkJsxpL?J5Ch)xWAh)FD8V#kS#;-UB`0s7|{4+%*`Vv>-Q zWF$|4Ql?6c(x9}+&k`4sZeQHf~~b@D{WcZA06w*kN|Ei{0#DFZquA3X&3%`0B> qhPQ2??ni?7(I8PY$Q2D9MT4i&n3x!1i7k$};)ySTgo(WJYGRU*lw^pA zN-l+zUh}$C-bhWFH`DSK=|~@vfDAH*k;&UK%Ob06+2zQYi+9LPp77pcY( zQn(237yW=@d`R(-lqji`(#lX)IptNT=%bG-ZH-i>3ROcd|JQ3 zjfjRcqH&0tG}Y|I^X6J;sg>5+wDsBNU+^XEXdj9WI{Hc{oqg>aU3Be6_Z~gz#kceh zNgsXnqrU+L8f35`Lk$}~f{~13bV$Y+Yn<^Wm}rv8rhLcLY15g(OlE~-wmIgSXTAl# z_k$l7TC{ixOIgP9P^_@hDyyxr);jBL*vO`zHuE#T@M}nZv&B~1Y`4QsyX@X$@4o#U z;2?)Wao7<@9dq0XC!O;9Y0jKI#~+;MLP##Usw|nmU W$G<%A(0~4a#N#JVdB$^Igytpk*^H?G diff --git a/testdata/M32_expected/1002-embedded-instructions b/testdata/M32_expected/1002-embedded-instructions deleted file mode 100644 index cffff3c6b4f59ff3aca169f2ed3cbfc821ddd335..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001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Y> zK=6GaG&Gbj!U`8&1QA7w97WV<(TPD!Vg1D{6N#-B2kd}a>ILTyFOr2)B8D`F!&78UOn9l+hF0$AX zOP5)0g_WyTTeEf@>)F6>zuRb&KmN4Y7F)Od#oya^u#;Wv-ea$Q_8)N2A%~9~b?o>F zPI8LVXPkA;`3o+(Ee-FxnP;NhdkLZ3Y48P9p~(krjMdF!3` Q{`>y}A3uHO3t##69j_CI4FCWD diff --git a/testdata/M32_expected/2004-numeric-types b/testdata/M32_expected/2004-numeric-types deleted file mode 100644 index 47e2524502e99c91732705abac5d18b216389e39..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024 zcmYcgR1!2+5_AD#K_FAf7>HaL7#bKL7|eh&fkGn|G@KdfK(GOnGD6eJJ7xkC1)RNV z_nEuz{uAQ=e|PuH?o~58%F{wYDUG3F)nEaQ6ej7$)%XF_c*aHnD68@AT?(zFs&)XH C3~EpS diff --git a/testdata/M32_expected/2005-string-types b/testdata/M32_expected/2005-string-types deleted file mode 100644 index df57058d0d0483766bc909c5897bfe0d18f3f4fc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3132 zcmeHJyG|QH6y5wlkjM{Qxp8AznDDYFA`4NtL6P`@jCb#9N1mN=X2#xZs&$e7u-qV} zh?I1ch{`pe00^j}5GRUK<<5c=9Ja7niWH$hqnUHg+;iD`hF3x*(AwW=x4~GQU0z*W zj*d=_CzH|F>2+46)9UNKvKUmVRf}(IHg=Hlmv5h^=Vu4w@$~%1G+Sw`K3`kk*xYJ9 z&Z>l9wOTE~-YQ9NmgTRM7HB+FVPmsWsXVB6^oK7&ZI-=YLNG!o3zoz7%}NODfIEy;l;ns+$u1Bk zkZ3^T03{$XQ9D#18Po#FyOPBqIRrQmYCwyaK^xHYnNNB(jKN@Jxa2VpAhHYtFpiSS z7C@b}5|D`kl$=CEMHhpi3%L#NTyH7lt^y33y(ppV?0kb3UN zH3+stfrffYMAQUF*CQr!%nYgahF&(8qHn#wa`dNHkfdHwlzI;uz*+jz=$8{Hif@nX zJ)QH{$d=~ciI3TG!AtS1=&5*7bj6~3F4|r$3SJa9^vIt#XK*!J^5z|W%9gz%i(a8e zZ_&GpaJk7+3Pq~fyC-{!hFJnPkpC7;1~nQ~%QXT82)8s~;Wp5BuhZX1=y941cWxsD zUlE)p$JS_4dQ98dLCmga{0=CEB_xdSee1F@&v=mjEsbghK!5`djWd^1_Ap50T5&mC;$M| C947n# diff --git a/testdata/M32_expected/2007-labels-and-symbols b/testdata/M32_expected/2007-labels-and-symbols deleted file mode 100644 index a200c62e91cd8a28de3ff5baa42ff17824d08e13..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 695 zcmcJN&2G~`5XWa9pkZ(l)Z<9L5Cl;RmJmot9FmAb4n3r)KsjKyZemF6kT`|57uS4$ zKLv+5SbhiY$r}`*T%b{%Q-lymYu14i;)?X&nVsMMXLk>?`g6L*V?O2;PFV6KPPxR$ zCwzvhtg~1oa#7V60v1hUp}}9}heOKlN{#+3*f5G`f}4W*w9#mU}K!fsxHP*LWB|k zBvL|>%ZaM43jwudl*u?d012SHx&Q&7NQN>7>PMiIVc@gS5L!hOzoRuzLx2__%x1Ic zS_De#5nPVoN^ngf>qlyRPpxk$<&g?VMGQ`Yufdmanued#@KajPW4(a&BDV4ft%6!b z1UiRw9_a$oMWiy)I+B5O73n(C4Wye$6{K4ju8QC&eEj6;v*#~fzIy%U?YsB?yKZ!x zAt{;E_1rcM{ek1Q%d|1_Gh|wJmrQquw!L1@c75_(a(wbV1>9X{&?CQNs=8zU)7#xA zv){MPLDrXGqN{wFmf~k+uuV#q#G+wD=#a^ K+#>{y4ABoowLAO( diff --git a/testdata/M32_expected/2010-target-adjustment b/testdata/M32_expected/2010-target-adjustment deleted file mode 100644 index 5b3cfa680579537c525423eb7ff4a911d8b49142..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 191 zcmZ1}xJYS%@k*Bl3uVT1*VUcx&k8aaD>Z~YI0`rm zFra~kwOj&g9R>J!1oZd>@&p8Qg#>s-1lAe~^qLB+wG`;J6;NOjSj#5xB|{+T=l``? z0&BAcR=(;j7wD}P=&cuMs^@QLY--kFQdrv}u$DogfxD)*t{x=R(%QC`S79xm!diZX ewE_xj1r^o`DXbM%SSzBiR#aiFn8I3dg#-ZOnK|JA diff --git a/testdata/M32_expected/2011-hinting b/testdata/M32_expected/2011-hinting deleted file mode 100644 index 07cb179..0000000 --- a/testdata/M32_expected/2011-hinting +++ /dev/null @@ -1,2 +0,0 @@ -,,, -,  V$"  ( V$3D : =V$ E` V$Uf`` \ No newline at end of file diff --git a/testdata/M32_expected/2012-label-localizer b/testdata/M32_expected/2012-label-localizer deleted file mode 100644 index 7a2358e88df2fbc5c448750d19ab52d2b81b1313..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 103 zcmaF0mRDdczrb1nfwg=BuYh2!h`>t0S8K%u*2;tUYh?wNGJIfDkQY#36j-UW)=c2l pT63VpO5?STK&CTD%}N&qFR)$(AAtsjS8F>uKnAU3xbP1K697C=GxPue diff --git a/testdata/M32_expected/2013-notes-and-comments b/testdata/M32_expected/2013-notes-and-comments deleted file mode 100644 index 233ba0563752d1a6f2f771284ebfcdd42b2476ac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 98 zcmb8i$pHWm3;;nP#H|qzC24QFRD<~qf+wIv5=N#_X>-P`M CBMkfi diff --git a/testdata/M32_expected/2014-label-dp b/testdata/M32_expected/2014-label-dp deleted file mode 100644 index 5c8e85e8d3da44f1b76ebca6fcf24b1f2dc23ec0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 601 zcmXBOV|14R9L4dQTm1jCd$N{o+qP|6-?sJ3w#{YRwr#DJm)pYA>D)K>ocnok3xql; zJx-v<3Gq0Qy^fF9@%1`CyiS-mI5=2@BRmm^NF*W?g{VG6iyp%i(-g}TdyM3fmpH^F z9`Q*)LJ}o5B}tmhl-!iUl+q=RDHW;Rl7_UTBRv_&n2F3;d`($R*-Y8pEr)WFi`?WP zFZsw%fr6$&g^QSqnu?iQ3J{sCnvM|mn#q*CQ7M?6(c)lAi0QA0JUMQ!T% z2h^n=^=Z)1)TnWjAdi}wnwgrrs6|U!{rTORHngQ3?di~wPMy1$x|+I~y1Sx>deV#D z^r0{P=+A(Gra^;;n1-5$nTERrjlfUxCxDR{qZmDgvE#;@CYUCgCb?v?rZAOhOlJl& znZ@imrn&Rxn--WBnijcaF-us=GM2M~m8@d*8rBA`Gp#pmFl}_jCT(U5TiM2TcCeFO zyG?uc?lbK-9WWhq$srDNL`ONsaZYfOQ>Qs|_MGXw>4NE^D=z6WSGdYGu5*K%+`4VL zbN8O5 z4|BF!Ui0ZCv+v1f5DW@flyImJmDFev`mc}}`R9}0Qxlw4Qa{~gpa+<7qsPFXLr=9p4i333JAt`JI32KmOE1aLH&kL!U=(4%B4eb)V8H0&>AGPM4Gl>h`vg2pbPY2_U=JId42jyW83I_z@P?KsfvRRRrb1sV>%d2{sT f^A}%$PD?7v&rZ!#V1zm>0ptKKh6JEYYF-Ke=88um