KEMBAR78
Multicore and Assembly Language | PDF | Central Processing Unit | Multi Core Processor
0% found this document useful (0 votes)
10 views31 pages

Multicore and Assembly Language

The document discusses multicore systems, which utilize multiple processors to enhance computing efficiency, and explains the fundamentals of assembly language as a low-level programming interface between high-level code and machine code. It details the basic components of assembly language, including instructions, operands, mnemonics, and registers, as well as the execution cycle of assembly code. Additionally, it covers memory addressing modes and provides examples of basic assembly instructions and their execution process.

Uploaded by

patrickmontero61
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views31 pages

Multicore and Assembly Language

The document discusses multicore systems, which utilize multiple processors to enhance computing efficiency, and explains the fundamentals of assembly language as a low-level programming interface between high-level code and machine code. It details the basic components of assembly language, including instructions, operands, mnemonics, and registers, as well as the execution cycle of assembly code. Additionally, it covers memory addressing modes and provides examples of basic assembly instructions and their execution process.

Uploaded by

patrickmontero61
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

MULTICORE

ASSEMBLY LANGUAGE
How many hours does it takes to complete a
project?

that will depend on how many workers you put


on a task.
the same goes for computing.
put more CPU on the job to share the workload
MULTICORE SYSTEMS
Multicore Systems

Also known as ‘parallel systems’.


has 2 or more processors.
multicore processors consist of multiple processing
units, or ‘cores,’ on a single integrated circuit (IC).
A single core CPU

Does the calculations +, -, x, / and logical


ALU operations like AND, OR, NOT on data
contained in the registers.

CONTROL UNIT Directs the activities of the CPU

REGISTERS Registers provide temporary storage.


0
1 0 1
0 10 0
0 0 1 1
1 0 0 0
1 1 0 0
0 1 1 1
0 0 1 1
1 0 0 0
1 1 0 0
1 1 1
1 1
0 1 1 1

0
1
0
1
1

1
0
1
1
0 1
0
1
1
0
0
1
1
0
1
0
Multicore CPU
0 0 1 0
1 0 0 1
1 1 0 1
0 1 1 0
0 0 1 0
1 0 0 1
1 1 0 1
0 1 0
0 1 0
0 1
0 0
ALU ALU ALU 0 ALU

CONTROL UNIT 1 UNIT


CONTROL CONTROL UNIT CONTROL UNIT
0
1
0
REGISTERS REGISTERS
0 REGISTERS REGISTERS

1
1

0
1 1

1
0

0
0

0
0 1
1

1
1 0
0

1
1
1

0
0
0

0
1
0
1

1
1
0 1

1
1
0
1

1
0

0
1

1
0

1
1
0 1

1
1
1

0
0
1

1
0 1

0
0
0 0

0
1

1
1

0
1

1
0
1 1

0
0

0
0

1
0 1

1
1
1

0
1
0
1
0
1
0
0
1
1
0
0
1
1
1
0
1
1
0
1
0
0
Ever wondered how the
computer actually understand
the code you write?
Interacting directly with the
hardware?
Assembly Language
essential building block for how
computers execute instructions
at the hardware level.
What is an Assembly
Language?
Assembly language is a low-level programming
language that acts as a crucial bridge between the code
we write and the machine code that a computer’s
hardware understands.

Much more closer to the computer’s hardware.


What is an Assembly
Language?
Each instruction in assembly tells the computer to
perform a very specific operation, like moving data
between registers, performing arithmetic or jumping to a
new instruction.
Basic Components of
Assembly Language
Basic Components

1. Instructions - which tell the computer what action to


perform.
2. Operands - which specify the data the instruction
will work on.
3. Mnemonics - human-readable abbreviations like
MOV, ADD or JMP to represent these instructions.
4. Registers - which are small fast storage areas
inside the CPU where data is temporarily held during
operations.
CPU Registers

CPU registers are small, high-speed storage locations


within the processor that hold data and instructions
temporarily during computation.
CPU Registers
GENERAL DATA REGISTERS - which can hold data for
various operations
SPECIAL-PURPOSE REGISTERS - like the instruction
register, which holds the current instruction being
executed and the program counter, which keeps track
of the address of the next instruction.
STATUS REGISTERS- which maintain information
about the current state of the CPU, including flags for
arithmetic operations.
CPU Registers
EXAMPLE:
You want to add two numbers.

The CPU might first load the first number and the second number into another
into a general-purpose register general-purpose register

REGISTER A REGISTER B REGISTER C

10 10 20
Flags in Assembly
Flags are special bits in the CPU that store the results
of operations and help control the flow of a program.

These status flags are updated automatically based on


the outcome of instructions and are used to make
decisions during execution.
Flags in Assembly
Examples:
Zero Flag (ZF) : is set when the result of an operation is
zero.
Carry Flag (CF) : is set if an arithmetic operation
produces a result too large for the register to hold.
Overflow Flag (OF): tracks whether an arithmetic
operation results in an overflow.
Sign Flag (SF): indicates whether the result is negative.
Memory and Addressing
Modes
Memory and Addressing
Modes
Memory refers to the physical locations where data is
kept, allowing programs to retrieve and manipulate
information.
Addressing Modes define the different ways we can
access this memory, determining how the CPU
interprets the addresses in instructions.
Common Addressing Modes
IMMEDIATE
ADD R1, 5 - which adds the value 5 directly to register
R1.
DIRECT
ADD R1, [1000] - where 1000 is the memory address
containing the value to be added to R1.
INDIRECT
ADD R1, [R2] - where register R2 holds the address
of the value to be added to R1.
Basic Assembly Instruction
Basic Assembly Instruction
ARITHMETIC perform mathematical operations
ADD R1, R2 LOGIC handle bitwise operations
SUB R1, R2 AND R1, R2 CONTROL direct program flow
MUL R1, R2 OR R1, R2 JUMP: causes the program to jump to specific point
JMP LABEL
DIV R1, R2 XOR R1, R2 CMP R1, R2 COMPARE: compares the value of R1 and R2
NOT R1 JE LABELS JUMP IS EQUAL: jumps if the values are equal
JUMP IS NOT EQUAL: jumps if the values are not
JNE LABEL equal
Data movement instructions transfer data:
MOV R1, R2 : moves data from R2 to R1.
PUSH R1 : saves R1's value onto the stack
POP R1 : retrieves the last value from the stack.
Basic Assembly Instruction
Bit Manipulation instructions include:
SHL R1 Shift Left: which shifts register's bits left, essentially
multiplying the value by 2
SHR R1 Shift Right: which shifts right, dividing the value by 2.

ROL R1, 1 Rotate Left: Rotates the bits left and right, looping
them back around
ROR R1, 1 Rotate Right:
How Assembly is Executed?
FETCH - DECODE - EXECUTE CYCLE
Assembly Execution
FETCH
the CPU retrieves an instruction from memory, typically
pointed to by the program counter.
If the instruction is SHL R1, 1: The CPU fetches this
command from memory

DECODE
The CPU interprets the fetched instruction, determining what
action is required and identifying the involved operands
such as recognizing that it needs to shift the bits
in R1 to the left by one position.
Assembly Execution
EXECUTE
the CPU carries out the operation as specified by the
instruction.
it shifts the bits of R1 left, effectively multiplying the value by
2.
Example Assembly Code
MOV R1, 5 we start by loading the values 5 and 10 into registers
MOV R2, 10
ADD R3,R1,R2 combines R1,R2 stores results to R3
AND R4, R3,1 identify: even/odd : AND operation (stores the outcome in R4)
MOV R5,’Odd’ Initially, we assume the result is 'Odd' by loading this string into register R5.
CMP R4, 0 Compare R4 to 0
JE even_number
JMP end
even_number: if the result is equal, indicates the SUM is EVEN and will JMP to this to update R5
MOV r5, ‘Even’
end: If the sum is odd, the program skips to this.

You might also like