Mobile Security Platform

ARM assembly vol1


ARM64 assembly language is a low-level programming language used for the ARMv8 architecture, which supports 64-bit and 32-bit processing. ARM is a widely used in mobile devices, embedded systems, and even some server environments due to its power efficiency and performance. Before we begin, there are such things to know for sake of this blog. Let’s take a look at them.

CPU(Central Processing Unit): the primary component of a computer that performs most of the processing inside the system. the CPU is responsible for executing instructions. Your desktop/laptop/video-game-console/etc is controlled by a CPU. A CPU doesn’t understand any Human Language, but a CPU can understand two things. 0 and 1.These are known as Binary numbers. CPU will perform tasks based on receiving fixed or variable length blocks that are made up of certain combinations of 0’s and 1’s. These blocks are known as CPU Instructions. I think this is pretty obvious that attempting to make a program writing these blocks is pain in the ass! So that is where we use what is called Assembly Language

Assembly Language: Assembly language is a low-level programming language that is closely related to machine code, the set of binary instructions(0 and 1) that a computer’s CPU executes directly. This is different than high-level programming languages, assembly language provides direct control over the hardware and allows programmer to write instructions that the CPU can execute. Enough with bullshit!

HEX: the 0’s and 1’s that a CPU can understand are called Binary Numbers. Binary Numbers are the simplest/lowest number form. A Binary value is also known as a Bit. Bits can only be 0 or 1, nothing else. Before you can understand Binary, you will need to learn Hexadecimal. First off, regular Decimal is something you already know. It’s the basic numbers that everyone uses on a regular basis. Such as 3, 16, 2057, 5168430, etc. The regular Decimal number system uses what is called Base 10. You start at 0 and go to 9. After 9, you must start a new “base of 10”. This new base starts at 10 and goes thru 19. After 19, you have to start another new base of 10 at the number 20. Hexadecimal uses a Base 16 system. Similar to decimal, you start with 0. However, once you get to 9, you proceed to A, the first letter of the English Alphabet. You keep proceeding through the Alphabet til you hit F. 0 thru F are 16 total numbers/values. This is the first “base of 16” After F, you can then go to 10. 10 thru 1F is the next “Base of 16”. After that would be 20 thru 2F, etc etc.
Here are some Hexadecimal digits represented by 4 consecutive binary values:
Hex -Binary
0—->0000
1—->0001
2 —-> 0010
3 —-> 0011
3 —-> 0011
4 —-> 0100

P.S: Hex values present in an Assembly Source file are always designated via a “0x”. For example, the Hex Value BC needs to be written as 0xBC.
Some Special terms that is good to know:
8 Bits = Byte (2 Hex digits) Example: 0x44
16 Bits = Halfword (4 Hex digits) Example: 0xB0C8
32 Bits = Word (8 Hex digits) Example: 0xDEDD0020
64 Bits = Double-Word (16 Hex digits)
128 Bits = Quadword (32 Hex digits)

As an example:
0x8045CD0A
The “8045” portion (lefthand 16-bits) of the word value is known as the upper 16-bits. The “CD0A” portion (righthand 16-bits) is known as the lower 16-bits. Another example, we have the following double-word value:
0xFFFFFFFF80007774
The “FFFFFFFF” portion is known as the upper 32-bits and the “80007774” portion is known as the lower 32-bits.
Lefthand = upper
righthand = lower.

Memory: CPU’s all instructions will reside in Memory. There are two types of memory- Static and Dynamic.
The region of Memory where a CPU’s instructions reside at is usually called Static or Main. It’s named Static because every time a specific program is executed by the CPU, the CPU instructions are usually placed at the same locations within Static Memory every single time.
The region of Memory where Data is kept at is usually called Dynamic or Heap. It’s called Dynamic because every time a specific program is executed/launched by the CPU, the Data may not be at the same location it was present at the time before.
Locations in Memory are called Memory Addresses

References:

https://mariokartwii.com/armv8/

Home