forked from r0nk/simplecpu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.html
106 lines (102 loc) · 2.74 KB
/
code.html
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<head>
<link rel="stylesheet" type="text/css" href="styles/style.css">
</head>
<html>
<body>
<div class="wrap">
<ul>
<li><a href="Binary.html"><b>SimpleCPU.com</b></a> </li>
<li><a href="about.html">about</a></li>
</ul><br>
<div class="content">
<head>
<style>
table{
border:1px solid black;
}
</style>
</head>
Cool, now we have a basic calculator. How can we turn this up to eleven<br>
and make a computer?<br>
<br>
Code.<br>
<br>
Now that you know what data is, code is easy to explain. It's just data.<br>
The reason why it's different than other data, however, is because the CPU<br>
interprets it as <i>instructions.</i><br>
<br>
Let's say we wanted the computer to do math, we could use a system like;<br>
<br>
<table>
<tr>
<td><b>instruction</b></td>
<td></td>
<td><b>code</b></td>
<tr>
<td><i>"add a number to another number"</i></td>
<td> </td>
<td>00000001</td>
</tr>
<tr>
<td><i>"subtract a number from another number"</i></td>
<td> </td>
<td>00000010</td>
</tr>
</table>
<br>
With this, we can set what logic gates are being used based on data.<br>
<br>
Now, real quick, memory is organized in a computer by something called<br>
memory addresses, which basically allow the CPU to ask for memory at a<br>
certain location. Generally speaking the addresses are sized by "bytes"<br>
which is just another word for "eight bits". So if we wanted to access<br>
memory location five or whatever we could store that as '00000101'.<br>
<br>
Lets go back and add some more to our table:<br>
<br>
<table>
<tr>
<td><i>"move this data into some location"</i></td>
<td> </td>
<td>00000011</td>
<tr>
</table>
<br>
Cool, now we can say something like:<br>
<br>
"add the number at location #5 in memory to the other number at <br>
location #7 in memory."<br>
<br>
By breaking it down into:<br>
<br>
(add) (memory address #5) (memory address #7)<br>
<br>
Which is really just:<br>
<br>
00000001 00000101 00000111<br>
<br>
Pretty sweet right?<br>
<br>
<div class="center">
<a href="adder.html">
<img src="images/Left.png" alt="<left" style="width:50px;height:80px;" align="middle">
</a>
6/8
<a href="InstructionPointer.html">
<img src="images/Right.png" alt="next>" style="width:50px;height:80px;" align="middle">
</a>
</div>
<br>
</div>
</div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-55886101-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>