0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ilasmでstack machine その7

Last updated at Posted at 2020-01-07

概要

ilasmでstack machineやってみた。
俺言語、コンパイラを考えてみた。
3段階です。
1回目をハンドコンパイルしてみた。

10 a=1

    pushi   1
    set     a

30 b=a%15

loop:
    get     a
    pushi   15
    %
    

40 #=b=0*120

    if      fizzbuzz

50 b=a%5

    get     a
    pushi   5
    %

60 #=b=0*140

    if      buzz

70 b=a%3

    get     a
    pushi   3
    %

80 #=b=0*160

   if      fizz

90 ?=a

    get     a
    call    printi

100 #=a<100*30

tugi:
    get     a
    pushi   100
    if<     loop

110 #=255

    jp      ext

120 ?="fizzbuzz "

fizzbuzz:
    push    "fizzbuzz"
    call    prints

130 #=180

jp      tugi

140 ?="buzz "

buzz:
    push    "buzz"
    call    prints

150 #=180

    jp      tugi

160 ?="fizz "

fizz:
    push    "fizz"
    call    prints

180 a=a+1

tugi:
    get     a
    pushi   1
    +
    set     a

190 #=30

    jp      loop

ext:
    ret

以上。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?