LoginSignup
0
0

More than 1 year has passed since last update.

インタープリタを作る その23

Last updated at Posted at 2021-06-18

概要

インタープリタを作ってみた。
avrインタープリター書いてみた。
定数比較cpiを実装する。

投入するソース

9 > 8 なら1

avr.ldi(16, 0x09)
avr.ldi(17, 0x00)
avr.ldi(18, 0x01)
avr.cpi(16, 0x08)
avr.brcs(2)
avr.out(1, 17)
avr.jmp(9)
avr.out(1, 18)


サンプルコード

    cpi: function(_Rd, K) {
        var Rd = kan2(this.dataspace[_Rd]);
        var SREG = [false, false, false, false, false, false, false, false];
      var c;
        var z;
        if (Rd > K)
        {
            c = true;
        }
        else
        {
            c = false;
        }
        if ((Rd - K) == 0)
        {
            z = true;
        }
        else
        {
            z = false;
        }
        SREG[0] = c;
        SREG[1] = z;
        this.PC++;
        this.dataspace[this.sreg] = SREG;
    },


成果物

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0