-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstruction.js
87 lines (83 loc) · 2.3 KB
/
instruction.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// TI calculator simulator
// Ken Shirriff, http://righto.com/ti
// Based on patent US3934233
//
// This file shows information on the currently-executing instruction.
var Instruction = function(elem, model) {
var flagops = [
'NOP: No-op',
'WAITDK: Wait for Display Key, then branch',
'WAITNO: Wait for key pressed, then branch',
'SFB: Set flag B bits',
'SFA: Set flag A bits',
'SYNC: Sync to start of key scan',
'SCAN: Scan keys; set condition if pressed',
'ZFB: Zero flag B bits',
'ZFA: Zero flag A bits',
'TFB: Test flag B bits',
'TFA: Test flag A bits',
'FFB: Flip flag B bits',
'FFA: Flip flag A bits',
'CF: Compare A and B flag bits',
'NOP: No-op',
'EXF: Exchange A and B flag bits'];
var aluops = [
'AABA: A+B⇒A',
'AAKA: A+K⇒A',
'AAKC: A+K⇒C',
'ABOA: B⇒A',
'ABOC: B⇒C',
'ACKA: C+K⇒A',
'ACKB: C+K⇒B',
'SABA: A-B⇒A',
'SABC: A-B⇒C',
'SAKA: A-K⇒A',
'SCBC: C-B⇒C',
'SCKC: C-K⇒C',
'CAB: Compare A and B',
'CAK: Compare A and K',
'CCB: Compare C and B',
'CCK: Compare C and K',
'AKA: K⇒A',
'AKB: K⇒B',
'AKC: K⇒C',
'EXAB: Exchange A and B',
'SLLA: Shift A left',
'SLLB: Shift B left',
'SLLC: Shift C left',
'SRLA: Shift A right',
'SRLB: Shift B right',
'SRLC: Shift C right',
'AKCN: A+K⇒A one cycle until key press',
'AAKAH: A+K⇒A (hex)',
'SAKAH: A-K⇒A (hex)',
'ACKC: C+K⇒C'];
this.update = function() {
if (model.running) {
// Only display instruction when stepping
elem.html('');
return;
}
var instrCode = model.rom[model.address];
var classBits = instrCode >> 9;
var opcode = (instrCode >> 4) & 0x1f;
if (classBits == 0) {
elem.html("Bxx: Branch if condition 0");
} else if (classBits == 1) {
elem.html("Bxx: Branch if condition 1");
} else if (classBits == 3) {
// Register instruction
elem.html(aluops[opcode]);
} else {
// classBits == 2
if (opcode >= 16) {
// Flag instruction
elem.html(flagops[opcode - 16]);
} else if (opcode >= 8) {
elem.html("BKP: Branch if KP key down");
} else {
elem.html("BKO: Branch if KO key down");
}
}
};
};