20
32 bit And 64 bit Register manipulation. By RAHEEL NIAZI

32 bit and 64 bit Register manipulation

Embed Size (px)

DESCRIPTION

This presentation made by Raheel Niazi (BScs). Include 32 bit and 64 bit register manipulation in Assembly Language

Citation preview

Page 1: 32 bit and 64 bit Register manipulation

32 bit And 64 bit Register manipulation.

ByRAHEEL NIAZI

Page 2: 32 bit and 64 bit Register manipulation

RegisterIn computer architecture, a

processor register is a very fast computer memory used to speed the execution of computer programs by providing quick access to commonly used values-typically, the values being in the midst of a calculation at a given point in time.

Page 3: 32 bit and 64 bit Register manipulation

Purpose of Register ManipulationAs we know the register is the fastest

accessible memory for the processor by using the register we can execute our program more faster than the secondary memory. Using Register also make the supremacy to Assembly language to other programming language.

Page 4: 32 bit and 64 bit Register manipulation

TYPES OF 32-bit registersEax (extended accumulator register) ebx (extended base register) ecx (extended counter register) edx (extended data register) esi(  Extended Source Index register) edi(Extended destination Index register) ebp(Extended base pointer) esp (stack pointer register)

Page 5: 32 bit and 64 bit Register manipulation

VolatilityVolatile: ecx, edxNon-Volatile: ebx, esi, edi, ebpSpecial: eax, esp.

Page 6: 32 bit and 64 bit Register manipulation

Register to Register Why we do not use Memory to Memory

Instruction?The reason is that in secondary memory the

data is stored by name or address of binary numbers, when address bus retrieve a first data from memory for second it goes again to the memory and get the empty that’s why address bus must need a register for the first data it stores the first data in register and then it can retrieve the second data from secondary memory.

Page 7: 32 bit and 64 bit Register manipulation

32 bit and 64 bit Register Difference32bit CPUs process data in 32-bit chunks,

while 64bit CPUs process data in 64-bit chunks.

Page 8: 32 bit and 64 bit Register manipulation

32 bit Registers RepresentationIn assembly language the 32 bit register are

often represented by “e” extended for example eax extended accumulator register.

Page 9: 32 bit and 64 bit Register manipulation

Arithmetic Operation by 32 bit register Mov eax, 12 Mov ebx , 10 Sub eax, rax_______________________________________________ mov eax , 12 mov ebx, 10 Imul eax, ebx

Page 10: 32 bit and 64 bit Register manipulation

Jump statement for 32 bit l1: mov eax , 12 mov ebx, 11 cmp eax, ebx je L1 jne L2 L1: add eax , ebx PRINT_DEC 2,eax NEWLINE PRINT_STRING "The values are not equal that's why L2 is activated" L2: sub eax , ebx PRINT_DEC 2, eax NEWLINE PRINT_STRING "The values are not equal that's why L2 is activated"

Page 11: 32 bit and 64 bit Register manipulation

Jump statement for 32 bit

Page 12: 32 bit and 64 bit Register manipulation

Factorial Program Example For 32 bit section .data num1 dw 1 num2 dw 5 section .text mov ecx,[num1] mov ebx,[num2] lab1: imul ecx,ebx dec ebx cmp ebx,1 je lab jne lab1 lab: PRINT_DEC 2,cx PRINT_STRING " : The Given Number of factorial Program Has been Terminated" xor eax, eax ret

Page 13: 32 bit and 64 bit Register manipulation

Factorial Program example by 32 bit executed

Page 14: 32 bit and 64 bit Register manipulation

64 bit register A 64-bit register is made by concatenating a

pair of 32-bit registers. This is shown by putting a colon between them.

The most common 64-bit register (used for operations such as division and multiplication) is edx:eax. This means that the 32-bits of eax are put in front of the 32-bits of eax, creating a double-long register,. We can also use rax for 64 bit register.

Page 15: 32 bit and 64 bit Register manipulation

64 bit Register RepresentationIn assembly the 64 bit register can be

represented by “r” as prefix.E.g. rax, rbx, rcx ,rdx etc.

Page 16: 32 bit and 64 bit Register manipulation

Arithmetic Operation by 64 bit register Mov rax, 12 Mov rbx , 10 Sub rax, rax_______________________________________________ Mov rax , 12 Mov rbx, 10 Imul rax, rbx

Page 17: 32 bit and 64 bit Register manipulation

Arithmetic operations by 64 bit register

Page 18: 32 bit and 64 bit Register manipulation

JUMP for 64 bit l1: mov rax , 12 mov rbx, 11 cmp rax, rbx je L1 jne L2 L1: add rax , rbx PRINT_DEC 2,rax NEWLINE PRINT_STRING "The values are not equal that's why L2 is activated" L2: sub rax ,rbx PRINT_DEC 2,rax NEWLINE PRINT_STRING "The values are not equal that's why L2 is activated"

Page 19: 32 bit and 64 bit Register manipulation

FACTORIAL CODE FOR 64 bit section .data num1 dw 1 num2 dw 5 section .text mov rcx,[num1] mov rbx,[num2] lab1: imul rcx, rbx dec rbx cmp rbx,1 je lab jne lab1 lab: PRINT_DEC 2,cx PRINT_STRING " : The Given Number of factorial Program Has been Terminated" xor eax, eax ret

Page 20: 32 bit and 64 bit Register manipulation

Factorial Program example by 64 bit executed