-
Notifications
You must be signed in to change notification settings - Fork 35
/
code.html
98 lines (94 loc) · 3.01 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
<!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>
</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 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. However, code is different than other data because the CPU interprets code as <i>instructions.</i><br>
<br>
Let's say we wanted the computer to do math, we could come up with 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>
Then, we could build a machine with logic gates so that these inputs would cause adders or subtractors to be used.<br>
<br>
Now, real quick, memory is organized in a computer by something called memory addresses, which basically allow the CPU to ask for memory at a certain location. Generally speaking the addresses are sized by "bytes" which is just another word for "eight bits". So if we wanted to access memory location five or whatever we could store that as '00000101'.
<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>
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>
<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>
<font size=2><a href="https://www.github.com/r0nk/simplecpu">source code</a> - <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=AVU3S9FB4BMCY&lc=US&item_name=Simple%20CPU¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted">donate</a> - <a href="mailto:r00nk@simplecpu.com">contact</a></font>
</body>
</html>