Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

What happens inside your computer?

#1
C C Offline
https://plus.maths.org/content/what-does...er-science

EXCERPT: I turn on my laptop. I open the file for this article. I start typing: the letters appearing with each keystroke, building to words, sentences and paragraphs. I save the file. I scroll back to reread. I move the cursor to edit the text: deleting some, moving some, typing more. I save the file, I scroll back to reread, I edit some more, until I feel this article is done, at which point I'll upload it to our website.

That's my view of the events taking place on my computer as I write this article. I'm aware that behind each of these events complex operations are occurring: in the text-editing software, the computer's operating system, the machine code that translates between software and hardware. And underlying it all, this text ultimately exists as strings of 0s and 1s, manipulated and stored as strings of binary digits, physically encoded into the computer's circuitry.

Computers are an interface between theory and physical reality; they operate both on a theoretical level of programming languages and data, and on the nuts-and-bolts level of the computer's hardware. They are a pinnacle of discoveries in physics and engineering, but also in the mathematics and logic of computer science. Where does the realm of one end and the other begin...

MORE: https://plus.maths.org/content/what-does...er-science
Reply
#2
confused2 Offline
[quote pid='13570' dateline='1504587497']
Here is the entire instructions set of the Intel 8080 used in the original IBM PC
http://www.classiccmp.org/dunfield/r/8080.txt

Later processors use more more bits and are much faster but the principle is the same.

assume the program counter (PC) starts at zero ...
the processor reads the byte stored in memory location zero
Read from location 0 and execute
PC=1
Read from 1 and execute
PC=2
Read from 2 and execute
PC=3
Read and execute
...
For some real excitement we can jump...
JMP      11000011 01101100 00000000
Loads the program counter with 00000000 01101100
and continues program execution from 00000000 01101100

It is more fun than you would believe possible.
Another fun bit is the way the letters get onto the screen.
There's an area of memory that is scanned by some clever electronics that turns what is written in the memory location into bright and dark. More sophisticated now but the principle is the same.

[/quote]
Reply
#3
confused2 Offline
I think it would be unreasonable to leave out subroutines. Maybe interrupts too - we'll see how popular this post is - more than five 'likes' and we do interrupts.
So far we've seen the program counter advance for each instruction and even a program jump. Program jumps are more exciting when you can make them conditional - for example if the result of adding two registers together results in a carry you can jump to one place if it does and another place if it doesn't.
Subroutines! Yaay.
Once you're fairly far forward in your program (bearing in mind that I'm a machine code programmer) You'll have written bits of code to put individual characters on the screen - so what use is that you ask?
Subroutines! Let's assume we have the value we want to display in the accumulator (say the ascii character 'R' (we're going to display 'READY' on the screen)). This is exciting - we have 01010010 in the accumulator and we call the subroutine that will set the pixels on the screen (write ... I won't do it here...)... when calling a subroutine the current program counter is is stored in an area of memory called the stack - there is a stack pointer which points to this area of memory - and as the program counter is stored the stack pointer is incremented (by two bytes - the program counter is 16 bit so two bytes) and the program counter is set to the value you gave in the CALL instruction (obviously a three byte instruction) so the actual value of the program counter on stack will be (location of call + 3). Program counter then fetches from the start of the subroutine and works through each instruction until it gets to a RET (return from subroutine) instruction. The Stack pointer is decremented by two and the top two bytes of the stack are read into the program counter. Program execution continues as normal after the call to the subroutine. So to put 'READY' on the screen you'd have something like
MVI A,nextbyte 00111110 01010010 < an 'R'
CALL dddd where dddd is the address of the subroutine that puts the bytes which you interpret as 'R' on screen
... note we continue execution 'inline' after the subroutine
MVI A,nextbyte 00111110 011101 < 'E'
CALL dddd where dddd is the address of the subroutine that puts the bytes which you interpret as 'E' on screen
and so on until the word 'READY>' is up on the screen. We assume (of course) that the subroutine we use keeps track of where we're writing, advances one character each time and draws a cursor in the next position.
Interrupts - by request.
Fourty years ago all you needed to do was keep building on this and get it done before some other asshole did it. No regrets. All I ever wanted was a rat-infested shack by the sea.
Edit... and Mrs C2.Smile
Reply
#4
C C Offline
(Sep 7, 2017 10:01 PM)confused2 Wrote: No regrets. All I ever wanted was a rat-infested shack by the sea.
Edit... and Mrs C2.Smile


Never too old for that last minute save to avoid sleeping on the couch. Or maybe more exposed to the sea than you'd like tonight or the next. Wink

- - -
Reply
#5
C C Offline
(Sep 7, 2017 07:02 PM)confused2 Wrote:
(Sep 5, 2017 05:58 AM)pid='13570 Wrote: Here is the entire instructions set of the Intel 8080 used in the original IBM PC http://www.classiccmp.org/dunfield/r/8080.txt

Later processors use more more bits and are much faster but the principle is the same.

assume the program counter (PC) starts at zero ...
the processor reads the byte stored in memory location zero
Read from location 0 and execute
PC=1
Read from 1 and execute
PC=2
Read from 2 and execute
PC=3
Read and execute
...
For some real excitement we can jump...
JMP      11000011 01101100 00000000
Loads the program counter with 00000000 01101100
and continues program execution from 00000000 01101100

It is more fun than you would believe possible.
Another fun bit is the way the letters get onto the screen.
There's an area of memory that is scanned by some clever electronics that turns what is written in the memory location into bright and dark. More sophisticated now but the principle is the same.

CPU clock rate of 2 MHz to 3.125 MHz, access to a "whopping" 64kb of memory. Maybe more analogous to the Ford Model T rather than horse and buggy days?

Historic year of 1974. Britain goes to a 3-day work week following a power shortage caused by striking miners. In April, Patty Hearst robs a bank with the SLA. Ted Bundy seizes victim Susan Rancourt. Pan Am 707 crashes into the mountains of Bali. President Nixon hands over partial transcripts of Watergate tape recordings...

- - -
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Research Something strange happens when you ask AI to act like Star Trek C C 0 21 Mar 3, 2024 08:13 AM
Last Post: C C
  Living inside a massive computer program + Consciousness is an inference process C C 3 623 May 28, 2017 04:21 PM
Last Post: C C



Users browsing this thread: 1 Guest(s)