Author Topic: noob Q  (Read 1164 times)

0 Members and 1 Guest are viewing this topic.

Offline big_tree2015

  • NULL
  • Posts: 3
  • Cookies: 1
    • View Profile
noob Q
« on: May 29, 2015, 07:27:39 pm »
I have this problem trying to understand a basic idea of how a microprocessor works. I tried reading some architecture books and they were really dense maybe someone can recommend a good one, especially that addresses this question I have. So I started from an electronics perspective trying to understand how each individual process is executed. THinking in terms of assembly commands, (say you have amd_64 and for simplicity one cpu) say you have "mov ecx, 1" along with a list of 20 other commands. Is there only one set of registers in that entire cpu to execute each command?

I know there are other parts of the cpu, but for something that is highlighted as a central part of how a computer works (every book I read says assembly-like behavior is the core of every language, especially C) this seems hard to understand. So I should understand that large programs are run (in gHZ cycles) by executing countless numbers of assembly-like commands in an environment with a small number of registers?

I apologize if this is badly worded but please recommend me to a book or website you think is appropriate.
Open the pod bay door, HAL

Offline TheWormKill

  • EZ's Scripting Whore
  • Global Moderator
  • Knight
  • *
  • Posts: 257
  • Cookies: 66
  • The Grim Reaper of Worms
    • View Profile
Re: noob Q
« Reply #1 on: May 29, 2015, 09:55:15 pm »
Yes, each process has only a few general-purpose registers and some others. It's code is in assembly instructions, which vary depending on the architecture you use. But the registers are not the only memory the process uses, which seems to be what you think, judging by your wording. Thus, I recommend that you read about some keywords:
- what is the stack?
- the heap?
- virtual memory?

Hope this helps.
Stuff I did: How to think like a superuser, Iridium

He should make that "Haskell"
Quote
<m0rph-is-gay> fuck you thewormkill you python coding mother fucker

Offline ghostdragon

  • /dev/null
  • *
  • Posts: 7
  • Cookies: 1
    • View Profile
Re: noob Q
« Reply #2 on: June 03, 2015, 04:05:07 pm »
i'll try to explain you:
every processor has a little banch of general purpose registers and a smaller banch of private registers,
the number of registers is implementation dependent and, just for example, private registers include 1 register for the current istruction e 1 for program counter.
every processor makes the loop:
- fetch
- decode
- execute
- check interruption

now, we assume 1 single processor not parallel, and this code ( i use D-RISC for this example)
Code: [Select]
         CLEAR  R2
loop:    LOAD   R1, R2, R3
         LOAD   R4, R2, R5
         ADD    R3, R5, R6
         STORE  R7, R2, R6
         INCR   R2
         IF<    R2, R8, loop
this can be
Code: [Select]
for (i = 0; i < N; i++) C[i] = A[i] + B[i];
in our example we have 7 istruction and a for loop that will be executed N times:
so we have (1 (CLEAR) + 6 * N (LOOP)) * T
were T is the average time that processor does the work of fetch, decode, execute, check interrupt.

every time processor wants to fetch an istruction send a request to a module (MMU) that does the translation from logical address to fisical address.
MMU speaks with L1 cache and returns the istruction to processor (if there is not a fault, at this point i will talk about paginated memory, segmented memory, TLBs, ecc., too long...).
processor --> MMU --> TLB -->  L1 --> ...
for every fetch (and eventualy, other access to the memory for istruction m-m or r-m).
when processor owns the istruction ( in IR register) can do the decodification and the execution of the istruction.
every istruction (class of istruction) has different T (Register-Register arithmetical short operation can have 1 clock circle to execute,ecc).

if there are cache faults we have (1 + 6*N) * Tex + Nfault * Tfault

I have written enough, for pipeline processors or multicore or istruction cache e data cache you have to understand this before.

this are the concepts i have, probably is only didattic stuff, but is the best i can do.
if someone has less didattic, more real world experience/concepts correct me.

as always, sorry for my  english ;)
« Last Edit: June 04, 2015, 10:36:00 am by ghostdragon »
---
Sorry for my bad English :)

Offline big_tree2015

  • NULL
  • Posts: 3
  • Cookies: 1
    • View Profile
Re: noob Q
« Reply #3 on: June 07, 2015, 05:56:10 pm »

yeah, ok thanks for the reply. You look pretty advanced in your understanding of machine behavior, i am also curious

about why one uses C for manipulating memory & pointers, why use such low level programming when one can just

depend on the compiler?


I found these in pdf section, maybe other noob will find them useful:

http://upload.evilzone.org/download.php?id=9242941&type=zip

http://evilzone.org/ebooks/inside-the-machine-an-illustrated-introduction-to-microprocessors-and-computer/


btw your English looks pretty solid
« Last Edit: June 08, 2015, 06:08:56 am by big_tree2015 »
Open the pod bay door, HAL

Offline ghostdragon

  • /dev/null
  • *
  • Posts: 7
  • Cookies: 1
    • View Profile
Re: noob Q
« Reply #4 on: June 08, 2015, 12:05:59 am »
yeah, ok thanks for the reply. You look pretty advanced in your understanding of machine behavior, i am also curious about

why one uses C for manipulating memory & pointers, why use such low level programming when one can just depend on  the compiler?

I think that the more you have to manage  low level things, the more you have to use low level languages, up to the verilog...

-------------------
|        Ln           | <-- Application
-------------------
|          .           | <-- OS
-------------------
|          .           | <-- Assembler
------------------
|          L1        | <-- Firmware
-------------------

every level has languages that fits best for the pourpose, and in each level languages have different vision of the system.... in firmware programming you have vision of all registers and modules, in assembly level you can view less register but you have more "power" (you can call procedures!), in c you don't see any register(see register keyword) but you can manage pointers (and have sockets!), in (Objective)$LANGUAGE(++|#|*) you can have generic programming, regexp, ecc.

you must write the scheduler for your OS, or the memory manager for your OS, what language you think you'll use? :)

I found these in pdf section, maybe other noob will find them useful:

http://upload.evilzone.org/download.php?id=9242941&type=zip

http://evilzone.org/ebooks/inside-the-machine-an-illustrated-introduction-to-microprocessors-and-computer/


btw your English looks pretty solid
this is usefull too:
"What Every Programmer Should Know About Memory" --> https://people.freebsd.org/~lstewart/articles/cpumemory.pdf

As always, sorry for my english ( i'll write this on my signature asap :)
« Last Edit: June 08, 2015, 12:49:06 am by ghostdragon »
---
Sorry for my bad English :)

Offline big_tree2015

  • NULL
  • Posts: 3
  • Cookies: 1
    • View Profile
Re: noob Q
« Reply #5 on: June 12, 2015, 04:15:40 am »
okay I'm gonna read over your attachment as my reading list is currently quite long and I will get back to you...
Open the pod bay door, HAL