diff --git a/asm.img b/asm.img index e59ce0e..74b4308 100755 Binary files a/asm.img and b/asm.img differ 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 2324115..22597a6 100755 Binary files a/out.com and b/out.com differ 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"