1
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?

windowsでiverilog その169

Last updated at Posted at 2024-12-19

概要 

windowsでiverilogやってみた。
自作cpu、見つけたので、調査してみた。
練習問題やってみた。
構想編

練習問題

elixirでzktcのアセンブラが動くインタープリタを書け。
fizzbuzzを求よ。

方針

modが無いsubでやる。
divが無いsubでやる。
x7を仮想コンソールとする。
むずい。

仮想コードで書いてみる。

  x1 = 0
loop:
  x1 = x1 + 1
  x2 = x1
  x3 = x1
  x4 = x1
loop0:
  x2 = x2 - 15
  if x2 > 15 jmp loop0
loop1:
  x3 = x3 - 5
  if x2 > 5 jmp loop1
loop2:
  x4 = x4 - 3
  if x2 > 3 jmp loop1
  if x2 != 0 jmp tugi1
  print "fizzbuzz"
tugi1:
  if x3 != 0 jmp tugi2
  print "buzz"
tugi2:
  if x4 != 0 jmp tugi3
  print "fizz"
tugi3:
  x5 = 0
  x6 = x1
loop3:
  if x6 < 10 jmp loop4
  x5 = x5 + 1
  x6 = x6 - 10
  jmp loop3
loop4:
  x7 = 48
  x7 = x7 + x5
  x5 = 0
  x6 = x1
loop5:
  if x6 < 10 jmp loop6
  x5 = x5 + 1
  x6 = x6 - 10
  jmp loop3
loop6:
  x7 = 48
  x7 = x7 + x6
  if x1 < 99 jmp loop
bye:
  ret

以上。

1
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
1
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?