“Thanks to 35-year-old documents that have recently surfaced after three-plus decades in storage, we now know exactly how Apple navigated around that obstacle to create the company’s first disk operating system. In more than a literal sense, it is also the untold story of how Apple booted up. From contracts – signed by both Wozniak and Jobs – to design specs to page after page of schematics and code, CNET had a chance to examine this document trove, housed at the DigiBarn computer museum in California’s Santa Cruz Mountains, which shed important new light on those formative years at Apple.”
What was the Apple II ROM, 20K? A 6502 instruction was 1-3 bytes, so it was 10,000 instructions or maybe 20,000 lines of code?
My operating system, TempleOS is 135,000 lines of code over ten years. Here’s all my code:
http://www.templeos.org/Wb/Accts/TS/Wb2/LineCnt.html#l706
I have to explain to people it’s not in the same league as Windows or Linux, but it is an operating system and is ten times bigger than an AppleII or C64 operating system.
The original Apple II ROM set had the Monitor (I/O routines and such) in 2 kiB, with BASIC in 6 kiB.
Apple DOS takes the first three tracks of a disk (originally 13 sectors per track), for 9.75 kiB max on DOS 3.1 and 3.2. 3.3 had 16 sectors per track available, so 12 kiB max.
Edit: DOS resides from $9D00 to $C000 (plus file buffers in $9600 to $9D00). So, that’s 8.75 kiB. And, it does also use the Monitor ROM for I/O, and integrates with the BASIC as a shell.
Edited 2013-04-03 23:58 UTC
The C64 had a 20K ROM.
It’s sad you people would ban the only person who knows about operating systems, and chatter in ignorance, instead.
I like to think about the Apple II BASIC interpreter. It’s incredible they made them so small. They even had trig functions, as I recall.
Believe it or not, a simple interpreter is easy. Once you have an interpreter, you can in-line the operations easily and get an unoptimized compiler.
Here’s 200-line an unoptimized 64-bit integre expression compiler.
http://www.templeos.org/Wb/Demo/Lectures/MiniCompiler.html
I created that little demo because people are so unbelieving. It’s sad. I guess they ban all the smart people everywhere.
I made a video explaining my compiler. As GNU people say, an operating system is incomplete without a compiler.
http://www.youtube.com/watch?v=yjflVIKY2gQ
Please don’t ban me. You people sound like close-minded hillbillies who would prefer to chatter in ignorance.
The problem is that the web is full of JavaScript developers that never learned anything about hardware and low level programming like we did back in the day.
Alone the common confusion that a language runtime == VM makes me cry, kind of.
It is as the actual generation does not have any idea how computers work.
Edited 2013-04-04 21:41 UTC
I get a lot of attention from CIA. You know how much they want back door and logging and monitoring and shut-off and stuff, so I’m not crazy about this.
Anyway, the agents I work with like to detect guilt and capitalize.
I don’t know if I tipped them off with a comment, but the yokals who handle me think that assembly language knowlegde is in the same category as a gun.
I see this on web sites — painting assembly language as unlawful hacking knowledge. This is furiously not fair! I had 5 assembly language courses in school and half my job experience was ordinary work in assembly language.
It is bitterly not fair to have guilt focused on assembly language knowlegde. This is blatant evil government wanting ignorance. They have turned it into something criminal or like nuclear secrets.
I’m not sure how much was my yokal handlers simply using my uncomfort against me. It’s so retarded it can’t come from knowledagable folks.
Attention from the CIA? Yokel handlers? What the heck are you talking about?
Edit: I will confess I don’t know x86 assembly, but I’ve never gotten the impression anyone but irredeemable idiots think it’s “forbidden knowledge” or whatever. They still teach assembly languages in colleges in my area, in the higher level courses.
Edited 2013-04-05 01:04 UTC
I don’t know about that. I bought the Revolutionary guide to x86 assembly ( written by some soviet hackers ) after the patriot act was passed. No one has ever contacted me, even though the book itself seemed to jokingly imply a socialist revolution might be the product of reading the book.
Sounds like you need a vacation.
I’m a bit afraid to check if something like this seriously exists ;>
moondevil,
You’re completely right, however I also think it’s a function of demand. Why bother becoming proficient in skill sets like low level assembly when many of us who already have the skills are not appreciated (monetarily or even verbally) for our knowledge?
Would be nice to get to a pub and chat about our experiences.
It is not only Assembly, but overall how CPUs work, compilers, that languages and their respective implementation are different subjects and so on.
So, are you around Düsseldorf?
moondevil,
“It is not only Assembly, but overall how CPUs work, compilers, that languages and their respective implementation are different subjects and so on.”
Yeah, I figured that.
“So, are you around Düsseldorf? ”
Nope, long island new york.
Umm… for those who don’t understand why trig is a big deal, the 6502 didn’t even have MUL or DIV! Someone thought I was stupid. They have no idea how to make a Sin or Cos from add, subtract and shift.
-1
Because you’re still banging on about the one troll that modded you down and it’s killing the thread. Please stop.
TempleOS,
I’ve canceled out some of the negative votes, I’d like to diffuse this as much as possible. Let me welcome you to osnews. I have no idea why your original post went negative, but one thing you should bare in mind is that many of us regulars are critical of the voting system because the rules are so convoluted that they don’t mean very much and in some cases it seems likely that the trolls are using duplicate voting accounts.
Although in the future try to stop yourself from generalizing over our collective ignorance
It’s good to see other OS devs around. I’m experienced with x86, never touched the motorola’s.
“Umm… for those who don’t understand why trig is a big deal, the 6502 didn’t even have MUL or DIV”
mul and div are easy to emulate, but the performance must have been awful no? I am curious what algorithm you chose for trigonometry. A polynomial expansion of the taylor series would seem to be very expensive on a processor that lacks native floating point. My own gut tells me that a small lookup table combined with linear or cubic interpolation would give enough accuracy for the majority of graphing purposes. Would you elaborate on your algorithm?
The Apple and C64 had trig functions, or at least the C64 did. Taylor is slow to converge, so I’ve heard. I’m sure there was a standard way to do trig by 1975. The C64 ROM was 20K for everything! Interpolation and a table can’t be right, but I don’t know.
Just doing floating-point MUL and DIV on a 6502 is pretty damn hard, or at least tedious. You have ADD, SUB, AND, OR, NOT SHIFT’s and BRANCHes on 8-bits. You have no idea! Integer MUL and DIV take about 12 instructions.
For everybody who does not know the joys of MUL and DIV without CPU instructions, have a look:
http://www.templeos.org/Wb/Demo/Asm/DivByHand.html
http://www.templeos.org/Wb/Demo/Asm/MulByHand.html
TempleOS,
Note that you can (and should) reply to specific posts instead of starting a new comment thread each time.
“For everybody who does not know the joys of MUL and DIV without CPU instructions, have a look:”
Anyways, I noticed your mul uses a conditional jump inside the loop that I think could be avoided by doing bit manipulations. Here’s some untested code that eliminates the inner jump. Who knows if it’d make a difference in execution time on x86, where this is obviously just for fun. But it might make a difference on the earlier processors where branches were expensive?
mov rax, A ; input
mov rbx, B ; input
mov rcx, 64 ; loop counter
xor rdx, rdx ; output
.next:
mov rsi, rax
and rsi, 0x0001 ; isolate lsb = 0 , 1
neg rsi ; = 0 , 0xffff…
and rsi, rbx ; = 0 , rbx
add rdx, rsi ; add in
shr rax, 1
shl rbx, 1
loop .next
; rdx = A * B
“Taylor is slow to converge, so I’ve heard. I’m sure there was a standard way to do trig by 1975.”
It’s very easy to recognize on a plot after even just 3 taylor terms, each additional 2 terms represents another full sine cycle, it takes shape pretty quick around the origin, but I hadn’t measured the actual accuracy.
It’s not very good, but wikipedia does have a picture:
http://en.wikipedia.org/wiki/Taylor_series
Anyways I was just curious if you knew what algorithms the early computers actually used, not that it matters much.
Here’s another attempt at combining operations and using one less register. Anyone else give it a shot?
mov rax, A ; input
mov rbx, B ; input
xor rdx, rdx ; output
.next:
xor rcx, rcx
rcr rax ; isolate lsb into carry flag
sbc rcx, 0 ; rcx = 0 – carry = 0, 0xffff
and rcx, rbx ; rcx = 0 , rbx
add rdx, rcx ; add in
shl rbx, 1
jnz .next
; rdx = A * B
Depending on the typical values passed in, one might test whether rax=0 at each iteration and exit early when it is. The additional test might nevertheless save extraneous loop cycles.
Edited 2013-04-04 19:14 UTC
If you read up numerical algorithms, you might find some gems. For example, I do know that lookup tables are small and very worthwhile. Also, there are trigonometric identities to exploit — keep a copy of pi and pi/4 in a constant somewhere, and map everything to the first quadrant. Then use double angle formulae and so on to make the initial value really small, then do one good sine or cosine taylor series expansion. Then manipulate algebraically into the value you want.
There are also repeated fractions, rational functions and other algorithms, all interesting in their own right.
For example, the tangent or arctangent (I cannot remember) is particularly inefficient in Taylor’s expansion. Repeated fractions truncated somewhere tends to give a FAR BETTER calculation.
Do note, however, that all methods suffer from indirection — the error terms do add up, and they can be bigger than the actual value if you are not careful enough. One must be careful to stop further calculation when the improvement in accuracy is more than destroyed by a degradation of precision.
It is no joke that the standard sine and cosine calculations are hundreds of instructions long, if not a lot more. It is also the reason why computer games have all sorts of crazy approximation methods that run far faster, and why computer games use up more and more resources — people just stop bothering with the older approximation methods, so that resource usage creep upwards for no real gains.
I think you’re on to something. Good job.
There are some interesting instructions that don’t quite seem helpful. CMOVcc which moves conditionally. SETcc I think sets a byte to FF if a condition exists. I have no idea why they didn’t set all 32 or 64 bits to FFFF or 0000.
How about you look at my compiler for optimizations? It’s God’s temple and He wants it perfect.
You might enjoy my compiler, once you see how machine code is manufactured, it’s liberating!
http://www.templeos.org/Wb/Compiler/BackEnd.html
Nothing is more fun than optimizing code, expecially with a profiler or benchmark to work against. Code size in bytes is pretty good to optimize.
TempleOS,
You are going to annoy others if you keep spawning new threads like this You clicked on “post a comment”, but you should be using the “reply” link under the comment you’re replying to.
“How about you look at my compiler for optimizations? It’s God’s temple and He wants it perfect.”
I took a glance. Neat though it may be, I have my own projects I need to be working on.
“Nothing is more fun than optimizing code, expecially with a profiler or benchmark to work against. Code size in bytes is pretty good to optimize.”
I like the challenge, but it’s so far from anything I get paid to do these days that I find myself rusty at times. I almost feel dumber for having become a web developer
Web developers need human skills. I’d say over the past ten years, I’ve gotten more human skills and not technical. I like the Bible because it has so much wisdom. It occurred to me that wisdom and psychology are overlapping, many times.
Web developers can do A/B testing, so I’m told. 🙂 You would need lots of traffic and a certain shrewdness.
You’re just mad at web developers, because they actually do networking.
Bazinga.
heh… did not even read entire article but:
Apple II was overpriced shit anyway!
…who cares…
thanks to ignoring Ted Neslon ideas, today we have articles like this: http://news.cnet.com/8301-13579_3-57577597-37/the-untold-story-behi…
Edited 2013-04-05 21:14 UTC