CPU > MPU > MCU
CPU = Central Processing Unit
DSP = Digital Processing Procossing/Unit
MPU = Micro Processor Unit
MCU = Micro Controller Unit
RTOS = Real Time Operating System
For MPU, Integrity、QNX、VxWorks
For MCU, Nucleus、ThreadX、Unison OS、ucOS II/III
Reference:
https://www.digitimes.com.tw/iot/article.asp?cat=130&cat1=45&cat2=25&id=0000424643_ee45qu335sxgr42fqo53o
Saturday, October 20, 2018
Friday, October 19, 2018
Learning C
This post is for recording the learning process of C.
The bootloaders are generally written in 16-bit assembly(also called Real mode), then the bits can be extended to 32-bit(Protected mode).
So the bootloaders must be written in 16-bit assembly.
https://createyourownos.blogspot.com/
Download Required:
NASM assember
https://www.nasm.us/docs.php
QEMU simulator
https://qemu.weilnetz.de/
Start from the very beginning - Bootloader
Bootloader is a piece of program that runs before any operating system is running.The bootloaders are generally written in 16-bit assembly(also called Real mode), then the bits can be extended to 32-bit(Protected mode).
So the bootloaders must be written in 16-bit assembly.
https://createyourownos.blogspot.com/
Download Required:
NASM assember
https://www.nasm.us/docs.php
QEMU simulator
https://qemu.weilnetz.de/
Chosen Compiler
Grammar
#include <stdio.h> //library to run printf & scanf
int main() // int is keyword and main is the identifier. Main identifier is must for C programming. Main identifier is a integer, so at last return 0 inside the container means the main identifier is 0 so the program end
{ // a container start
printf(" Hello, World!") ; //printf is output function , the " ; " is a must for each statement
return 0; // "; " always here even at the end
} // a container end
Keywords
auto | double | int | struct |
break | else | long | switch |
case | enum | register | typedef |
char | extern | return | union |
continue | for | signed | void |
do | if | static | while |
default | goto | sizeof | volatile |
const | float | short | unsigned |
Identifier
Rules for writing an identifier
1.) A valid identifier can have letters (both uppercase and lowercase letters), digits and underscores.
2.) The first letter of an identifier should be either a letter or an underscore. However, it is discouraged to start an identifier name with an underscore.
3.) There is no rule on length of an identifier. However, the first 31 characters of identifiers are discriminated by the compiler.
Variables and Constants
Variables:
{ ...int examresult = 95; // exam result is variable
...}
Rules for naming a variable in C
1.) A variable name can have letters (both uppercase and lowercase letters), digits and underscore only.
2.) The first letter of a variable should be either a letter or an underscore. However, it is discouraged to start variable name with an underscore. It is because variable name that starts with an underscore can conflict with system name and may cause error.
3.) There is no rule on how long a variable can be. However, only the first 31 characters of a variable are checked by the compiler. So, the first 31 letters of two variables in a program should be different.
Constants:
{ ...const double PI = 3.14 // PI is constant
...}
Different types of constants
- Integer constants
- decimal constant(base 10) : 0, -9, 22 etc
- octal constant(base 8): 021, 077, 033 etc
- hexadecimal constant(base 16): 0x7f, 0x2a, 0x521 etc
- Floating-point constants
- Numeric constant that has either a fractional form or an exponent form
- e.g. -2.0, 0.0000234, -0.22E-5
- Character constants
- a constant which uses single quotation around characters. For example: 'a', 'l', 'm', 'F'
- Escape Sequences
Escape Sequences Character \b Backspace \f Form feed \n Newline \r Return \t Horizontal tab \v Vertical tab \\ Backslash \' Single quotation mark \" Double quotation mark \? Question mark \0 Null character - String constants
- "good" //string constant
- "" //null string constant
- " " //string constant of six white space
- "x" //string constant having single character.
- "Earth is round\n" //prints string with newline
- Enumeration constants
- enum color {yellow, green, black, white};
- Here, color is a variable and yellow, green, black and white are the enumeration constants having value 0, 1, 2 and 3 respectively
Data Types
- Fundamental Data Types
- Integer types
- Floating type
- Character type
- Derived Data Types
- Arrays
- Pointers
- Structures
- Enumeration
Qualifiers alters the meaning of base data types to yield a new data type
- Size qualifiers
- long double i;
- Sign qualifiers
- unsigned int positiveInteger;
- Constant qualifiers
- const int cost = 20;
- Volatile qualifiers
- A variable should be declared volatile whenever its value can be changed by some external sources outside the program. Keyword volatile is used for creating volatile variables.
E-Book:
Wednesday, October 10, 2018
Subscribe to:
Posts (Atom)