ホーム > その他 > TK-85 エミュレータ このエントリーを含む はてなブックマーク 0 users

TK85エミュレータ


ここに TK-85 シミュレータのアプレットが表示されます。

操作方法

操作方法は実物の TK-85 とまったく同じになるように作ったつもりです。
「8、0、0、0、ADDR SET」とボタンを押して、アドレスを 8000h 番地に設定します。TK-85 の RAM 領域は 8000h 番地からなので、ここからプログラムを書き込み始めます。
「3、E、WR/ENT、0、5、WR/ENT、・・・」という具合に、1バイト分ずつ、後で出てくるサンプルプログラムを書き込んでいきましょう。
書き込み終わったら、再び 「8、0、0、0、ADDR SET」を押して 8000h 番地に戻ってきてから「RUN」ボタンを押します。

プログラムを書いている途中で、正しく書き込まれているかどうか確認したくなった場合は、「READ INC」や「READ DEC」を使用して前後の番地に書き込まれている情報を見ることができます。
書き込むプログラムでは、LE D表示やキーボード入力などのモニタサブルーチンをほぼすべて使用することができます。
(ディレイとシリアル入出力を除く。)
モニタプログラムのサービスとして、「REG」キーによりレジスタの内容を確認したり、「MODE」キーによりメモリテストやメモリ転送をしたりできます。
「Step」をチェックしておくと、ステップ実行ができます。
その場合は「CONT」を押して一命令ずつ実行を続けることができます。
HLT命令を実行して、CPU がホールト状態になったら、「MON」を押してモニタに戻ります。
押しても戻らないときは「Reset」を押してください。
アプレット版では、.mic ファイルを読み込む機能は使用できません。
(アプレットのセキュリティの制約によります。)


サンプルプログラム

LED の左端に「05」と表示するプログラムです。
8000h 番地から順に1バイトずつ書き込んでみてください。

3e 05 32 f4 83 cd c0 01 76

サンプルプログラムの解説

最初の 3e は MVI 命令です。オペランドの値(ここでは 05h )をアキュムレータにロードします。
8002h 番地の 32 は STA 命令です。オペランドで示されるアドレス(ここでは 83f4h 番地)にアキュムレータの値をロードします。
つまり、先ほどの 05h という値が、メモリの 83f4h 番地に格納されるわけです。83f4h 番地というのは、TK85 の LED 表示用サブルーチンによって使用されるアドレスで、ここに値を格納しておき、01c0h 番地のサブルーチンを呼び出すと、その値が 16 進数で LED に表示されます。なお、83f4h〜83f7h 番地が、LED の左〜右に対応しています。 8005h 番地の cd は CALL 命令です。オペランドで示されるアドレス(ここでは 01c0h 番地)にあるサブルーチンを呼び出します。
つまり、上で説明した LED 表示用サブルーチンを呼び出して、05 という数字を実際に LED に表示させているわけです。
最後の 8008h 番地の 76 は HLT 命令です。CPU を停止させます。つまり、プログラムの終了です。TK85 でプログラムを作ったら、必ず最後にこの 76 を入れるようにしましょう。

このページに寄せられたコメント

kojiy
2009/08/01
17:07:43 --05:00
なんだかとても懐かしいことろにきてしまいました。
TK80は、大学に入学したころ発売になりました。
ブックマークして、ときどき遊びにきます。
Felix Fung
2010/04/24
11:38:57 --05:00
This TK-85 Simulator is not working well.
3E, 74, CE, 88, 27, 76
The correct answer should be 62H in Accumulator and Carry Flag = 1
Felix Fung
2010/04/25
07:22:54 --05:00
This TK-85 Simulator is not working well.
3E, 74, C6, 88, 27, 76 ( Correction )
The correct answer should be 62H in Accumulator and Carry Flag =
bear.mini
2010/04/25
08:43:30 --05:00
Hi Felix,

Thank you for your comment.

Your program is:

3E 74 MVI A, 0x74 ; A := 0x74
C6 88 ADI A, 0x88 ; A := A + 0x88 ( A will be 0x74 + 0x88 = 0xFC = 252'd )
27 DAA ; A will be BCD format (0x52)
76 HLT

Right?

If so, A (Accumulator) should be 0x52, and CY flag should be 1. (I found that GNUSim8085 set A = 0x62, I can't understand this behavior...)

I ran the program on my simulator, the result was A = 0x02, CY flag had not been changed.
This is not correct. :S

I would like to correct the bug, but I don't have the development environment (the simulator was build with JDK 1.2!! and now it cannot be complied with the latest JDK... unfortunately)

Felix Fung
2010/04/25
10:18:37 --05:00
Hi,

Thanks for your reply.My program is a BCD addition. After daa the correct answer should be
62H in accumulator and this is a BCD value with Carry flag=1, i.e. 74+88=162.
From this simulator the first addition was FBH which should be FCH. After DAA, 01 is in accumulator and the flags are S=1, Z=0,A=1,P=1,C=1which I believe some flags are wrong as well.

I do try the same program with the TK-80 simulator and the ENVI85 simulator and I have the same problem that I cannot get 62H in the accumulator, too. Interesting to point out that when the value in accumulator between FAH and FDH the DAA conversion is wrong.

I am still trying other simulators if I can get the correct answer.
bear.mini
2010/04/25
10:25:52 --05:00
Hi Felix,

Thank you for the explanation. I understood the correct behavior. I salvaged my simulator's code from old hdd, and fixed some errors in order to be compiled with latest Eclipse 3.5.2 & JDK 1.6.

I can be fixing the issue soon.
Felix Fung
2010/04/25
10:30:31 --05:00
bearmini,

I want to point out that when 74H+88H the value in accumulator should be FCH with
CY=1. Please note that this is BCD value, not Hex value, If you add 66H to FCH, you should get 62H in accumulator and CY =1. Again this is a correct BCD value, too.

The result you get from GNUsim8085 is correct

Felix Fung
2010/04/25
10:30:33 --05:00
bearmini,

I want to point out that when 74H+88H the value in accumulator should be FCH with
CY=1. Please note that this is BCD value, not Hex value, If you add 66H to FCH, you should get 62H in accumulator and CY =1. Again this is a correct BCD value, too.

The result you get from GNUsim8085 is correct

bear.mini
2010/04/25
12:10:56 --05:00
Hi,

I fixed the calculation in DAA instruction. Now as result of DAA, A is 62H, flags are 11H (S=0, Z=0, AC=1, P=0, C=1).
I'm not sure the flags are correct... it is 95H (S=1, Z=0, AC=1, P=1, C=1) in GNUsim8085.
Felix Fung
2010/04/26
00:42:23 --05:00
bearmini,

Thanks for your effort and time. After running my programme, I have 61H in accumulator now and the flag is 95H. I assume that S=1, Z=0, A=1, P=1, C=1.

When I simulate the program by hand, it looks like the following:

Acc SZ H P C
CE 74 mvi a, 74h 01110100 xxxxxxxx no change on flags
C6 88 adi 88h 11111100 1000010 bit 7 =1, no carry from bit 3 to bit 4,
no carry from bit 7
27 daa 01100010 0001001 bit 7=0, bit 3 has carry to bit 4,
and carry from bit 7
76 hlt

Please check it out whether it is correct or not.
bear.mini
2010/04/26
08:38:49 --05:00
I have fixed flag operations in my simulator. I believe that Carry and Aux Carry flags are now working more correctly than before. Now bit1 of flag register is fixed '1'. And I've fixed PUSH PSW operation which was sometimes storing wrong A reg value into stack.

Currently I have 62H in A, 13H (S=0, Z=0, AC=1, P=0, C=1) in Flag with your program (3E, 74, C6, 88, 27, 76).

This is still differ from GNUsim8085. As my understanding, all flags S, Z, AC, P, C will be altered to reflect the result of the DAA operation. But it seems like GNUsim8085 does not touch S and P flag. Do you know which is the correct behavior? I want to try it on a real TK-85...
Felix Fung
2010/04/26
10:54:53 --05:00
bearmini, this currently updated version is much better than the one I tried during the lunch break today. I am trying with varies value to fool around this simulator. I still have some wrong answers with the value of the previous program as follows:

mvi a,22h
adi 88h
daa
hlt

Again this is a simple BCD addition which should be 22+88=110 in decimal. And i get 01100000 in accumulator and the flag is 10010010 which is not correct.

I also tried to add 99 to 99, 88 to 88 and the value in accumulator and flags are funny, too.
I am trying to understand where the error occurs. I will keep you informed.

I am still trying to find out from the documents in hand to have better understanding of the flags behaviour. Will let you know.

I used to have a TK-85 but it was gone some time ago. Now I donot have any 8080 or 8085 hard ware to play with. I can only play with various simulators now.
Felix Fung
2010/04/26
11:27:58 --05:00
I found from Toshiba's and NS's datasheet, DAA does affect all flags.
bear.mini
2010/04/26
22:03:18 --05:00
Hi Felix,

Thank you for the valuable information. I'm looking into this issue.
bear.mini
2010/04/26
23:35:05 --05:00
Hi,
I found a bug in the code of DAA instruction and fixed it. Please check it out.
bear.mini
2010/04/26
23:36:34 --05:00
And now the simulator is not consuming CPU so much and working smoothly :)
(Eliminated busy loop)
Felix Fung
2010/04/27
05:13:59 --05:00
bearmini, I appreciate your great effort and contribution to the community. I will keep trying the simulator and keep you informed if I have any question.
Felix Fung
2010/04/29
00:29:44 --05:00
This simulator is great. Do you have any plan to add some utility to it? Such as loading an existing hex file directly into the memory or save it from memory to the disk like the tape function? How about making it available for download?
Felix Fung
2010/04/30
23:20:44 --05:00
bearmini, check this out
mvi a,23h
mvi b,46h
stc
adc b
hlt

The parity flag is not working well.
Felix Fung
2010/05/01
03:01:08 --05:00
Sorry, my mistake, I forgot to reset prior to execution.
Felix Fung
2010/05/02
05:19:44 --05:00
bearmini, please check this out:

xra a ; A=0
sui 1; A=FF=-1
adi a; A=0
daa ; A=66
hlt

This is not the answer what we want.
bear.mini
2010/05/07
02:01:25 --05:00
Hi Felix,

Sorry for this late reply. I had days off for a week :)

First, I agree with you that this emulator should have save/load function. I tried to implement such function when I originally wrote this emulator (10+ years ago!), but Java Applet has some restrictions to access local files. And I didn't have sufficient disk space on the server to accept file uploading.
I will make a function to load a bunch of binary code (in hex format) or mnemonic list (to be assembled) using textarea.

Second, the program you specified above, what is your expectation? After execution of SUI instruction, the accumulator became 0xFF, this is not BCD format. So the result of DAA does not make any sense, I think.
GNUsim8085 also answers the same value (0x66).
Felix Fung
2010/05/08
05:44:24 --05:00
Hi bearmini,

How are youdoing? Thanks for your reply. I am looking forward to the new version of the simulator.

I agree with your point that FFH is not a BCD value. I was trying if a minus number can be added to a BCD value.

I can get the correct answer from the TK-80 simulator with the following modified version:

xra a ; A=0
sui 1; A=FFH
daa ; A=99
adi 1; A=9AH
daa ; A=00, Carry Flag=1
hlt

I carefully examined the block diagram of the NEC UPD 8080A block diagram and found that there is another flag :SU Flag, which is for DAA after subtraction. Is that only applied for NEC 8080A, not for 8085 ?
bear.mini
2010/05/09
01:59:28 --05:00
Hi Felix,
My vacation was pretty nice, thank you.

TK-85 is using NEC uPD8085A, it has SU Flag as same as uPD8080A. Then my simulator also emulates the SU flag and the behavior of DAA after subtraction. I think the flag and the behavior are not implemented in Intel's original 8080/8085.

Felix Fung
2010/05/22
02:59:10 --05:00
Hi, bearmini, You always refer to GNUSIM8085 when I report the DAA bugs to you. I have recently downloaded the simulator and try it. I found that there was even more bugs than what you can think about. For example, 99+1=A0 after DAA adjustment.
bear.mini
2010/05/23
17:17:08 --05:00
Hi Felix,
Thank you for the information. You mean GNUsim8085 cannot be a reference implementation for me especially about DAA, right?
You and I should commit to fixing GNUsim8085 DAA :)

BTW, I published my dirty code of this emulator at github.
http://github.com/bearmini/Tk85Simulator

It would be appreciated if you'll kindly contribute any point on this project.
Felix Fung
2010/05/31
08:34:05 --05:00
Hi bearmini,

As a matter of fact, I have reported the DAA and they confirmed to correct it, may be in the next upgrade.

Besides, I love to do something for this TK85 Simulator project but I have to confess that I am not familiarized with the Java programming language. I have downloaded your code and try to learn something from you.

コメントしてください:
お名前: (半角/全角問わず 16 文字まで)
コメント:
(no HTML)
確認:
このテキストボックスに "確認" の 2 文字を書くと投稿できるようになります。
投稿ボタンが自動的に有効にならない場合は、ここをクリックしてください
これは、自動的にスパムコメントを書き込もうとする悪意をもったプログラムと、 そうでないあなたを識別するためのものです。お手数をおかけしますがよろしくお願いします。 また、ブラウザによっては対応していない場合があるかも知れません。IE 7 と Firefox で動作確認を行いました。

このページに寄せられたトラックバック

このページはまだトラックバックを受信していません。

このページへのトラックバック Ping URL:
http://bearmini.net/trackback.aspx?~/misc/tk85/default.aspx

このサイトの上位人気記事