VOOZH about

URL: https://qiita.com/ohisama@github/items/dd8c2551f22c7219b90f

⇱ アセンブラーを作る。 #九九 - Qiita


👁 Image
1

Go to list of users who liked

0

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 5 years have passed since last update.

@ohisama@github

アセンブラーを作る。

1
Posted at

概要

アセンブラーを作る。
俺cpuで動く。

ソース

九九

 push 1
 set a
 push 1
 set b
label30:
 get a
 get b
 *
 set c
 get c
 push 10
 /
 push 48
 +
 out
 get c
 push 10
 %
 push 48
 +
 out
 push 32
 out
 push ','
 out
 push 32
 out
 get a
 push 1
 +
 set a
 get a
 push 10
 <
 jz label30
 push 10
 out
 get b
 push 1
 +
 set b
 push 1
 set a
 get b
 push 10
 <
 jz label30
bye:
 jmp bye
a:
 0x0000
b:
 0x0000
c:
 0x0000
 

コンパイル結果

mem[12'h000] = 16'h1001;// push 1
mem[12'h001] = 16'h302f;// set a
mem[12'h002] = 16'h1001;// push 1
mem[12'h003] = 16'h3030;// set b
mem[12'h004] = 16'h202f;//label30: get a
mem[12'h005] = 16'h2030;// get b
mem[12'h006] = 16'hf004;// *
mem[12'h007] = 16'h3031;// set c
mem[12'h008] = 16'h2031;// get c
mem[12'h009] = 16'h100a;// push 10
mem[12'h00a] = 16'hf005;// /
mem[12'h00b] = 16'h1030;// push 48
mem[12'h00c] = 16'hf000;// +
mem[12'h00d] = 16'he000;// out
mem[12'h00e] = 16'h2031;// get c
mem[12'h00f] = 16'h100a;// push 10
mem[12'h010] = 16'hf006;// %
mem[12'h011] = 16'h1030;// push 48
mem[12'h012] = 16'hf000;// +
mem[12'h013] = 16'he000;// out
mem[12'h014] = 16'h1020;// push 32
mem[12'h015] = 16'he000;// out
mem[12'h016] = 16'h102c;// push ','
mem[12'h017] = 16'he000;// out
mem[12'h018] = 16'h1020;// push 32
mem[12'h019] = 16'he000;// out
mem[12'h01a] = 16'h202f;// get a
mem[12'h01b] = 16'h1001;// push 1
mem[12'h01c] = 16'hf000;// +
mem[12'h01d] = 16'h302f;// set a
mem[12'h01e] = 16'h202f;// get a
mem[12'h01f] = 16'h100a;// push 10
mem[12'h020] = 16'hf001;// <
mem[12'h021] = 16'h5004;// jz label30
mem[12'h022] = 16'h100a;// push 10
mem[12'h023] = 16'he000;// out
mem[12'h024] = 16'h2030;// get b
mem[12'h025] = 16'h1001;// push 1
mem[12'h026] = 16'hf000;// +
mem[12'h027] = 16'h3030;// set b
mem[12'h028] = 16'h1001;// push 1
mem[12'h029] = 16'h302f;// set a
mem[12'h02a] = 16'h2030;// get b
mem[12'h02b] = 16'h100a;// push 10
mem[12'h02c] = 16'hf001;// <
mem[12'h02d] = 16'h5004;// jz label30
mem[12'h02e] = 16'h402e;//bye: jmp bye
mem[12'h02f] = 16'h0000;//a: 0x0000
mem[12'h030] = 16'h0000;//b: 0x0000
mem[12'h031] = 16'h0000;//c: 0x0000


成果物

以上。

1

Go to list of users who liked

0
0

Go to list of comments

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

Go to list of users who liked

0