TEAM 04 EVALUTION 02 Ediv
TEAM 04 EVALUTION 02 Ediv
EVALUATION 02
PRABHANJAN
3 551 01FE21BEC359
KATTI
Example code 1
AGENDA
Example code 2
{
register int i asm("ecx"); // inline assembly
// The asm("ecx") part is an inline assembly instruction that informs the compiler to assign the register ecx to the variable i.
if (num <= 1)
{
return 0;
}
for (int i = 2; i < num; i++)
{
if (num % i == 0)
{
return 0;
}
}
}
ARM PROCESSOR AND APPLICATIONS 9
int main()
{
int num;
printf("Enter the number to be checked: ");
scanf("%d",&num);
if (isPrime(num))
{
printf("%d is a prime number.", num);
}
else
{
printf("%d is not a prime number.", num);
}
return 0;
}
USE OF REGISTER
CODE 1 2.265 s 8 bytes
INSTRUCTION
USE OF REGISTER
OPTIMIZED
2.077 s 8 bytes INSTRUCTION WITH
CODE 1
ECX REGISTER
• Code Size Reduction: Register allocation plays a role in reducing the size of
compiled code. By utilizing registers to store and access variables, register
allocation reduces the need for explicit memory access instructions in the
generated code. This leads to a smaller code footprint, which is advantageous in
resource-constrained environments or when optimizing for limited storage
capacity.
• High-Performance Computing (HPC): Register allocation plays a vital role in optimizing code
for HPC applications. It allows for the exploitation of parallel processing capabilities present in
modern processors, enabling efficient utilization of computational resources. By minimizing
memory operations and maximizing register usage, register allocation enhances the performance
of compute-intensive tasks in HPC environments.
return result;
}
int main() {
int x, y, a, b;
return 0;
}
BOOLEAN ALGEBR
CODE 2 5.408 s 24 bytes
A
OPTIMIZED
4.685 s 24 bytes DE'MORGONS LAWS
CODE 2
• Code Size Reduction: Expression simplification helps reduce the size of the
generated code by eliminating unnecessary or redundant code segments. By
streamlining expressions and removing superfluous operations, the resulting
executable becomes more compact. This reduction in code size leads to benefits
such as reduced memory consumption, faster loading times, and improved overall
efficiency, particularly in resource-constrained environments or when deploying
the code on memory-limited devices.