1 00:00:01,200 --> 00:00:08,020 So, this talk regards my translation of the classic reverse engineering work of Paul Corby and Sebastian Lalonde 2 00:00:08,720 --> 00:00:12,500 in a book they called Voyage au Centre de l'HP28C-S. 3 00:00:13,360 --> 00:00:16,560 They took apart the Hewlett-Packard 28 graphing calculator, 4 00:00:17,260 --> 00:00:23,500 which is the predecessor to the 48, the 49, and the 50 that all RPN junkies use, 5 00:00:24,140 --> 00:00:26,240 and they documented everything about it. 6 00:00:26,240 --> 00:00:32,060 So, they started with nothing more than a physical unit and documentation for the HP17, 7 00:00:32,540 --> 00:00:37,800 which was an unrelated machine that happened to use the same CPU. 8 00:00:39,040 --> 00:00:43,080 And from that, they dumped out the memory through a piezo buzzer. 9 00:00:44,080 --> 00:00:48,120 So, they dumped ones and zeros out, one full second of buzzing for a one, 10 00:00:48,200 --> 00:00:53,680 one full second of silence for a zero, recorded this to tape, fed the tapes into an Apple IIe, 11 00:00:54,600 --> 00:00:55,980 and then with this memory dump, 12 00:00:56,000 --> 00:00:56,220 they started to record the data for the HP17, 13 00:00:56,220 --> 00:00:57,840 and then they started looking through it and trying to recognize things. 14 00:00:58,120 --> 00:01:04,020 So, for example, they'd look for 314159, and that would be pi. 15 00:01:04,700 --> 00:01:09,120 And then seeing pi, they could try and go backward and figure out how all floats work. 16 00:01:10,400 --> 00:01:18,200 And then they began to inject things into memory and create new objects and mess with the operating system. 17 00:01:19,220 --> 00:01:24,860 And they documented this perfectly in a long and very technically detailed book. 18 00:01:25,260 --> 00:01:26,200 It's divided into two parts. 19 00:01:26,200 --> 00:01:27,000 It's divided into three sections. 20 00:01:27,420 --> 00:01:34,480 The first describes the software within the computer, or the HP28 graphing calculator, rather. 21 00:01:35,080 --> 00:01:41,340 And this software is described such that you can write your own machine language code. 22 00:01:42,000 --> 00:01:45,980 But the problem comes up that there's no assembler available for the platform. 23 00:01:46,480 --> 00:01:51,020 So, the appendices contain tables, and you can actually, using pen and paper, 24 00:01:51,640 --> 00:01:53,400 write your assembly language in the left column, 25 00:01:53,560 --> 00:01:55,700 and then you use the tables to convert everything over, 26 00:01:56,200 --> 00:02:00,100 to the individual hexadecimal entries which form the program. 27 00:02:01,380 --> 00:02:04,440 So, I'll be discussing the contents of the book. 28 00:02:04,880 --> 00:02:09,340 But because it's so technically dated, being like a hack that was performed 18 years ago, 29 00:02:09,860 --> 00:02:12,500 I'm focusing on the oddity of the hardware, 30 00:02:13,340 --> 00:02:16,320 and how impressive it is that they came up with all of this, 31 00:02:16,940 --> 00:02:19,680 using nothing more than an Apple IIe and a bit of ingenuity. 32 00:02:21,980 --> 00:02:25,020 Disclaimer, this is not my original work. 33 00:02:25,120 --> 00:02:26,160 All I did was translate. 34 00:02:26,200 --> 00:02:28,620 And my French is not terribly good. 35 00:02:30,260 --> 00:02:32,320 So, this is the HP28. 36 00:02:33,200 --> 00:02:38,480 It is a 4-bit architecture, with registers as wide as 64 bits. 37 00:02:38,840 --> 00:02:42,800 It's capable of doing algebra and calculus, symbolically. 38 00:02:43,420 --> 00:02:44,840 And it was released in 1986. 39 00:02:48,500 --> 00:02:52,960 Within software, we'll be discussing how objects work within the operating system. 40 00:02:53,100 --> 00:02:55,180 You don't have C compilers. 41 00:02:55,180 --> 00:02:58,100 So, things aren't done in terms of functions and returns. 42 00:02:58,720 --> 00:03:02,880 And they're not held as primitives within registers wherever possible. 43 00:03:03,100 --> 00:03:07,440 You have an entry prefix, and some other stuff that we'll describe. 44 00:03:08,240 --> 00:03:10,260 Then, I.O. has to be performed. 45 00:03:11,460 --> 00:03:14,200 And we'll discuss how that's implemented in the hardware, 46 00:03:14,400 --> 00:03:18,880 followed by the contents of RAM, and different tables that are used in RAM. 47 00:03:19,080 --> 00:03:21,160 How video processing works. 48 00:03:21,480 --> 00:03:23,580 This was before video cards were available. 49 00:03:23,660 --> 00:03:24,140 And... 50 00:03:25,420 --> 00:03:29,280 As there was no assembler openly available for it, 51 00:03:29,340 --> 00:03:31,840 we'll discuss how they initially broke into machine language. 52 00:03:31,920 --> 00:03:34,520 How they first wrote programs for it, 53 00:03:34,560 --> 00:03:37,740 and how they instruct the reader of the book to write programs for it. 54 00:03:38,820 --> 00:03:43,440 Then, there are suggestions for further discoveries and resources. 55 00:03:45,040 --> 00:03:51,560 There are three models, the 1BB and the 1CC, which are both labeled as the 28C. 56 00:03:52,860 --> 00:03:55,160 These differ not in hardware, but in firmware. 57 00:03:56,400 --> 00:03:58,560 So, entry points are different. 58 00:03:59,300 --> 00:04:06,060 You had the firmware compiled at HP, using whatever tools were private to that organization 59 00:04:06,060 --> 00:04:07,980 and unavailable to the authors of this book. 60 00:04:08,360 --> 00:04:12,940 So, in a given compile, you wind up with subroutines at particular addresses. 61 00:04:13,420 --> 00:04:16,860 They have to be found for every different firmware. 62 00:04:18,120 --> 00:04:22,380 Otherwise, they'll jump to a location that means something entirely different from what you expect, 63 00:04:22,480 --> 00:04:23,420 and your program crashes. 64 00:04:25,460 --> 00:04:27,860 The 28S only had a single revision. 65 00:04:28,040 --> 00:04:34,080 So, if you have a 28S, it's much easier to figure out which opcodes to type in. 66 00:04:34,940 --> 00:04:38,160 It used the HP Saturn, which was a chip that they designed in-house, 67 00:04:39,380 --> 00:04:41,640 and it was documented in the HP 71B. 68 00:04:42,320 --> 00:04:47,600 The 71B was interesting because they published their complete internal documentation for it. 69 00:04:48,340 --> 00:04:53,720 You can download from the HP Museum every single page of documentation 70 00:04:53,720 --> 00:04:55,900 that the original designers had access to. 71 00:04:56,760 --> 00:04:58,260 It has thousands of pages. 72 00:04:58,460 --> 00:05:00,020 It has schematic diagrams. 73 00:05:00,260 --> 00:05:02,920 It has the source code to the firmware of the 71B. 74 00:05:03,220 --> 00:05:07,480 It has all of this work, and it's freely published. 75 00:05:08,480 --> 00:05:11,000 Similar documents for the HP 28 are unavailable. 76 00:05:11,360 --> 00:05:12,620 I'm trying to find them. 77 00:05:12,680 --> 00:05:15,660 If you have any contacts with the Hewlett-Packard Archival Department, 78 00:05:16,000 --> 00:05:17,720 I would appreciate being put in touch. 79 00:05:19,180 --> 00:05:21,840 It's also interesting because it's nibble-wise a little Indian. 80 00:05:23,080 --> 00:05:24,960 So, instead of having... 81 00:05:25,980 --> 00:05:28,120 On a PC, you have bite-wise little Indians, 82 00:05:28,240 --> 00:05:29,660 so all of the bytes are backward, 83 00:05:29,880 --> 00:05:34,300 and to read it, you have to take those bytes and then flip them around in pairs. 84 00:05:35,360 --> 00:05:39,260 So, ABCD would become CDAB. 85 00:05:40,540 --> 00:05:44,040 Here, it's written backward as you would read it on paper in hexadecimal. 86 00:05:46,500 --> 00:05:49,700 You have four different memory layouts, 87 00:05:49,840 --> 00:05:51,820 even though you only have two different major revisions. 88 00:05:51,840 --> 00:05:58,640 So, they loaded the same firmware onto two units which defer slightly in hardware. 89 00:05:59,040 --> 00:06:00,620 So, the entry points are the same, 90 00:06:02,080 --> 00:06:04,520 but you can have extended memory. 91 00:06:05,620 --> 00:06:08,140 Among the 28C, the RAM grows. 92 00:06:08,880 --> 00:06:10,960 Everything else remains at rather fixed addresses. 93 00:06:11,440 --> 00:06:15,700 But with the 28S, there are many features that change. 94 00:06:15,840 --> 00:06:18,320 The row waveform driver no longer exists. 95 00:06:18,620 --> 00:06:21,820 The screen timer was moved from near the bottom of the screen. 96 00:06:21,820 --> 00:06:22,740 There's a lot of memory to near the top. 97 00:06:23,040 --> 00:06:28,300 And no program originally designed for any of the 28Cs would ever work on the 28S. 98 00:06:29,840 --> 00:06:34,400 The registers are far from the homogenous 32 general-purpose ones 99 00:06:34,400 --> 00:06:37,460 that we now expect from working with RISC systems. 100 00:06:39,400 --> 00:06:47,660 So, you've got ones of 12, 16, 1, 4, 16, 20, 64 bits in width. 101 00:06:49,000 --> 00:06:51,920 So, for example, you have a return stack, 102 00:06:52,180 --> 00:06:56,100 which is 8 levels deep and 20 bits wide. 103 00:06:56,460 --> 00:06:58,220 The address space is 20 bits. 104 00:06:58,380 --> 00:07:00,680 20 is not evenly divisible by 8. 105 00:07:00,820 --> 00:07:05,960 So, every pointer on this system is not 8 bytes as you would expect, 106 00:07:06,100 --> 00:07:08,180 but instead it's 5 nibbles. 107 00:07:09,740 --> 00:07:14,980 You've got an entire register just for carrying that contains nothing else. 108 00:07:15,200 --> 00:07:17,140 And then you have separate hardware 109 00:07:17,140 --> 00:07:18,880 and software status registers. 110 00:07:19,640 --> 00:07:21,440 You have safeguard registers, 111 00:07:21,740 --> 00:07:24,440 which you can copy data into and out of, 112 00:07:24,540 --> 00:07:25,740 but you cannot do anything else with. 113 00:07:26,060 --> 00:07:29,500 So, you can't make these the source or destination of an addition. 114 00:07:30,520 --> 00:07:36,180 They're only used for backing things up before a quick function call or subroutine. 115 00:07:37,400 --> 00:07:40,040 All pointers are 20 bits wide, of course. 116 00:07:40,120 --> 00:07:43,780 That's the address space. 117 00:07:45,200 --> 00:07:48,760 So, of course, everything is in nibbles or quartets, 118 00:07:48,760 --> 00:07:51,600 as it's been translated, 119 00:07:51,820 --> 00:07:53,220 quartet being the more formal term. 120 00:07:54,840 --> 00:07:57,560 So, as a byte goes from 0 to 255, 121 00:07:57,600 --> 00:08:00,040 these nibbles go from 0 to F, 122 00:08:00,780 --> 00:08:02,740 or often they'll go from 0 to 9. 123 00:08:02,780 --> 00:08:03,940 To ease debugging, 124 00:08:04,660 --> 00:08:08,480 they use binary-coded decimal in hardware. 125 00:08:09,740 --> 00:08:12,380 All floats are held in binary-coded decimal 126 00:08:12,380 --> 00:08:14,100 so that it makes the same rounding mistakes 127 00:08:14,100 --> 00:08:15,580 that you would with pen and paper. 128 00:08:16,860 --> 00:08:19,180 And that way, when you calculate it with the calculator 129 00:08:19,180 --> 00:08:20,420 and you do it again on pen and paper, 130 00:08:20,500 --> 00:08:21,580 you wind up with the same value. 131 00:08:22,340 --> 00:08:24,440 You have no problem representing one-fifth, 132 00:08:24,520 --> 00:08:29,620 which is very difficult to represent in binary float. 133 00:08:31,060 --> 00:08:32,640 And it's nibble-wise little-endian. 134 00:08:33,520 --> 00:08:35,340 So, for the number 1, 2, 3, 4, 135 00:08:36,140 --> 00:08:40,160 we find that in big-endian, it would read just as it's written. 136 00:08:40,260 --> 00:08:41,820 This would be on, say, a PowerPC machine. 137 00:08:43,180 --> 00:08:46,300 Now, little-endian on, say, an MSP430, 138 00:08:46,440 --> 00:08:48,120 in which I do most of my work, 139 00:08:48,220 --> 00:08:53,280 the less significant byte comes first, 140 00:08:53,800 --> 00:08:55,240 followed by the more significant one. 141 00:08:55,520 --> 00:08:56,600 So, if you have a pointer 142 00:08:57,340 --> 00:09:00,400 and you only want the least significant byte, 143 00:09:00,560 --> 00:09:03,000 so you want to find it modulus 256, 144 00:09:03,900 --> 00:09:06,200 all you have to do is pretend that it's a pointer to a byte. 145 00:09:07,820 --> 00:09:11,460 But on the HP28, they went one step further, 146 00:09:11,460 --> 00:09:14,340 and it's nibble-wise little-endian, 147 00:09:14,400 --> 00:09:16,500 so it's written exactly backward 148 00:09:16,500 --> 00:09:19,460 of how you would write it as a human being. 149 00:09:21,440 --> 00:09:23,200 Now, every object has a prologue, 150 00:09:23,200 --> 00:09:25,360 which is five nibbles and specifies the type. 151 00:09:25,800 --> 00:09:29,580 The actual values in this table aren't important to know, 152 00:09:29,700 --> 00:09:33,340 but it's important that they all begin with similar prefix. 153 00:09:33,520 --> 00:09:36,580 You have 02991, 02933. 154 00:09:37,220 --> 00:09:40,400 And these define different objects within the system. 155 00:09:41,700 --> 00:09:44,620 It's not object-oriented in the modern sense of inheritance, 156 00:09:44,980 --> 00:09:49,940 but every value on the stack has this prefix code, 157 00:09:50,100 --> 00:09:51,760 has a type specified with it, 158 00:09:51,880 --> 00:09:53,160 and this is all carried together. 159 00:09:53,300 --> 00:09:54,340 If you store it to a variable, 160 00:09:54,480 --> 00:09:56,180 you are applying a type to that variable, 161 00:09:56,300 --> 00:09:57,220 and that type carries over. 162 00:09:59,280 --> 00:10:02,540 Types include short integers, reals, extended reals, 163 00:10:02,540 --> 00:10:04,560 complex numbers, extended complex numbers, 164 00:10:05,720 --> 00:10:09,220 arrays, two types which the authors couldn't discern 165 00:10:09,220 --> 00:10:11,440 but found by disassembling them. 166 00:10:11,460 --> 00:10:17,060 You can describe an algebraic expression as an object 167 00:10:17,060 --> 00:10:18,660 and then run it through the stack 168 00:10:18,660 --> 00:10:20,820 and add to it and subtract from it 169 00:10:20,820 --> 00:10:22,680 just as you would an integer 170 00:10:22,680 --> 00:10:24,300 by calling the same routines. 171 00:10:24,480 --> 00:10:25,500 So you can call an add routine 172 00:10:25,500 --> 00:10:27,860 and not know what the inputs are. 173 00:10:30,080 --> 00:10:32,460 The prefix is also used to imply the length. 174 00:10:33,180 --> 00:10:35,380 So given an entry point of an object, 175 00:10:35,600 --> 00:10:37,000 you don't know where it ends 176 00:10:37,000 --> 00:10:38,600 until you use a lookup table 177 00:10:39,140 --> 00:10:40,100 with the... 178 00:10:42,060 --> 00:10:43,340 the object prolog. 179 00:10:44,000 --> 00:10:47,420 Now short integers prolog is 0, 2, 9, 1, 1. 180 00:10:48,520 --> 00:10:50,120 This is of course written backward 181 00:10:50,120 --> 00:10:52,540 because we're nibble-wise Lelandian. 182 00:10:53,740 --> 00:10:56,520 So you find 1, 1, 9, 2, 0 183 00:10:57,780 --> 00:10:59,040 as the prefix, 184 00:10:59,500 --> 00:11:00,860 and then the number follows. 185 00:11:01,320 --> 00:11:03,260 So in the case of 0, it's all zeros. 186 00:11:03,580 --> 00:11:05,400 But in the case of 1, 2, 3, 4, 5, 187 00:11:06,460 --> 00:11:08,620 it's of course written nibble-wise and backward. 188 00:11:10,120 --> 00:11:11,160 A real number 189 00:11:11,460 --> 00:11:13,000 is expressed, of course, 190 00:11:13,040 --> 00:11:15,600 with an exponent, a mantissa, and a sign. 191 00:11:16,460 --> 00:11:17,980 So we have the prolog, 192 00:11:18,180 --> 00:11:19,380 which of course is backward, 193 00:11:20,020 --> 00:11:21,980 followed by an exponent, say 5. 194 00:11:22,220 --> 00:11:25,180 This has to be padded to fit the specified width. 195 00:11:25,420 --> 00:11:27,060 So we find 5, 0, 0. 196 00:11:27,820 --> 00:11:29,840 The mantissa is pi, 197 00:11:30,000 --> 00:11:31,740 so 3.14159. 198 00:11:32,800 --> 00:11:34,480 That's actually rendered backward 199 00:11:34,480 --> 00:11:36,620 and in binary coded decimal. 200 00:11:36,880 --> 00:11:38,180 So you... 201 00:11:38,740 --> 00:11:40,580 looking in memory without... 202 00:11:41,460 --> 00:11:43,020 doing conversions will recognize 203 00:11:43,020 --> 00:11:44,120 the same constant 204 00:11:44,120 --> 00:11:46,140 that you learned in elementary school. 205 00:11:48,140 --> 00:11:50,000 And then this is followed by a sign, 206 00:11:50,200 --> 00:11:52,200 which even though it could possibly 207 00:11:52,200 --> 00:11:53,800 have one of 16 values, 208 00:11:53,880 --> 00:11:55,460 is either a 0 or a 1, 209 00:11:55,680 --> 00:11:56,980 0 being positive. 210 00:11:58,860 --> 00:12:01,000 Now all operations in this calculator 211 00:12:01,000 --> 00:12:02,760 are performed using reverse Polish notation. 212 00:12:03,500 --> 00:12:06,900 So instead of typing in 3 plus 5 times 6 213 00:12:06,900 --> 00:12:08,980 and then having the order of operations 214 00:12:10,220 --> 00:12:11,460 cause the multiplication 215 00:12:11,460 --> 00:12:13,680 to be performed before the addition, 216 00:12:14,820 --> 00:12:17,140 instead everything occurs as it's seen. 217 00:12:17,280 --> 00:12:19,760 Wherever you see an integer 218 00:12:19,760 --> 00:12:21,080 or a float or whatever, 219 00:12:21,760 --> 00:12:22,800 a constant value, 220 00:12:22,900 --> 00:12:24,160 that is pushed onto the stack. 221 00:12:24,560 --> 00:12:25,800 Whenever you see an operator, 222 00:12:26,300 --> 00:12:28,360 its inputs are popped off of the stack, 223 00:12:28,580 --> 00:12:29,740 run through the operator, 224 00:12:29,940 --> 00:12:31,220 and then the result is pushed back. 225 00:12:32,380 --> 00:12:34,300 This takes a long time to get used to, 226 00:12:35,160 --> 00:12:36,520 but once you're used to it, 227 00:12:36,560 --> 00:12:37,480 you'll never want to go back, 228 00:12:37,480 --> 00:12:38,840 because it allows you to 229 00:12:39,400 --> 00:12:40,860 work with a series of numbers 230 00:12:41,480 --> 00:12:42,540 and flip them around, 231 00:12:42,660 --> 00:12:43,420 and instead of seeing 232 00:12:43,420 --> 00:12:45,620 a complicated version history 233 00:12:45,620 --> 00:12:47,380 of what you know you typed in 234 00:12:47,380 --> 00:12:49,100 above the command line, 235 00:12:49,340 --> 00:12:51,040 you'll instead see the values 236 00:12:51,040 --> 00:12:52,140 that are available to you. 237 00:12:54,580 --> 00:12:57,140 This also allows you to completely avoid 238 00:12:57,140 --> 00:12:58,280 grouping symbols. 239 00:12:58,640 --> 00:13:00,060 You never need any parentheses 240 00:13:00,060 --> 00:13:02,460 unless you're trying to treat code as an object. 241 00:13:03,780 --> 00:13:06,220 And it's trivially easy to interpret. 242 00:13:06,220 --> 00:13:11,040 So it takes no effort or code space 243 00:13:11,040 --> 00:13:12,720 to build an interpreter for this language. 244 00:13:14,040 --> 00:13:16,420 Now given an algebraic expression 245 00:13:16,420 --> 00:13:18,340 like 1 plus 10 times 3, 246 00:13:18,980 --> 00:13:21,360 we know that the multiplication happens first. 247 00:13:23,500 --> 00:13:26,060 And we can draw this little inheritance tree of it. 248 00:13:26,120 --> 00:13:29,660 So we see that the addition takes the 1 249 00:13:29,660 --> 00:13:31,040 and the result of the multiplication 250 00:13:31,040 --> 00:13:31,940 as its inputs, 251 00:13:32,660 --> 00:13:35,440 and then the multiplication takes 10 and 3 252 00:13:35,440 --> 00:13:35,980 as its inputs. 253 00:13:37,680 --> 00:13:39,160 Well, this can be rewritten. 254 00:13:39,240 --> 00:13:43,660 You can put every value 255 00:13:44,140 --> 00:13:45,840 between the operator that applies to it. 256 00:13:45,980 --> 00:13:47,220 So 10 3 times, 257 00:13:47,660 --> 00:13:49,060 as soon as the times hits, 258 00:13:49,240 --> 00:13:50,980 it multiplies those two together, 259 00:13:51,100 --> 00:13:52,680 and all we see on the calculator is 30. 260 00:13:53,860 --> 00:13:54,940 And then 1 plus, 261 00:13:56,080 --> 00:13:57,560 as soon as you get the plus sign, 262 00:13:57,620 --> 00:13:58,780 it pops the 30 and the 1, 263 00:13:58,900 --> 00:14:00,260 and it returns 31 to the stack. 264 00:14:02,740 --> 00:14:04,160 Viewed differently, if you have input, 265 00:14:04,340 --> 00:14:06,120 10 3 times 1 plus. 266 00:14:06,120 --> 00:14:08,220 The 10 is pushed onto the stack. 267 00:14:08,820 --> 00:14:10,740 The 3 is then pushed onto the stack. 268 00:14:11,700 --> 00:14:13,500 As soon as the multiplication hits, 269 00:14:13,780 --> 00:14:15,200 they're combined into 30. 270 00:14:16,280 --> 00:14:17,820 As soon as the 1 hits, 271 00:14:17,960 --> 00:14:19,060 1 is pushed on top. 272 00:14:19,980 --> 00:14:21,660 And then the addition combines them. 273 00:14:23,600 --> 00:14:26,340 Now, despite doing everything in reverse Polish notation, 274 00:14:26,660 --> 00:14:28,380 the calculator still has an algebraic type. 275 00:14:28,840 --> 00:14:31,000 So inside of quotation marks, 276 00:14:31,080 --> 00:14:33,540 you can say pi times 10 to the fifth power. 277 00:14:33,980 --> 00:14:35,700 And it interprets that properly. 278 00:14:36,780 --> 00:14:38,080 But when it's stored in memory, 279 00:14:38,240 --> 00:14:39,760 you have your entry prologue, 280 00:14:40,680 --> 00:14:45,000 and then you have the system in reverse Polish notation. 281 00:14:45,580 --> 00:14:47,280 So everything is rearranged, 282 00:14:47,320 --> 00:14:48,840 and inside of memory, 283 00:14:49,020 --> 00:14:51,520 you'll see 10 5 power pi times. 284 00:14:53,080 --> 00:14:54,760 And of course, this seems difficult 285 00:14:54,760 --> 00:14:56,040 if you're unfamiliar with it, 286 00:14:56,100 --> 00:14:59,560 but it's really as easy as learning your multiplication tables 287 00:14:59,560 --> 00:15:01,200 or all of that stuff that we now take for granted, 288 00:15:01,300 --> 00:15:02,800 but that we struggled with 289 00:15:02,800 --> 00:15:04,840 when we first saw it in elementary school 290 00:15:04,840 --> 00:15:05,820 or middle school or wherever. 291 00:15:07,120 --> 00:15:08,540 And then once you get used to this, 292 00:15:08,580 --> 00:15:09,420 you never want to go back. 293 00:15:10,500 --> 00:15:13,200 It's the most efficient way to use a graphing calculator. 294 00:15:14,460 --> 00:15:16,840 UNIX has a command line calculator 295 00:15:16,840 --> 00:15:18,140 that uses a similar interface. 296 00:15:18,900 --> 00:15:20,540 And many of us that know RPN 297 00:15:20,540 --> 00:15:22,280 will use it out of habit 298 00:15:22,280 --> 00:15:23,480 because it's so much more work 299 00:15:23,480 --> 00:15:25,840 to use algebraic notation. 300 00:15:27,440 --> 00:15:29,100 And then, of course, within this, 301 00:15:30,040 --> 00:15:31,480 pi isn't just a letter. 302 00:15:31,580 --> 00:15:34,220 It is the pi object that we saw before. 303 00:15:34,880 --> 00:15:36,520 As a real number. 304 00:15:37,620 --> 00:15:41,680 You'll see it's prolog of 0, 9, 2, 3, 3 at the beginning. 305 00:15:43,580 --> 00:15:44,980 Red backward, of course. 306 00:15:46,200 --> 00:15:47,840 Followed by the exponent, 307 00:15:48,040 --> 00:15:49,240 which in this case is a 0, 308 00:15:49,420 --> 00:15:51,440 and then the mantissa and the sign. 309 00:15:53,460 --> 00:15:56,660 Now, IO is performed for infrared input and output, 310 00:15:56,820 --> 00:16:00,700 even though the input diode never shipped on the device. 311 00:16:01,300 --> 00:16:03,700 Although it had all of the hardware 312 00:16:03,700 --> 00:16:05,860 to do input and output 313 00:16:05,860 --> 00:16:07,860 and backing up files and that sort of stuff, 314 00:16:09,140 --> 00:16:11,160 this was never supported by the software. 315 00:16:12,140 --> 00:16:15,180 And it was never supported by the product after release. 316 00:16:15,880 --> 00:16:19,260 You could use the output to print to an infrared printer, 317 00:16:19,780 --> 00:16:22,320 a little thermal printer that would give you receipt paper. 318 00:16:23,260 --> 00:16:25,840 But you couldn't back anything up to a computer. 319 00:16:25,980 --> 00:16:27,400 You couldn't receive anything from a computer. 320 00:16:28,140 --> 00:16:29,980 And as all software was stored, 321 00:16:30,260 --> 00:16:32,520 all user-added software was stored in RAM, 322 00:16:32,520 --> 00:16:35,680 as soon as your battery died or your program crashed, 323 00:16:35,800 --> 00:16:36,420 you lost everything. 324 00:16:36,920 --> 00:16:38,400 Every program you had ever written, 325 00:16:38,440 --> 00:16:39,520 you would have to type back in. 326 00:16:40,340 --> 00:16:42,320 And that's just how things were in 1986. 327 00:16:42,820 --> 00:16:46,060 But by 1990, they started changing things. 328 00:16:46,820 --> 00:16:49,520 And so they recognized that there was space in the board 329 00:16:49,520 --> 00:16:52,220 for a photo transistor right next to the diode. 330 00:16:52,720 --> 00:16:54,020 And they started poking memory, 331 00:16:54,160 --> 00:16:56,660 and they found the addresses for it. 332 00:16:57,720 --> 00:16:59,420 And near this piece of memory, 333 00:16:59,500 --> 00:17:00,840 they also found timers. 334 00:17:00,840 --> 00:17:02,520 They found control for the contrast. 335 00:17:03,200 --> 00:17:06,260 They found screen bits, 336 00:17:06,540 --> 00:17:08,260 so they could write a bit-mapped image 337 00:17:08,260 --> 00:17:09,420 to a particular spot in memory. 338 00:17:09,760 --> 00:17:12,340 They could even change how physical rows 339 00:17:12,340 --> 00:17:13,720 were mapped to logical rows. 340 00:17:13,920 --> 00:17:15,060 So if they had a bit-map 341 00:17:15,060 --> 00:17:17,740 and they wanted to scroll it very quickly, 342 00:17:17,940 --> 00:17:20,200 they could scroll it not by copying bits around, 343 00:17:20,500 --> 00:17:23,120 but rather by copying the... 344 00:17:23,120 --> 00:17:24,380 by moving the rows around. 345 00:17:25,600 --> 00:17:27,900 They could even overclock one of the calculators 346 00:17:27,900 --> 00:17:28,820 in software only. 347 00:17:29,560 --> 00:17:31,160 And all of these features 348 00:17:31,160 --> 00:17:32,440 were hidden from the original users. 349 00:17:32,580 --> 00:17:35,460 You could not do this when the device was manufactured, 350 00:17:35,600 --> 00:17:37,220 and none of the official documents admitted 351 00:17:37,220 --> 00:17:38,280 that such features existed. 352 00:17:41,140 --> 00:17:43,620 This is the printer that you could purchase, 353 00:17:43,780 --> 00:17:45,460 the HP 82240. 354 00:17:46,640 --> 00:17:51,040 You can see a graph being printed on the right, 355 00:17:51,120 --> 00:17:53,040 and then above that, some records. 356 00:17:55,480 --> 00:17:58,800 The row driver waveform was used to map... 357 00:17:58,820 --> 00:18:01,600 the mapped lines, as I mentioned earlier. 358 00:18:02,780 --> 00:18:05,200 And for scrolling, you can map... 359 00:18:05,200 --> 00:18:06,760 or you can swap these line mappings 360 00:18:06,760 --> 00:18:07,840 instead of the actual data. 361 00:18:08,280 --> 00:18:10,040 If you're doing sprites, 362 00:18:10,080 --> 00:18:12,880 you can actually hide half of the screen 363 00:18:12,880 --> 00:18:14,500 and then swap it in, 364 00:18:15,340 --> 00:18:17,240 just as I believe Mode X did 365 00:18:17,240 --> 00:18:21,000 on DOS video game programming. 366 00:18:21,460 --> 00:18:23,140 So you have off-screen memory, 367 00:18:23,360 --> 00:18:25,880 and then you swap that on-screen. 368 00:18:26,880 --> 00:18:28,800 And because you're just 369 00:18:28,820 --> 00:18:30,660 swapping memory and not actually moving memory, 370 00:18:30,920 --> 00:18:32,460 you don't have to read it all in 371 00:18:32,460 --> 00:18:33,520 and then write it back out. 372 00:18:36,200 --> 00:18:38,180 This is initialized at boot 373 00:18:38,180 --> 00:18:39,620 to the proper settings, 374 00:18:39,880 --> 00:18:42,320 and then it's interpreted by a software video driver. 375 00:18:42,940 --> 00:18:45,140 So in the 28C, an interrupt will fire, 376 00:18:45,740 --> 00:18:47,460 and when it fires, its handler 377 00:18:47,460 --> 00:18:50,920 will actually update the physical row 378 00:18:50,920 --> 00:18:53,040 that needs to be shown to the LCD lines 379 00:18:53,040 --> 00:18:54,280 at that moment in time. 380 00:18:56,860 --> 00:18:58,560 The row driver waveform looks like 381 00:18:58,820 --> 00:18:58,960 this. 382 00:18:58,960 --> 00:19:02,580 I've covered the ones in red circles. 383 00:19:02,740 --> 00:19:05,320 You can see that the first physical line 384 00:19:05,320 --> 00:19:06,080 comes initially, 385 00:19:06,280 --> 00:19:07,940 followed by the first logical line, 386 00:19:08,640 --> 00:19:10,200 and that they're on opposite ends. 387 00:19:10,920 --> 00:19:11,440 Sorry. 388 00:19:13,800 --> 00:19:16,900 They run backward and then to each other. 389 00:19:17,440 --> 00:19:20,500 So the first and the 32nd line are adjacent, 390 00:19:20,700 --> 00:19:22,660 followed by the second and the 31st 391 00:19:22,660 --> 00:19:23,980 and the third and the 30th. 392 00:19:24,020 --> 00:19:25,620 So the screen is actually updated 393 00:19:25,620 --> 00:19:26,960 from the top and the bottom 394 00:19:26,960 --> 00:19:29,360 by alternate lines working inward 395 00:19:30,520 --> 00:19:31,820 until they meet in the center. 396 00:19:32,400 --> 00:19:35,080 Wherever you see a red dot over a bit, 397 00:19:35,280 --> 00:19:38,840 that's the logical line that gets mapped 398 00:19:38,840 --> 00:19:40,140 to a particular physical line. 399 00:19:40,780 --> 00:19:44,180 So for example, if we changed the red dot 400 00:19:44,180 --> 00:19:47,340 on the second row to the very first bit, 401 00:19:47,480 --> 00:19:48,680 the one on the far left, 402 00:19:49,540 --> 00:19:52,160 the first logical line would be shown 403 00:19:52,160 --> 00:19:54,340 on two physical lines, both at the top 404 00:19:54,340 --> 00:19:55,560 and at the bottom of the screen. 405 00:19:56,360 --> 00:19:58,240 Setting more than one of these bits 406 00:19:58,240 --> 00:20:00,880 causes the screen to scramble, I believe. 407 00:20:04,240 --> 00:20:07,560 You could do a magnifying glass with that. 408 00:20:07,780 --> 00:20:09,820 So you could make the top half of the screen 409 00:20:09,820 --> 00:20:11,660 grow to fill the entire screen 410 00:20:11,660 --> 00:20:14,320 and all sorts of neat little tricks. 411 00:20:15,400 --> 00:20:21,280 RAM itself contains not only objects and variables 412 00:20:21,280 --> 00:20:21,940 and that sort of stuff, 413 00:20:22,060 --> 00:20:24,360 but it also holds sort of virtual I.O. addresses. 414 00:20:24,360 --> 00:20:27,980 So these are polled by a background process. 415 00:20:28,320 --> 00:20:30,260 And then if you write something to them, 416 00:20:30,320 --> 00:20:31,680 the polling process recognizes 417 00:20:31,680 --> 00:20:33,400 that it's not the value that it was before, 418 00:20:34,300 --> 00:20:36,700 and it then carries out an action based upon it. 419 00:20:37,400 --> 00:20:39,280 Or it will write to it in the background 420 00:20:39,280 --> 00:20:40,340 and then you read from it. 421 00:20:40,620 --> 00:20:42,440 For example, there's a keyboard buffer. 422 00:20:42,620 --> 00:20:45,600 So when you press a key, an interrupt fires, 423 00:20:45,860 --> 00:20:47,460 writes that to the next key slot 424 00:20:47,460 --> 00:20:49,120 on the keyboard buffer, 425 00:20:50,060 --> 00:20:53,480 and then any user software can just watch it magically appear 426 00:20:53,480 --> 00:20:54,860 because it's happening in the background, 427 00:20:55,960 --> 00:20:57,780 interrupting the foreground process. 428 00:20:59,060 --> 00:21:01,080 But at the same time, it's really just RAM. 429 00:21:01,220 --> 00:21:03,940 This doesn't physically connect to any I.O. addresses. 430 00:21:04,700 --> 00:21:06,600 The flags, the command line stacks, 431 00:21:06,860 --> 00:21:08,660 and the temporary environment are all stored here. 432 00:21:09,140 --> 00:21:11,820 The keyboard buffer works sort of like a clock. 433 00:21:12,060 --> 00:21:13,840 You've got a circular buffer. 434 00:21:15,260 --> 00:21:16,880 There's a variable that marks 435 00:21:16,880 --> 00:21:19,840 the start of unhandled keys 436 00:21:20,280 --> 00:21:21,720 and the end of unhandled keys. 437 00:21:21,720 --> 00:21:23,380 And it's... 438 00:21:23,960 --> 00:21:26,740 As keys are handled, these two advance, 439 00:21:26,920 --> 00:21:28,820 and the two hands are sort of chasing one another. 440 00:21:29,780 --> 00:21:32,780 So the characters on the right side of the display, 441 00:21:33,600 --> 00:21:34,780 those to be treated, 442 00:21:35,000 --> 00:21:37,380 have not yet been handled by the operating system. 443 00:21:38,460 --> 00:21:40,440 Now, key end is swinging around 444 00:21:40,440 --> 00:21:42,740 as new characters get entered into the waiting buffer, 445 00:21:42,940 --> 00:21:45,920 and key start is swinging around in the same direction 446 00:21:45,920 --> 00:21:48,080 as keys are handled by the operating system. 447 00:21:49,200 --> 00:21:51,080 If things slow down to the point 448 00:21:51,080 --> 00:21:53,820 where one crosses the other, then you lose key events. 449 00:21:54,720 --> 00:21:56,580 But the system still recovers itself. 450 00:21:58,200 --> 00:21:59,500 And at the same time, 451 00:21:59,520 --> 00:22:02,320 if the key end advances past key start, 452 00:22:02,580 --> 00:22:04,460 it then ceases to advance, 453 00:22:04,740 --> 00:22:06,200 knowing that everything has been handled. 454 00:22:07,480 --> 00:22:11,140 Doing this in a circular buffer makes sense, 455 00:22:11,340 --> 00:22:14,140 because you can just do a modulus operation on a pointer 456 00:22:15,720 --> 00:22:16,940 and then increment it 457 00:22:16,940 --> 00:22:18,700 and never have to care about resetting it 458 00:22:18,700 --> 00:22:19,580 or decrementing anything. 459 00:22:19,580 --> 00:22:21,320 You need no conditionals. 460 00:22:22,360 --> 00:22:24,020 To access machine language, 461 00:22:24,220 --> 00:22:26,080 there is a machine language program type, 462 00:22:26,320 --> 00:22:28,240 a 02C96, 463 00:22:28,700 --> 00:22:30,700 but it's not creatable by the user. 464 00:22:31,740 --> 00:22:33,340 So you have to bootstrap it, 465 00:22:33,420 --> 00:22:35,380 first using a program called ASS 466 00:22:35,380 --> 00:22:38,000 to compose an object. 467 00:22:38,460 --> 00:22:40,460 This tricks the operating system 468 00:22:40,460 --> 00:22:43,240 into applying a particular object type 469 00:22:43,240 --> 00:22:46,820 before some given hex digits. 470 00:22:47,760 --> 00:22:49,220 And then after that, 471 00:22:49,220 --> 00:22:51,540 they had the LASS operation, 472 00:22:52,120 --> 00:22:53,600 which was a short little program 473 00:22:53,600 --> 00:22:56,680 that signed the object type of machine language program. 474 00:22:57,960 --> 00:23:00,300 Now, it takes as input a machine language string. 475 00:23:00,560 --> 00:23:02,980 This is not an assembler in the sense of a PC 476 00:23:02,980 --> 00:23:04,380 or a workstation or a UNIX. 477 00:23:04,560 --> 00:23:08,900 You cannot give it a human-readable program. 478 00:23:09,060 --> 00:23:11,120 You have to give it individual nibbles 479 00:23:11,120 --> 00:23:14,040 in hexadecimal and nothing else. 480 00:23:14,800 --> 00:23:16,780 Every single character is one nibble. 481 00:23:17,580 --> 00:23:19,740 And it takes this machine language string 482 00:23:19,740 --> 00:23:22,600 and compiles it to a machine language object, 483 00:23:22,720 --> 00:23:23,800 which you can then execute. 484 00:23:24,680 --> 00:23:26,320 So you push the string to the stack, 485 00:23:26,480 --> 00:23:27,180 you run LASS, 486 00:23:27,320 --> 00:23:29,440 and then you store the resultant object to a variable, 487 00:23:29,580 --> 00:23:32,100 and then you can execute that variable as a program. 488 00:23:32,880 --> 00:23:33,900 When you do this, 489 00:23:33,940 --> 00:23:35,880 your raw machine code is running on the device. 490 00:23:36,340 --> 00:23:38,900 If you make any mistake that will cause the device to crash, 491 00:23:40,240 --> 00:23:42,200 you quite likely lose all of memory 492 00:23:42,200 --> 00:23:43,480 and have to start from scratch. 493 00:23:47,000 --> 00:23:48,760 This is an example of a program. 494 00:23:49,180 --> 00:23:55,900 You would have to type in 76C2091C7069C20 and so forth. 495 00:23:56,680 --> 00:23:57,540 All of this. 496 00:23:57,700 --> 00:23:59,200 And if you made one typo, 497 00:23:59,780 --> 00:24:01,460 that might be enough to crash your calculator. 498 00:24:03,280 --> 00:24:05,540 There's no debugger that allows you to single-step it. 499 00:24:05,580 --> 00:24:06,960 At the time, there was no emulator. 500 00:24:09,360 --> 00:24:11,000 You're on your own. 501 00:24:13,160 --> 00:24:14,780 Further, some of the addresses here 502 00:24:14,780 --> 00:24:17,480 are unique to the particular revision 503 00:24:17,480 --> 00:24:19,760 of the model of the calculator that you're running. 504 00:24:21,000 --> 00:24:23,200 And so when you actually find the listing in the book, 505 00:24:23,300 --> 00:24:25,020 it has this with holes in it, 506 00:24:25,080 --> 00:24:26,480 and you have to fill in those holes 507 00:24:26,480 --> 00:24:28,720 with bytes from a table in the appendix. 508 00:24:30,560 --> 00:24:33,300 You as a user have to assemble your own program 509 00:24:33,900 --> 00:24:35,520 just to type it into your calculator. 510 00:24:38,600 --> 00:24:42,020 So they suggested finding further things by searching ROM, 511 00:24:42,240 --> 00:24:43,660 and they included string tables 512 00:24:43,660 --> 00:24:46,160 for things like errors. 513 00:24:46,420 --> 00:24:48,860 So you could look up the particular error code 514 00:24:48,860 --> 00:24:50,680 and then search ROM for that error. 515 00:24:51,340 --> 00:24:53,640 And they suggested two ways of doing it 516 00:24:53,640 --> 00:24:55,600 as a sort of sign of the times. 517 00:24:55,820 --> 00:24:58,680 The first was to write a disassembler that... 518 00:24:58,680 --> 00:25:01,120 And by disassembler, they mean a program 519 00:25:01,120 --> 00:25:04,020 which gives you hexadecimal values from memory. 520 00:25:04,480 --> 00:25:05,640 So a memory spy. 521 00:25:05,760 --> 00:25:08,320 They don't really mean a disassembler in the modern sense. 522 00:25:09,020 --> 00:25:10,780 You could write one on the calculator, 523 00:25:11,000 --> 00:25:13,640 and then you could sort of scroll through memory, 524 00:25:13,660 --> 00:25:15,560 and it would show you the address on the left 525 00:25:15,560 --> 00:25:16,600 and the bytes on the right, 526 00:25:16,680 --> 00:25:19,600 and then you with pen and paper could do your analysis. 527 00:25:20,180 --> 00:25:22,460 They also suggested dumping it to a workstation 528 00:25:24,560 --> 00:25:26,540 using I.O. that'll be described later. 529 00:25:27,220 --> 00:25:29,540 The latter method was the one that they used 530 00:25:29,540 --> 00:25:30,840 for most of their research, 531 00:25:31,900 --> 00:25:34,860 but they knew so little about the hardware when they started, 532 00:25:35,080 --> 00:25:36,180 none of it being documented 533 00:25:36,180 --> 00:25:37,640 and none of this having been done before, 534 00:25:37,840 --> 00:25:39,180 that they had to... 535 00:25:39,960 --> 00:25:42,200 They had to write a short snippet of machine code 536 00:25:42,200 --> 00:25:43,900 to spit out to the only I.O. address they knew, 537 00:25:44,060 --> 00:25:45,660 that being the piezobuzzer. 538 00:25:46,340 --> 00:25:48,720 You get a full second of buzzing for a one, 539 00:25:48,780 --> 00:25:50,240 full second of silence for a zero. 540 00:25:50,520 --> 00:25:52,560 All of this has to be recorded to audio cassette 541 00:25:52,560 --> 00:25:54,160 and then fed into an Apple IIe. 542 00:25:56,340 --> 00:25:59,100 And then you've got problems changing tapes or floppy disks. 543 00:26:00,940 --> 00:26:02,940 It takes days to dump it, so... 544 00:26:02,940 --> 00:26:05,060 I mean, for days this thing was buzzing 545 00:26:05,060 --> 00:26:07,060 in poor Sebastian's dorm room. 546 00:26:10,500 --> 00:26:12,180 They then identify useful features 547 00:26:12,200 --> 00:26:13,160 like useful routines in memory, 548 00:26:13,320 --> 00:26:15,280 like saving and loading registers, 549 00:26:16,260 --> 00:26:18,220 reserving room in the heap, 550 00:26:18,500 --> 00:26:20,120 performing garbage collection. 551 00:26:20,780 --> 00:26:23,940 While this isn't object-oriented in the modern sense, 552 00:26:24,080 --> 00:26:27,260 it did have object creation and deletion 553 00:26:28,080 --> 00:26:28,920 in the modern sense, 554 00:26:29,020 --> 00:26:30,300 and you did have a garbage collector, 555 00:26:30,480 --> 00:26:31,840 similar to what you would have in Java. 556 00:26:34,920 --> 00:26:37,500 They also identified entry points for things 557 00:26:37,500 --> 00:26:40,000 like a function that shows a too-few memory error 558 00:26:40,640 --> 00:26:41,900 or a beep. 559 00:26:42,100 --> 00:26:45,260 So if you know that something is causing you 560 00:26:45,260 --> 00:26:45,940 to run out of memory, 561 00:26:46,120 --> 00:26:48,640 you can search for the call to that function 562 00:26:49,240 --> 00:26:51,140 and then identify what's happening. 563 00:26:51,580 --> 00:26:53,880 They do flowcharts for routines 564 00:26:53,880 --> 00:26:54,880 that they reverse-engineered. 565 00:26:55,020 --> 00:26:59,400 So when you call the saveRegisters function, 566 00:27:00,860 --> 00:27:02,480 it reserves an address in memory, 567 00:27:03,980 --> 00:27:05,860 then it makes sure that there's room available. 568 00:27:06,400 --> 00:27:08,480 If not, it attempts to garbage collect, 569 00:27:09,300 --> 00:27:11,100 and it only makes one attempt. 570 00:27:11,320 --> 00:27:12,660 Failing that, it'll continue on. 571 00:27:13,180 --> 00:27:15,180 If it runs out, it does the memory error. 572 00:27:17,000 --> 00:27:20,220 And they keep in mind that when they started, 573 00:27:20,300 --> 00:27:23,880 they knew nothing of what was inside this machine. 574 00:27:24,020 --> 00:27:26,040 They didn't have a floppy disk drive. 575 00:27:26,160 --> 00:27:27,860 They didn't have a debugger. 576 00:27:27,920 --> 00:27:29,160 They didn't have access to memory 577 00:27:29,160 --> 00:27:30,400 until they created it themselves. 578 00:27:31,460 --> 00:27:34,200 And they built all the way up to understanding 579 00:27:34,200 --> 00:27:36,520 how garbage collection was performed on the machine, 580 00:27:36,680 --> 00:27:38,460 understanding all of these things 581 00:27:38,480 --> 00:27:39,060 and all of these different routines 582 00:27:39,060 --> 00:27:40,680 that were essential to the operating system. 583 00:27:41,040 --> 00:27:42,620 And then instead of keeping it to themselves 584 00:27:42,620 --> 00:27:48,100 or doing a security exploit and publishing that, 585 00:27:48,320 --> 00:27:49,760 instead they documented it. 586 00:27:49,960 --> 00:27:51,860 And they documented it all to the point 587 00:27:51,860 --> 00:27:53,740 where you as a mere mortal could go through 588 00:27:53,740 --> 00:27:54,540 and do the same thing. 589 00:27:55,920 --> 00:27:57,800 And then as you start doing the simple stuff, 590 00:27:57,900 --> 00:27:59,740 you work your way up to the more advanced stuff. 591 00:28:02,380 --> 00:28:04,120 So the second part of the book 592 00:28:04,620 --> 00:28:06,340 discusses the hardware of the device. 593 00:28:07,580 --> 00:28:10,280 How to modify it, how to add new features 594 00:28:10,280 --> 00:28:12,660 that didn't exist as it was initially manufactured. 595 00:28:14,100 --> 00:28:15,840 They begin with an exterior description, 596 00:28:17,040 --> 00:28:19,220 then opening the machine and so forth. 597 00:28:20,200 --> 00:28:22,760 This is what the calculator looks like when it's opened. 598 00:28:22,920 --> 00:28:24,380 As you remember from the first slide, 599 00:28:24,600 --> 00:28:27,500 it has a keyboard on the left and the right 600 00:28:27,500 --> 00:28:30,280 with letters being on the left and numbers being on the right. 601 00:28:30,320 --> 00:28:32,980 So you can fold the letters behind the screen 602 00:28:32,980 --> 00:28:34,100 if you've no need for them. 603 00:28:35,420 --> 00:28:37,840 All of the electronics sit beneath the screen 604 00:28:37,840 --> 00:28:39,080 on the top right face, 605 00:28:39,600 --> 00:28:41,520 and then the batteries slide into the case 606 00:28:41,520 --> 00:28:42,560 to the side behind it. 607 00:28:43,960 --> 00:28:45,040 There are no screws. 608 00:28:45,340 --> 00:28:48,600 They have plastic pins which are glued into one another. 609 00:28:49,100 --> 00:28:51,040 So you have to either drill these out 610 00:28:51,040 --> 00:28:52,320 or physically break them. 611 00:28:53,380 --> 00:28:55,180 And even after 20 years of aging, 612 00:28:56,100 --> 00:28:58,840 they're not too keen to fall apart. 613 00:28:59,060 --> 00:29:00,340 So in opening this device, 614 00:29:00,540 --> 00:29:01,900 you're going to break a lot of it. 615 00:29:05,220 --> 00:29:07,100 Once the calculator is opened 616 00:29:07,100 --> 00:29:08,500 and you're looking inside of the board, 617 00:29:08,980 --> 00:29:11,280 you'll note that there are two ROM chips. 618 00:29:13,000 --> 00:29:14,300 On the bottom right, 619 00:29:15,700 --> 00:29:17,700 where all of those lines are labeled, 620 00:29:17,900 --> 00:29:19,260 that's the memory bus. 621 00:29:20,960 --> 00:29:22,900 There's B0, 1, 2, and 3 622 00:29:22,900 --> 00:29:26,120 because the fundamental unit of addressing is a nibble, 623 00:29:26,140 --> 00:29:27,620 so they only have to run four data lines. 624 00:29:29,220 --> 00:29:32,780 At the top, you'll see a diode symbol for output, 625 00:29:32,780 --> 00:29:35,440 and you'll see two empty pads to the right of it. 626 00:29:36,440 --> 00:29:38,140 That's initial supportive input 627 00:29:38,140 --> 00:29:41,960 that was never physically attached during manufacturing. 628 00:29:43,520 --> 00:29:45,880 And then you'll note a large capacitor 629 00:29:46,540 --> 00:29:51,440 with a resistance capacitance circuit beneath it, 630 00:29:51,500 --> 00:29:52,360 which is used for timing. 631 00:29:53,000 --> 00:29:54,880 If you want to overclock this older model, 632 00:29:55,060 --> 00:29:58,280 you modify the inductor and the capacitor, 633 00:29:58,560 --> 00:30:00,380 and in that way, you can change the clock. 634 00:30:03,380 --> 00:30:05,880 So they first describe an external power feed 635 00:30:06,860 --> 00:30:08,200 so that you don't have to keep buying 636 00:30:08,200 --> 00:30:09,480 expensive end-cell batteries, 637 00:30:11,520 --> 00:30:14,740 and they do this to get the user familiar 638 00:30:14,740 --> 00:30:16,180 with soldering and such. 639 00:30:16,880 --> 00:30:18,760 Immediately after that, they go into overclocking. 640 00:30:18,780 --> 00:30:21,080 By replacing a capacitor and inductor, 641 00:30:21,160 --> 00:30:22,900 you can speed the thing up, you can slow it down. 642 00:30:25,760 --> 00:30:27,880 And this is necessary in the 28C. 643 00:30:27,960 --> 00:30:30,360 In the 28S, you just run a program to do it. 644 00:30:30,380 --> 00:30:33,000 But the more interesting hardware modification 645 00:30:33,000 --> 00:30:36,640 was a replacement of the RAM of the device 646 00:30:36,640 --> 00:30:39,300 by actually cutting the traces of the memory bus. 647 00:30:39,880 --> 00:30:43,560 So they cut these gold traces on the circuit board, 648 00:30:44,400 --> 00:30:48,000 and then they purchased memory upgrades for the HP-71, 649 00:30:48,240 --> 00:30:50,540 the architectural ancestor of this device, 650 00:30:50,700 --> 00:30:52,440 for which they had full documentation. 651 00:30:54,040 --> 00:30:56,300 They then patch in this memory module. 652 00:30:58,300 --> 00:31:00,160 You can see from the pricing 653 00:31:00,380 --> 00:31:05,840 that 64 kilobytes would cost $150 to $300 654 00:31:05,840 --> 00:31:10,020 at the time that this book was published, 655 00:31:10,140 --> 00:31:14,240 which was four years after the calculator was first released. 656 00:31:15,240 --> 00:31:17,340 This was never supported by the manufacturer. 657 00:31:17,340 --> 00:31:21,120 They knew at this point in history. 658 00:31:24,620 --> 00:31:26,320 The I.O. ports were modified. 659 00:31:26,600 --> 00:31:28,840 It had ridiculously short range, 660 00:31:28,840 --> 00:31:32,680 and there was no receiving phototransistor. 661 00:31:32,960 --> 00:31:37,240 So they got the idea that they could patch in an opto-isolator. 662 00:31:37,520 --> 00:31:40,620 So you've got a single chip with an infrared LED 663 00:31:40,620 --> 00:31:43,700 and a phototransistor embedded in silicon, 664 00:31:43,880 --> 00:31:44,900 so the light never escapes. 665 00:31:45,200 --> 00:31:47,160 There's never any optical interference. 666 00:31:48,740 --> 00:31:51,100 And then they just ran the lines through it 667 00:31:51,100 --> 00:31:54,560 in series with the original phototransistor and photodiode 668 00:31:55,980 --> 00:31:58,100 so that you can have a physical cable 669 00:31:58,100 --> 00:31:59,160 to connect between two devices. 670 00:31:59,940 --> 00:32:02,200 They also did the same thing involving the buzzer. 671 00:32:02,220 --> 00:32:04,980 So when the buzzer fires, it turns on an LED. 672 00:32:05,420 --> 00:32:08,100 And they used this to connect to the Apple IIe, 673 00:32:08,220 --> 00:32:11,920 the Commodore, many different minicomputers 674 00:32:11,920 --> 00:32:12,980 that you had available at the time. 675 00:32:14,160 --> 00:32:15,700 They came up with cartridges 676 00:32:16,160 --> 00:32:17,960 so that you could replace 677 00:32:17,960 --> 00:32:20,540 what was plugged into the infrared ports on the fly. 678 00:32:22,180 --> 00:32:23,600 They have schematics included 679 00:32:23,600 --> 00:32:25,360 for connecting this to an Apple IIe joystick 680 00:32:25,360 --> 00:32:27,120 to connect the two calculators to one another. 681 00:32:27,120 --> 00:32:29,560 They have voltage-level converters 682 00:32:29,560 --> 00:32:31,180 so you can run it to RS-232 683 00:32:31,180 --> 00:32:32,940 and take it into your PC. 684 00:32:34,680 --> 00:32:37,740 They suggested adding a joystick, motor control, 685 00:32:37,900 --> 00:32:38,840 a robot, and a plotter. 686 00:32:39,960 --> 00:32:41,240 And most interesting, 687 00:32:41,600 --> 00:32:43,480 they suggested a telephone composer. 688 00:32:44,060 --> 00:32:46,160 They figured that you could make clicks with it 689 00:32:46,160 --> 00:32:49,520 that would work as a sort of rotary telephone. 690 00:32:50,740 --> 00:32:52,600 They never got around to freaking with this, 691 00:32:52,720 --> 00:32:54,480 but it would be interesting to see if it were possible. 692 00:32:56,520 --> 00:33:00,260 Then the book ends with appendices. 693 00:33:00,780 --> 00:33:03,360 And the appendices take a full third of the book. 694 00:33:04,400 --> 00:33:07,440 They begin by describing machine language in absolute detail. 695 00:33:07,700 --> 00:33:10,740 This is what you would expect in a manufacturer data sheet 696 00:33:11,320 --> 00:33:12,880 as opposed to the prose 697 00:33:12,880 --> 00:33:15,300 that forms the first two sections of the book. 698 00:33:18,000 --> 00:33:20,280 They describe the Saturn microprocessor. 699 00:33:20,400 --> 00:33:21,400 They describe its instructions. 700 00:33:21,780 --> 00:33:24,140 They have tables of error codes and objects. 701 00:33:24,480 --> 00:33:25,080 And entry points. 702 00:33:25,900 --> 00:33:26,880 And for each of these, 703 00:33:26,940 --> 00:33:28,480 they have to have it for every single revision. 704 00:33:28,720 --> 00:33:31,100 They had to disassemble the code of not one device, 705 00:33:31,260 --> 00:33:32,680 but of three or four devices. 706 00:33:34,340 --> 00:33:36,780 And then they include a small library of programs. 707 00:33:37,100 --> 00:33:39,040 So if you want to, say, invert the video of your screen, 708 00:33:39,140 --> 00:33:40,640 if you want to overclock your calculator, 709 00:33:41,140 --> 00:33:45,520 they include the original source code in their own notation. 710 00:33:46,520 --> 00:33:49,960 Then they translate that to machine language for you 711 00:33:50,520 --> 00:33:52,060 and include the information 712 00:33:52,060 --> 00:33:56,080 that you need to build that long series of hex 713 00:33:56,080 --> 00:33:57,180 that I showed you to type in. 714 00:33:59,700 --> 00:34:04,400 So after this in history, many events happened. 715 00:34:04,460 --> 00:34:05,840 This book was published in 1990. 716 00:34:07,400 --> 00:34:09,460 Since then, Hewlett-Packard came out 717 00:34:09,460 --> 00:34:11,020 with the much more famous 48 series. 718 00:34:12,800 --> 00:34:15,480 This supported memory expansion off the bat, 719 00:34:15,620 --> 00:34:19,120 which was first introduced by Voyage aux Cintres. 720 00:34:19,280 --> 00:34:21,900 They include infrared input and output. 721 00:34:21,900 --> 00:34:24,520 Also introduced in this book for the first time. 722 00:34:24,660 --> 00:34:25,840 They add a serial port. 723 00:34:26,120 --> 00:34:28,140 Also introduced in this book for the first time. 724 00:34:28,540 --> 00:34:32,440 And eventually the community wrote a program called MetaKernel, 725 00:34:32,500 --> 00:34:34,820 which was a replacement operating system 726 00:34:34,820 --> 00:34:36,940 that stayed on an external memory card. 727 00:34:38,640 --> 00:34:41,260 Sort of like Linux, but for a graphing calculator. 728 00:34:41,720 --> 00:34:46,320 And they jealously worked on this. 729 00:34:46,420 --> 00:34:48,380 They'd spend days on it, 730 00:34:48,420 --> 00:34:51,540 and you could actually go into a particular electronic shop in Paris 731 00:34:51,900 --> 00:34:56,160 and purchase a memory card with this kernel loaded on it. 732 00:34:58,680 --> 00:35:00,440 Later on, emulators were written. 733 00:35:01,100 --> 00:35:05,000 Christoph Geislink writes one called Emu28, 734 00:35:05,360 --> 00:35:09,240 which can emulate the HP28, 28C, 735 00:35:09,400 --> 00:35:10,660 and he has another for the 28S. 736 00:35:11,040 --> 00:35:14,480 So you can run this calculator today, 737 00:35:14,560 --> 00:35:16,000 and you can do it on your PC. 738 00:35:16,640 --> 00:35:19,800 He was able to build this emulator 739 00:35:19,800 --> 00:35:21,560 using the assistance of the book, 740 00:35:21,900 --> 00:35:23,400 even though he does not read French, 741 00:35:24,000 --> 00:35:25,780 by reading the pictures. 742 00:35:26,560 --> 00:35:28,880 Because there's so many diagrams in this, 743 00:35:28,960 --> 00:35:30,980 and so many of them contain useful addresses, 744 00:35:31,360 --> 00:35:33,800 that he was able to figure out his remaining questions 745 00:35:33,800 --> 00:35:35,420 about how the hardware functioned 746 00:35:36,620 --> 00:35:39,020 by looking at the diagrams in the tables alone. 747 00:35:41,460 --> 00:35:44,060 Then the HP49 series came out, 748 00:35:45,960 --> 00:35:47,880 including native support for algebra 749 00:35:47,880 --> 00:35:50,700 and all sorts of things that are necessary in the modern market. 750 00:35:50,700 --> 00:35:52,260 It has an SD card slot. 751 00:35:52,880 --> 00:35:56,280 My HP49 has two gigabytes of storage. 752 00:35:56,600 --> 00:35:57,800 Not that I'll ever need it, 753 00:35:57,920 --> 00:36:03,540 but it's certainly helpful to be able to go beyond the original memory. 754 00:36:03,980 --> 00:36:06,440 It supports a USB port, 755 00:36:06,640 --> 00:36:08,940 which is powered by a USB-to-serial chip. 756 00:36:09,740 --> 00:36:11,680 Infrared, serial, and all of that stuff. 757 00:36:11,980 --> 00:36:13,460 It has an ARM CPU, 758 00:36:13,800 --> 00:36:15,620 which emulates the original Saturn. 759 00:36:16,120 --> 00:36:18,080 After the very first HP49, 760 00:36:18,340 --> 00:36:19,920 they could no longer justify 761 00:36:19,920 --> 00:36:21,320 fabbing their own chip for this, 762 00:36:21,960 --> 00:36:23,440 but it was impossible for them 763 00:36:23,440 --> 00:36:25,380 to rewrite the software on their modern budget. 764 00:36:26,580 --> 00:36:27,920 So they built an emulator, 765 00:36:28,080 --> 00:36:30,160 and the official device that you buy today 766 00:36:30,160 --> 00:36:32,700 is an emulator of the classic device 767 00:36:32,700 --> 00:36:34,300 that you would have purchased a decade ago. 768 00:36:36,020 --> 00:36:37,260 It being ARM, though, 769 00:36:38,220 --> 00:36:40,460 some enterprising folks ported GCC. 770 00:36:41,020 --> 00:36:44,580 So you can compile a C program on your workstation, 771 00:36:44,780 --> 00:36:46,180 write it to an SD card, 772 00:36:46,820 --> 00:36:47,640 and copy it over. 773 00:36:49,160 --> 00:36:50,420 Then execute it. 774 00:36:50,480 --> 00:36:52,620 And it has full access to everything in the ARM device, 775 00:36:52,920 --> 00:36:59,300 as well as access by proxy to things within the emulated Saturn device. 776 00:37:00,000 --> 00:37:02,940 And then MetaKernel became the official operating system. 777 00:37:03,040 --> 00:37:06,920 So when you turn on a modern HP49 or 50G, 778 00:37:07,800 --> 00:37:09,960 there's a splash screen for MetaKernel, 779 00:37:10,040 --> 00:37:14,440 the image of which looks more like something that you'd find at DEF CON 780 00:37:14,440 --> 00:37:16,920 than something that you would find in Hewlett-Packard. 781 00:37:16,920 --> 00:37:19,500 And that's because they took this hacker operating system 782 00:37:19,500 --> 00:37:20,720 and they made it their official one, 783 00:37:21,540 --> 00:37:24,060 being unable to reproduce all of its features. 784 00:37:25,060 --> 00:37:27,860 TI calculator hacking came into vogue, 785 00:37:27,960 --> 00:37:31,120 and overclocking was performed by the same method, 786 00:37:32,220 --> 00:37:34,160 optionally cutting off a capacitor. 787 00:37:35,980 --> 00:37:39,620 And the next step will be the Texas Instruments Inspire calculator. 788 00:37:39,940 --> 00:37:41,220 It's completely locked down. 789 00:37:41,740 --> 00:37:42,760 DRM on everything. 790 00:37:42,960 --> 00:37:44,460 You cannot run any machine code. 791 00:37:45,000 --> 00:37:46,860 You cannot run any games. 792 00:37:46,920 --> 00:37:48,420 No ROM dump is available. 793 00:37:49,460 --> 00:37:51,800 And serious work is just beginning on this. 794 00:37:51,960 --> 00:37:57,740 So it's a sort of next step in this chain that stretches back to 1990. 795 00:38:01,100 --> 00:38:03,260 So I hope you've enjoyed a little history lesson. 796 00:38:03,600 --> 00:38:07,300 It's a departure from the MSP430 stuff that I usually speak about. 797 00:38:07,720 --> 00:38:08,860 But do you have any questions? 798 00:38:10,860 --> 00:38:11,380 Yes? 799 00:38:13,140 --> 00:38:14,440 It's on your DEF CON CD. 800 00:38:14,700 --> 00:38:14,900 No. 801 00:38:14,900 --> 00:38:17,900 I've finished 60% to 70% of it. 802 00:38:17,940 --> 00:38:19,700 It's not complete, and it's rather rough, 803 00:38:19,840 --> 00:38:21,060 but it's typeset in LaTeX. 804 00:38:21,380 --> 00:38:23,140 You get a bilingual PDF 805 00:38:23,780 --> 00:38:26,500 containing both a copy of the French 806 00:38:26,500 --> 00:38:28,420 and the English translation for each paragraph. 807 00:38:29,500 --> 00:38:31,240 If you natively speak French, 808 00:38:31,260 --> 00:38:34,500 or like myself, you can suffer through it, 809 00:38:34,560 --> 00:38:38,940 the original documentation is available at corbi.fr. 810 00:38:39,380 --> 00:38:41,520 That's C-O-U-R-B-I-S. 811 00:38:42,980 --> 00:38:43,960 Any other questions? 812 00:38:46,140 --> 00:38:46,800 Yes, again? 813 00:38:47,560 --> 00:38:50,540 Why are there so many French hackers on the HP Calculators? 814 00:38:50,860 --> 00:38:53,220 Because this book first came out in French. 815 00:38:53,520 --> 00:38:54,680 They had a head start. 816 00:38:54,940 --> 00:38:59,120 And then the authors later came out with a book on the HP-48. 817 00:39:00,400 --> 00:39:02,840 So because this work was originally done in French, 818 00:39:03,040 --> 00:39:05,200 and it took so long to be translated into English, 819 00:39:05,420 --> 00:39:07,320 a good 20 years or so, 820 00:39:08,420 --> 00:39:11,460 it set us behind here in the States. 821 00:39:11,640 --> 00:39:14,880 And many of the good HP Calculators, 822 00:39:14,880 --> 00:39:16,600 are from outside of France. 823 00:39:17,060 --> 00:39:18,700 But you're right in that the majority 824 00:39:18,700 --> 00:39:20,640 are French and then German. 825 00:39:23,120 --> 00:39:24,000 Any other questions? 826 00:39:25,900 --> 00:39:27,720 If I can't see you, just speak out. 827 00:39:29,640 --> 00:39:31,440 All right, well, thank you for your time. 828 00:39:31,620 --> 00:39:35,440 I'll be in room 115 by the vendor area 829 00:39:35,440 --> 00:39:39,320 for any one-on-one questions. 830 00:39:40,140 --> 00:39:40,820 Thank you.