Helpful ReplyHot!The specifier "register" in the standard C

Author
Andy_Taiwanese
Super Member
  • Total Posts : 408
  • Reward points : 0
  • Joined: 2014/12/19 02:59:38
  • Location: 0
  • Status: offline
2017/12/06 23:19:41 (permalink)
0

The specifier "register" in the standard C

Hi, there! I'm trying to interpret my problem explicitly, if there is any shortage of information, please let me know.
 
I read a book "C how to program 6/E" and here is an excerpt(attachment 1).
When I was reading this part, I was like, is this high-speed hardware register an counterpart of Working register?(Personal Computer vs PIC device)
 
 
As far as I know, the architecture of the personal computer is: the OS load program from secondary memory(disk) to RAM and execute it. When the data in the process(process is the program in the ram)need to be calculated, OS need to put data into the register and do calculation, then put it back to the RAM.
 
As to PIC, the data to be calculated in the data memory(RAM) need to be put into the Working register and do calculation, then put it back to the data memory(RAM).
 
Question: Is high-speed hardware register in textbook an counterpart of Working register?
 
Problem 2:
This is the PIC16F1824's BLOCK DIAGRAM(attachment 2) and this is the CORE BLOCK DIAGRAM of which(attachment 3)
 
Question: Are these two RAM block a same one?
 
Thank you!

Attached Image(s)

#1
andersm
Super Member
  • Total Posts : 2255
  • Reward points : 0
  • Joined: 2012/10/07 14:57:44
  • Location: 0
  • Status: offline
Re: The specifier "register" in the standard C 2017/12/07 00:11:51 (permalink) ☄ Helpfulby Andy_Taiwanese 2017/12/07 01:37:38
+1 (1)
Andy_TaiwaneseQuestion: Is high-speed hardware register in textbook an counterpart of Working register?

Yes. Note that compilers have always been allowed to ignore the register keyword, and most modern ones do. In C++, the keyword was deprecated in C++11 and removed in C++17.
 
Question: Are these two RAM block a same one?

Yes.
#2
NKurzman
A Guy on the Net
  • Total Posts : 15127
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: The specifier "register" in the standard C 2017/12/07 00:40:44 (permalink) ☄ Helpfulby Andy_Taiwanese 2017/12/07 01:37:45
+1 (1)
Be careful trying to match rules for different architecture CPUs.
1. The PIC code is alway run out of flask. It is not copied to RAM like a PC.
2. In the CPU world you have RISC and CISC processors. Simple Construction sets versus complex once. The PIC I very simple.
3. Then there was Accumulator base vs register based. Does every thing go through the accumulator. The pic is a yes.
4. Harvard versus von Neumann architecture.
5. The Stack. The PIC has no paratameter stack. Most CPUs do.

C was an attempt to somewhat avoid these differences.
#3
Andy_Taiwanese
Super Member
  • Total Posts : 408
  • Reward points : 0
  • Joined: 2014/12/19 02:59:38
  • Location: 0
  • Status: offline
Re: The specifier "register" in the standard C 2017/12/07 01:05:12 (permalink)
0
To NKurzman:
Thank you. I want to clarify whether we are on the same page.
 The PIC code is alway run out of flask. It is not copied to RAM like a PC.

What do you mean run out of flash? I think the code in PIC is always in the flash memory(program memory)
Then there was Accumulator base vs register based. Does every thing go through the accumulator. The pic is a yes.

Can you please give me some keyword for me to google? What are(or is? Sorry bad grammar) Accumulator base and register base?
 
Thank you. 
#4
qɥb
Monolothic Member
  • Total Posts : 171
  • Reward points : 0
  • Joined: 2017/09/09 05:07:30
  • Location: Jupiter
  • Status: offline
Re: The specifier "register" in the standard C 2017/12/07 01:24:17 (permalink) ☄ Helpfulby Andy_Taiwanese 2017/12/07 01:37:30
+1 (1)
Andy_Taiwanese
 The PIC code is alway run out of flask. It is not copied to RAM like a PC.

What do you mean run out of flash? I think the code in PIC is always in the flash memory(program memory)

You are both saying the same thing.
Code is NOT copied to RAM, it runs directly from the FLASH memory.
 

Then there was Accumulator base vs register based. Does every thing go through the accumulator. The pic is a yes.

Can you please give me some keyword for me to google? What are(or is? Sorry bad grammar) Accumulator base and register base?

There really is no value to you in pursuing this further.
The "register" keyword only ever had any use in processors that have multiple working registers.
PIC16F and PIC18F chips only have a single working register, so it is entirely meaningless in the PIC world.
 
post edited by qɥb - 2017/12/07 01:25:50
#5
du00000001
Just Some Member
  • Total Posts : 1434
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: online
Re: The specifier "register" in the standard C 2017/12/07 01:45:16 (permalink)
+1 (1)
@ Andy_...
Most RISC cores have a vast set of "registers" - those "high-speed registers" mentioned in the book. These registers are widely interchangeable in the sense that it is possible to select the register your operation is working on. This is the "register based" approach.
In contrast, many classical CISC processors (as well as the PIC16) perform most operations on a single register (WREG or some "accumulator"). Cores with a very limited set (e.g. 4) of registers acting in the accumulator role may still be considered "accumulator based".
And don't be confused by another "accumulator" shown in many core diagrams: the "arithmetic unit's" intermediate results register may be called accumulator as well.

Most times the bug is in front of the keyboard.
#6
Andy_Taiwanese
Super Member
  • Total Posts : 408
  • Reward points : 0
  • Joined: 2014/12/19 02:59:38
  • Location: 0
  • Status: offline
Re: The specifier "register" in the standard C 2017/12/07 03:20:36 (permalink)
0
To du00000001:
These registers are widely interchangeable in the sense that it is possible to select the register your operation is working on.

Excuse me, I don't really know this sentence. Can you give me an example?
In contrast, many classical CISC processors (as well as the PIC16)

In my opinion, PIC16 is the RISC(Reduced Instruction Set Computing)
Cores with a very limited set (e.g. 4) of registers acting in the accumulator role may still be considered "accumulator based".

I don't know how to interpret "in the accumulator role". Sorry for that.
#7
du00000001
Just Some Member
  • Total Posts : 1434
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: online
Re: The specifier "register" in the standard C 2017/12/07 03:48:10 (permalink)
+1 (1)
Take some ARM with 8 (or more?) "general purpose registers". There the instructions incorporate some bit field to hold the address of the register(s) affected by the operation.
Very symbolic:
MOV.w R0, [RAM address]
MOV.w R2, ...
etc. is the ever-same MOV instruction (here word-wide) - applicable on any of the general purpose registers.
("General purpose" as there is often another set of registers with "not-so-general" applicability - e.g. to allow for indexed and indirect addressing. These registers might not be applicable for basic math operations.)
 
You're absolutely right about the PIC16 being RISC. It's so risc'y that it only incorporates the accumulator-based core known very well from the "smaller" CISC machines like 8051, 680x, 6502 etc.
 
"accumulator role" == acts like an accumulator. Here I referenced to architectures that may not have a single accumulator but 4 registers that are interchangeable to some extend. The term "register based architecture" is usually applied on cores with 8+ registers.

Most times the bug is in front of the keyboard.
#8
mlp
boots too small
  • Total Posts : 523
  • Reward points : 0
  • Joined: 2012/09/10 15:12:07
  • Location: Microchip XC8 and XCLM team
  • Status: offline
Re: The specifier "register" in the standard C 2017/12/07 08:02:03 (permalink)
+1 (1)
Andy_Taiwanese
In contrast, many classical CISC processors (as well as the PIC16)

In my opinion, PIC16 is the RISC(Reduced Instruction Set Computing)

In my opinion, your opinion is wrong.
 
The instruction sets of the 8-bit PICs are small, but the architecture lacks most of the features of RISC - see https://en.wikipedia.org/wiki/Reduced_instruction_set_computer and in particular the section "Instruction set philosophy".
 

Please, before you post, read the Forum Guidelines
To get a useful answer, always state which PIC you are using!
 
Mark (not paid to state the opinions of Microchip Technology Inc.)


#9
du00000001
Just Some Member
  • Total Posts : 1434
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: online
Re: The specifier "register" in the standard C 2017/12/07 08:20:20 (permalink)
0
@ mlp
The PIC16s were sold as RISC, although they lack some of the features of full-blown modern RISC cores. But I wouldn't consider them CISC as they are e.g. lacking features like indexed/indirect addressing. (OK - you CAN have these features. But only via "very special" hardware support.)

It may be a bit irritating as a number of features might seem to indicate they are not RISC (such as the 4 clock cycles per instruction). But honestly: most modern RISC machines take at least 2 clock cycles per instruction (or are active at both clock edges - which in effect is the same as a doubled clock rate). But overall they are RISCier than CISC Smile

Most times the bug is in front of the keyboard.
#10
NKurzman
A Guy on the Net
  • Total Posts : 15127
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: The specifier "register" in the standard C 2017/12/07 11:33:14 (permalink)
0
Mark:
 Microchip Marketing claimed the PIC16/18 was RISC, back when it was Sexy.  The PIC CORE Predates the RISC "fad".  But It is its own Odd Duck.  More RISC than that CISC.  (More Peripheral that CORE)  But really neither.
#11
Aussie Susan
Super Member
  • Total Posts : 2922
  • Reward points : 0
  • Joined: 2008/08/18 22:20:40
  • Location: Melbourne, Australia
  • Status: offline
Re: The specifier "register" in the standard C 2017/12/07 18:10:17 (permalink)
+2 (2)
"Microchip Marketing..." - I stopped reading at that point: marketing departments will say anything!
Susan
#12
NKurzman
A Guy on the Net
  • Total Posts : 15127
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: The specifier "register" in the standard C 2017/12/07 18:44:27 (permalink)
0
Aussie Susan
"Microchip Marketing..." - I stopped reading at that point: marketing departments will say anything!Susan

Like Real-ICE?
#13
mlp
boots too small
  • Total Posts : 523
  • Reward points : 0
  • Joined: 2012/09/10 15:12:07
  • Location: Microchip XC8 and XCLM team
  • Status: offline
Re: The specifier "register" in the standard C 2017/12/08 09:12:37 (permalink)
+1 (1)
du00000001
@ mlp
The PIC16s were sold as RISC

 
If you call its tail a leg, how many legs does a horse have?
(Hint: it's not 5.)
 
See also Neil's and Susan's posts.
 
But overall they are RISCier than CISC

We'll have to agree to disagree there.
I don't see it as a binary partitioning - it is possible to have something that is neither Complex nor Reduced but merely limited.

Please, before you post, read the Forum Guidelines
To get a useful answer, always state which PIC you are using!
 
Mark (not paid to state the opinions of Microchip Technology Inc.)


#14
du00000001
Just Some Member
  • Total Posts : 1434
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: online
Re: The specifier "register" in the standard C 2017/12/08 09:17:14 (permalink)
0
OK - so the PIC16 is some LISC (Limited Instruction Set Computer).
Or - maybe - a VLISC ???

Most times the bug is in front of the keyboard.
#15
jack@kksound
code tags!
  • Total Posts : 2116
  • Reward points : 0
  • Joined: 2014/05/14 10:03:19
  • Location: 0
  • Status: offline
Re: The specifier "register" in the standard C 2017/12/08 10:08:50 (permalink)
+1 (1)
Does it really matter (except in possibly some acedemic way) what catagory we pigeon hole the parts? Always has seemed like a silly thing to worry about to me....IMHO
#16
NKurzman
A Guy on the Net
  • Total Posts : 15127
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: The specifier "register" in the standard C 2017/12/08 10:13:44 (permalink)
+1 (1)
du00000001
OK - so the PIC16 is some LISC (Limited Instruction Set Computer).
Or - maybe - a VLISC ???


LISC (Lame Instruction Set Computer)?
 
I agree it is Not real RISC and, that what marketing says may not be true.
The PIC is in it own Niche Category.
 
#17
Gort2015
Klaatu Barada Nikto
  • Total Posts : 1551
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: offline
Re: The specifier "register" in the standard C 2017/12/09 12:22:43 (permalink)
0
Ignore the accumulator, it's only relevant if you are programming in assembly.

MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
https://www.youtube.com/watch?v=Iu1qa8N2ID0
+ ST:Continues, "What Ships are Made for", Q's back.
#18
Jump to:
© 2017 APG vNext Commercial Version 4.5