From a3fb0b95dffebdbda440ff707934813b5851a99a Mon Sep 17 00:00:00 2001 From: Jeremy Penner Date: Sat, 26 Oct 2019 14:12:25 -0400 Subject: [PATCH] loops, add --- asm.img | Bin 11554 -> 11680 bytes asm.qf | 6 +- in.asm | 21 +- out.com | Bin 27 -> 37 bytes trace.txt | 682 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 693 insertions(+), 16 deletions(-) diff --git a/asm.img b/asm.img index e59ce0e32c59ad88c367523071f468561fe2e9b1..74b4308b98df5bca5f21bda02f848dab314d6d9b 100755 GIT binary patch delta 660 zcmX}nK}b|l6b9gP-o5XQ11egSGlnD16IYf?p<2vF)FKd+Fb9IsXP`LbsMEBtUbGPu z7tf2}CXn0&K?Ea03s>S=a4Cq2HQtd7~)x877% z)yJAe#`A)pDe_wYOy;K*-f6bP zm>+cw_6`KW1LqeXyd=-Cwq!Ba_$+Gg$W3sHc5A%~`XY1=PR60 z{-HB^&#T?8)FVIf8lAGh)4HTIi}o9xX6*~re{Fb*IUVwt(RZwGLY*->!*D?8N8Z|sPE!Y)WtN$-hhkS#6s#`K~C zV-(1Xe4+!l)F6bEDV6z}&XPy^L^YXJ;|m+6Y`kG(k$lk4{|1xS)qj(+0Zb#uq$+9x zNM0+80a_D2_AFY-C{)F(c!!GoX0vb+zC~T!LtO|_5xZ1~zjJ-;P_FT@Jf07tv*=-T n1|350pu^}KdInuYFQCWwaj=YoJ#-R%fKH*e(Rp-^rw4<-u>y6v diff --git a/asm.qf b/asm.qf index 9a4be33..73940c3 100755 --- a/asm.qf +++ b/asm.qf @@ -88,6 +88,9 @@ OP_IMM OP_REG16 :noname &hb8 op1 + outb! op2 outw! ; ' mov impl OP_IMM OP_REG8 :noname &hb0 op1 + outb! op2 outb! ; ' movb impl : :+r anondo >r , OP_REG16 r> does> @ op1 + outb! ; : :+sreg anondo >r , OP_SREG r> does> @ op1 8 * + outb! ; +: modrm ( mod rm reg ) 8 * | swap 64 * | outb! ; +2 inst add +OP_REG16 OP_REG16 :noname &h01 outb! &h03 op1 op2 modrm ; ' add impl 1 inst push &h06 :+sreg ' push impl @@ -99,7 +102,8 @@ OP_IMM OP_REG8 :noname &hb0 op1 + outb! op2 outb! ; ' movb impl &h48 :+r ' dec impl : :jumprel here >r 1 LBL_REL | inst - :| anondo >r , OP_IMM r> does> @ outb! op1 outb! |; r> impl ; + :| anondo >r , OP_IMM r> does> @ outb! op1 outb! |; execute + r> impl ; &h77 :jumprel ja &h73 :jumprel jae diff --git a/in.asm b/in.asm index 8af4481..2405e47 100755 --- a/in.asm +++ b/in.asm @@ -1,20 +1,21 @@ - cs push \ copy code segment to data segment - ds pop + cs push \ copy code segment to data segment + ds pop -\ jne not yet working -\ :> loop -\ cx 3 # mov + cx 11 # mov -:> msg +:> loop + :> msg dx msg mov + dx cx add ah 9 # movb &h21 int - -\ cx dec -\ loop jne + + cx dec + loop jge 0 .EXIT msg <: - d" Hello World!$" + : nl 13 outb! 10 outb! ; + d" Hello World!" nl d" $" diff --git a/out.com b/out.com index 23241150ce4b57df14983f8fe8e1c10b7c3a1f71..22597a6aa6e2337e056ed932c8706889df2737e1 100755 GIT binary patch literal 37 tcmd;+-^tCeON^26)E3UOik`J!b};yyRrE;B$;np;&o9bJQRL-P0RZli3|#;K literal 27 icmd;+-^Itch4ZZ94hEmIiXN#sIr$3V`9(P?iYfqm7YOwL diff --git a/trace.txt b/trace.txt index 452e983..bd0f8ee 100755 --- a/trace.txt +++ b/trace.txt @@ -1,26 +1,698 @@ +read: array +read: ops +read: 2 +read: allot +read: array +read: optypes +read: 2 +read: allot +read: var +read: currop +read: : +read: op1 +read: ops +read: @ +read: ; +read: : +read: op2 +read: ops +read: 1 +read: + +read: @ +read: ; +read: 0 +read: const +read: OP_NONE +read: 1 +read: const +read: OP_REG8 +read: 2 +read: const +read: OP_REG16 +read: 3 +read: const +read: OP_SREG +read: 4 +read: const +read: OP_IMM +read: : +read: op! +read: ( +read: currop +read: @ +read: >r +read: optypes +read: r@ +read: + +read: ! +read: ops +read: r@ +read: + +read: ! +read: 1 +read: r> +read: + +read: currop +read: ! +read: ; +read: : +read: mkreg +read: makedo +read: , +read: does> +read: @ +read: swap +read: makedo +read: , +read: , +read: does> +read: dup +read: @ +read: swap +read: 1 +read: + +read: @ +read: op! +read: ; +read: OP_REG8 +read: mkreg +read: reg8 +read: OP_REG16 +read: mkreg +read: reg16 +read: OP_SREG +read: mkreg +read: sreg +read: 0 +read: reg16 +read: ax +read: 0 +read: reg8 +read: al +read: 4 +read: reg8 +read: ah +read: 1 +read: reg16 +read: cx +read: 1 +read: reg8 +read: cl +read: 5 +read: reg8 +read: ch +read: 2 +read: reg16 +read: dx +read: 2 +read: reg8 +read: dl +read: 6 +read: reg8 +read: dh +read: 3 +read: reg16 +read: bx +read: 3 +read: reg8 +read: bl +read: 7 +read: reg8 +read: bh +read: 4 +read: reg16 +read: sp +read: 5 +read: reg16 +read: bp +read: 6 +read: reg16 +read: si +read: 7 +read: reg16 +read: di +read: 0 +read: sreg +read: es +read: 1 +read: sreg +read: cs +read: 2 +read: sreg +read: ss +read: 3 +read: sreg +read: ds +read: : +read: # +read: OP_IMM +read: op! +read: ; +read: &h80 +read: const +read: LBL_REL +read: var +read: lblfixup +read: var +read: currlbl +read: : +read: currlbl-head +read: currlbl +read: @ +read: 1 +read: + +read: ; +read: : +read: mk-lbl-fixpoint +read: here +read: currlbl-head +read: @ +read: , +read: tell +read: , +read: lblfixup +read: @ +read: , +read: currlbl-head +read: ! +read: ; +read: : +read: :> +read: makedo +read: tell +read: , +read: 0 +read: , +read: does> +read: 0 +read: # +read: currlbl +read: ! +read: ; +read: : +read: fixlabel.rel +read: currlbl +read: @ +read: @ +read: tell +read: - +read: &hff +read: & +read: tell +read: 1 +read: - +read: seek +read: outb! +read: ; +read: : +read: fixlabel.addr +read: currlbl +read: @ +read: @ +read: &h100 +read: + +read: tell +read: 2 +read: - +read: seek +read: outw! +read: ; +read: : +read: fixlabel +read: ( +read: if +read: fixlabel.rel +read: else +read: fixlabel.addr +read: then +read: ; +read: : +read: fixpoint.seek +read: ( +read: 1 +read: + +read: @ +read: seek +read: ; +read: : +read: fixpoint.fix +read: ( +read: 2 +read: + +read: @ +read: fixlabel +read: ; +read: : +read: fixpoint +read: ( +read: dup +read: fixpoint.seek +read: dup +read: fixpoint.fix +read: @ +read: ; +read: : +read: fix.fixpoints +read: currlbl-head +read: @ +read: begin +read: dup +read: while +read: fixpoint +read: repeat +read: drop +read: ; +read: : +read: assembled +read: ( +read: currlbl +read: @ +read: and +read: if +read: lblfixup +read: @ +read: fixlabel +read: mk-lbl-fixpoint +read: then +read: 0 +read: currop +read: ! +read: 0 +read: lblfixup +read: ! +read: 0 +read: currlbl +read: ! +read: ; +read: : +read: update.label +read: tell +read: currlbl +read: @ +read: ! +read: ; +read: : +read: <: +read: update.label +read: tell +read: fix.fixpoints +read: seek +read: 0 +read: assembled +read: ; +read: : +read: read-impl +read: ( +read: dup +read: @ +read: swap +read: dup +read: 1 +read: + +read: @ +read: swap +read: 2 +read: + +read: ; +read: : +read: match-impl +read: ( +read: begin +read: dup +read: 0 +read: > +read: while +read: 1 +read: - +read: 2dup +read: + +read: @ +read: over +read: optypes +read: + +read: @ +read: != +read: if +read: drop +read: drop +read: 0 +read: ret +read: then +read: repeat +read: drop +read: drop +read: 1 +read: ; +read: : +read: inst +read: ( +read: makedo +read: dup +read: &h7f +read: & +read: , +read: 0 +read: , +read: &h80 +read: & +read: , +read: does> +read: dup +read: 2 +read: + +read: @ +read: lblfixup +read: ! +read: dup +read: @ +read: currop +read: @ +read: != +read: if +read: 0 +read: message +read: yelp +read: ret +read: then +read: 1 +read: + +read: @ +read: begin +read: dup +read: while +read: read-impl +read: currop +read: @ +read: match-impl +read: if +read: execute +read: drop +read: 1 +read: assembled +read: ret +read: else +read: drop +read: then +read: repeat +read: drop +read: 1 +read: message +read: yelp +read: 0 +read: assembled +read: ; +read: : +read: inst-nextimpl +read: do.data +read: 1 +read: + +read: ; +read: : +read: inst-opcount +read: do.data +read: @ +read: ; +read: : +read: impl +read: ( +read: here +read: >r +read: >r +read: ( +read: r@ +read: inst-nextimpl +read: @ +read: , +read: , +read: r@ +read: inst-opcount +read: begin +read: dup +read: while +read: 1 +read: - +read: swap +read: , +read: repeat +read: drop +read: r> +read: inst-nextimpl +read: r> +read: swap +read: ! +read: ; +read: : +read: int +read: &hcd +read: outb! +read: outb! +read: 1 +read: assembled +read: ; +read: 2 +read: inst +read: mov +read: 2 +read: inst +read: movb +read: OP_IMM +read: OP_REG16 +read: :noname +read: &hb8 +read: op1 +read: + +read: outb! +read: op2 +read: outw! +read: ; +read: ' +read: mov +read: impl +read: OP_IMM +read: OP_REG8 +read: :noname +read: &hb0 +read: op1 +read: + +read: outb! +read: op2 +read: outb! +read: ; +read: ' +read: movb +read: impl +read: : +read: :+r +read: anondo +read: >r +read: , +read: OP_REG16 +read: r> +read: does> +read: @ +read: op1 +read: + +read: outb! +read: ; +read: : +read: :+sreg +read: anondo +read: >r +read: , +read: OP_SREG +read: r> +read: does> +read: @ +read: op1 +read: 8 +read: * +read: + +read: outb! +read: ; +read: : +read: modrm +read: ( +read: 8 +read: * +read: | +read: swap +read: 64 +read: * +read: | +read: outb! +read: ; +read: 2 +read: inst +read: add +read: OP_REG16 +read: OP_REG16 +read: :noname +read: &h01 +read: outb! +read: &h03 +read: op1 +read: op2 +read: modrm +read: ; +read: ' +read: add +read: impl +read: 1 +read: inst +read: push +read: &h06 +read: :+sreg +read: ' +read: push +read: impl +read: &h50 +read: :+r +read: ' +read: push +read: impl +read: 1 +read: inst +read: pop +read: &h07 +read: :+sreg +read: ' +read: pop +read: impl +read: &h58 +read: :+r +read: ' +read: pop +read: impl +read: 1 +read: inst +read: dec +read: &h48 +read: :+r +read: ' +read: dec +read: impl +read: : +read: :jumprel +read: here +read: >r +read: 1 +read: LBL_REL +read: | +read: inst +read: :| +read: anondo +read: >r +read: , +read: OP_IMM +read: r> +read: does> +read: @ +read: outb! +read: op1 +read: outb! +read: |; +read: execute +read: r> +read: impl +read: ; +read: &h77 +read: :jumprel +read: ja +read: &h73 +read: :jumprel +read: jae +read: &h72 +read: :jumprel +read: jb +read: &h76 +read: :jumprel +read: jbe +read: &h74 +read: :jumprel +read: je +read: &h7f +read: :jumprel +read: jg +read: &h7d +read: :jumprel +read: jge +read: &h7c +read: :jumprel +read: jl +read: &h7e +read: :jumprel +read: jle +read: &h75 +read: :jumprel +read: jne +read: &h74 +read: :jumprel +read: jz +read: : +read: .EXIT +read: ax +read: &h4c00 +read: | +read: # +read: mov +read: &h21 +read: int +read: ; +read: : +read: d" +read: begin +read: in@ +read: dup +read: [ +read: in@ +read: lit +read: ] +read: != +read: while +read: outb! +read: repeat +read: drop +read: ; read: cs read: push read: \ read: ds read: pop -read: \ -read: \ -read: \ +read: cx +read: 11 +read: # +read: mov +read: :> +read: loop read: :> read: msg read: dx read: msg read: mov +read: dx +read: cx +read: add read: ah read: 9 read: # read: movb read: &h21 read: int -read: \ -read: \ +read: cx +read: dec +read: loop +read: jge read: 0 read: .EXIT read: msg read: <: +read: : +read: nl +read: 13 +read: outb! +read: 10 +read: outb! +read: ; +read: d" +read: nl read: d"