From d187fbfc00db1f52e481b39f20bc760dc96011fc Mon Sep 17 00:00:00 2001 From: gautam-dev-maker Date: Sat, 18 Dec 2021 15:17:04 +0530 Subject: [PATCH 1/2] Adds Cross Compilations section in Week 2 --- week2/week2.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/week2/week2.md b/week2/week2.md index eab6310..2f6fabd 100644 --- a/week2/week2.md +++ b/week2/week2.md @@ -7,11 +7,14 @@ - [Compiling](#compiling) - [Assembly](#assembly) - [Linking](#linking) + - [Cross Compilation](#cross-compilation) - [Header files](#header-files) - [Object and source files in C: .o and .c](#object-and-source-files-in-c-o-and-c) - [Brief overview of GNU Make and CMake build systems](#brief-overview-of-gnu-make-and-cmake-build-systems) - [GNU Make](#gnu-make) - [Ninja](#ninja) + - [Basic specifications :](#basic-specifications-) + - [Note :](#note-) - [CMake](#cmake) - [Memory allocation in C](#memory-allocation-in-c) - [Static](#static) @@ -209,6 +212,12 @@ So, in the above program we only have a single .c file then why did we need to l Now, we can run the generated binary: `./main` and then output will be `23`. +### Cross Compilation + +- A cross-compiler is a tool that transforms source code into object code that will run on a machine other than the one where the compilation was executed. +- For example, a compiler that runs on a PC but generates code that runs on Android smartphone is a cross compiler. +- Embedded computers where a device has extremely limited resources. For example, a microwave oven will have an extremely small computer to read its keypad and door sensor, provide output to a digital display and speaker, and to control the machinery for cooking food. This computer is generally not powerful enough to run a compiler, a file system, or a development environment. So cross compiled binaries can be flashed on the system. + ### Header files - As we all know that files with .h extension are called header files in C. These header files generally contain function declarations which we can be used in our main C program, like for e.g. there is need to include stdio.h in our C program to use function printf() in the program. From fd1bc507045cc413527ae049b9ac35fe5905e7ab Mon Sep 17 00:00:00 2001 From: gautam-dev-maker Date: Sat, 18 Dec 2021 15:39:14 +0530 Subject: [PATCH 2/2] Adds Basics of Interpreter --- week2/week2.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/week2/week2.md b/week2/week2.md index 2f6fabd..37125c1 100644 --- a/week2/week2.md +++ b/week2/week2.md @@ -20,6 +20,7 @@ - [Static](#static) - [Automatic](#automatic) - [Dynamic](#dynamic) + - [Basics of Interpreter](#basics-of-interpreter) - [Assignment](#assignment) ## Basics of Embedded Programming @@ -626,6 +627,22 @@ For example, if you want to allocate dynamically some space to hold a struct foo } ``` +## Basics of Interpreter + +- Interpreter is a computer program that directly executes instructions written in a programming or scripting language, without requiring them previously to have been compiled into a machine language program. +- An interpreter generally uses one of the following strategies for program execution: + + - Parse the source code and perform its behavior directly. Ex:- dBASE and BASIC + - Translate source code into some efficient intermediate representation or object code (ex bytecode) and immediately execute that. Ex:- Java + +- Interpreting a program is much slower than executing native machine code +- Interpreting a high-level language is ~100 times slower +Interpreting an intermediate-level (such as JVM bytecode) language is ~10 slower +- If an instruction is called repeatedly, it will be analysed repeatedly - time-consuming! + +*JVM (Java Virtual Machine) is a program which accepts and runs Java bytecode on computers. The Sun's official implementation of JVM is mostly written in C/C++.* + ## Assignment * [Assignment 2](../assets/week2/embedded_assignment_2.pdf) +