Pointers - Com Sci
Pointers - Com Sci
Key Definitions:
Algorithm – refers to the finite number of precise steps in which the flow of control of processes
CPU – the central processing unit (CPU) is a microprocessor consisting of millions or billions of
transistors, resistors, and diodes that are used to execute high-speed tasks for each clock cycle,
serving as the logical brain of the computer system (handles program logic through arithmetic
Registers – small capacity, high-speed primary memory units located on the CPU, holding
cycle.
Instruction set – refers to the different types of processes that a CPU can perform during the
machine cycle. It speaks to the lexicon of possible instructions that the CPU can perform within
it’s circuitry. For example, arithmetic, logic, and data-transfer operations can be executed based
detailing how the CPU interacts with hardware components (main memory) to execute
the control unit based on system architecture (x86, ARM). An instruction format features binary
by Leo~
segments that represent addressing modes (immediate, direct, and indirect), opcode (details the
operation for execution like ADD, MUL, MOV, PUSH), and operands (computable terms like
Byte – the smallest number of bits representing a single character, typically (7-8 bits). It is the
smallest addressable unit of data within most computer systems (meaning it holds part of an
address).
Word size – refers to the standard number of bytes (chunks) that can be processed within a
by Leo~
3. Can be programmed ONCE after system setup (after first write, fuse will blow, and other
3. It can be reprogrammed MORE THAN ONCE but uses ultraviolet radiation to clear the
Control Structures:
deeper, it speaks to code following the imperative programming paradigm that details
how the program changes throughout execution via assignment or the other two (2)
ii) Selection – involves instructions carried out by a condition. Detailing more, it entails
the use of blocked segments of code that will only be executed based on a specific
iii) Iteration – involves instructions carried out by a loop. Elaborating further, it pertains
unbounded blocks of code only terminating after the sentinel condition is met.
by Leo~
Instruction Cycle/Machine Cycle:
i) Fetch – the Control Unit (CU) signals the Program Counter (PC) to retrieve the
address of the next instruction to be executed from main memory down the address
bus. After that, the address is copied to the Memory Address Register (MAR) and
then the Current Instruction Register (CIR) is flagged to fetch the instruction located
at the address of the MAR. Lastly, the PC increments to the next address.
ii) Decode – the CU will now evaluate the instruction stored in the CIR by using the
processing; x86 vs ARM-64). The instruction is analysed for its addressing mode
opcode (ADD, MUL, PUSH, MOV) and operands (immediate values or registers
storing addresses).
iii) Execute – the CU signals the relevant register to process the decoded instruction and
will write the computed information back to main memory via the Memory
like loading the value stored at an address into a register, the MDR can also read the
corresponding data stored in main memory. For instance, LOAD R1, 0x1000.
Steps in Problem-Solving:
for the identified issue for unambiguity. Moreover, it also features a general solution to
by Leo~
2. Problem Analysis – involves analysing the general solution identified to create an
3. Identify & Evaluate Possible Solutions – involves brainstorming for other plausible
solutions to the problem statement and categorizing them for their advantages and
4. Select and Justify the Optimal Solution – at this stage, the programmer selects each
5. Implementation & Review – the last stage entails the programmer converting the
program state by testing/debugging variables and how they interact with each other in
Translation Process:
1. Lexical Analysis – this compilation stage features the lexer (lexical analyzer) breaking
down program code into tokens categorized by a symbol table of deemed identifiers
(variables, expressions, data structures), scope (global vs local), data types, memory
addresses, and other information (like function arguments). Moreover, it also removes
whitespaces and comments before proceeding to the next stages that will reference the
2. Syntax Analysis – this stage in the translation process speaks to the use of the symbol
table to generate concrete syntax trees (CSTs) and/or abstract syntax trees (ASTs).
by Leo~
Adding, syntax trees are used to represent blocks of code using nodes (of identifiers) and
evaluates whether or not code fragments are grammatically correct, adhering to the
programming language rules. These syntax trees used will either represent the entire code
using keywords and parentheses (CST) or abstract these concepts into phrases like
this stage whilst ASTs are used in semantic analysis for efficiency.
3. Semantic Analysis – this stage uses the semantic analyzer to annotate syntax trees (like
ASTs) with error messages due to type mismatch errors (unexpected variable used),
4. Intermediate Code Generation – here, the syntax tree (likely AST) is converted into an
intermediate representation (IR) that lies between a high-level code (human-readable) and
code fragments through the use of explicit address formats (like Three-Address-Code;
TAC) consisting of assignment of temporal variables (t1, t2, t3…), “goto” conditional
branches, and operator keyword (op) [not needed, best to research this part if you’d
like]. This serves to make code optimization much easier when removing inefficient code
elements.
5. Code Optimization – now, this stage makes the IR more efficient in memory allocation
by Leo~
operations, for instance, multiplication being swapped for addition in certain contexts for
improved efficiency).
governing instruction processing (x86, ARM), and is stored in object (.o) files to be
Paradigms refer to the method involved in solving a task. Programming paradigms refer to the
way in which programs are written to solve general problems. There are two paradigms that
Fundamental Paradigms:
implemented. Elaborating further, it details how the program should change it state in a
step-by-step manner via common methods like assignment, selection and iteration
constructs.
by Leo~
2. Declarative Paradigm – specifying WHAT the desired outcome is, rather than detailing
the steps in how to achieve it. It abstracts the program state and its control flow, typically
through immutability and the absence of side-effects (of variables), as seen in the
and Animal) that can be used in sub-classes/derived classes (like Jane Doe and Dog) via
attributes to objects, for e.g., Dog is an animal that barks whilst Cat is an animal that
change its state. Notably, functions also control how variables interact with one another
by using global and local scopes, ensuring information integrity (changes only as
mathematical-like pure functions that simply gives the same desired output from
by Leo~
every repeated input without detailing the mathematical method. Here, variables
(immutable) will not change their state based on conditions or loops but depend
only on the input provided. Moreover, functions are considered as high order
because they can be used as arguments or return values for other functions.
by Leo~