Questions about this topic? Sign up to ask in the talk tab.
Difference between revisions of "Assembly"
From NetSec
(→Binary) |
(→Data storage) |
||
Line 28: | Line 28: | ||
== Data storage == | == Data storage == | ||
− | + | === register === | |
− | + | A location where memory can be stored temporarily. A register has the bit-width of a cpu's bit description. So for 32 bit systems, a register is 32 bits (4 bytes or a doubleword, also called long) whereas on a 64 bit system a register is 64 bits in length (8 bytes or a qword). | |
− | + | === pointer === | |
− | + | An address that points to another location in memory | |
− | * architecture-specific registers | + | === sub-register === |
+ | A portion of another register always divisible by 8 bits (1 byte) in size | ||
+ | === cpu flag registers === | ||
+ | * pflag | ||
+ | * zflag | ||
+ | === architecture-specific registers === | ||
+ | ==== x86 ==== | ||
+ | =====32 bit general purpose===== | ||
+ | * eax | ||
+ | * ebp | ||
+ | |||
+ | =====64 bit general purpose===== | ||
+ | * rax | ||
+ | * r8-15 | ||
+ | |||
+ | =====mmx===== | ||
+ | =====sse===== | ||
== Memory Addressing == | == Memory Addressing == |
Revision as of 03:36, 21 May 2012
Assembly requires a basic understanding of bitwise math |
Contents
Introduction
- assembler - An assembler is a program that compiles human-readable operations into instructions interpreted by the processor
- linker - A linker is a program that combines the compiled assembly objects into a binary. 'ld' is the standard linker on Linux platforms.
Compilers such as GCC/CC do both operations dynamically.
- Assemble-time: Assembly & operands -> Opcode Sequence
- Link-time: Flat binary of opcode sequence -> executable file format for OS
- Runtime: Opcode Sequence -> hardware gates (may interact with ram etc)
Binary
- Main article: [[Bitwise Math]]
- counting
- endianness
- nybble - An uncommon unit of memory equivalent to 4 bits.
- byte - A byte is a unit of memory equivalent to 8 bits.
- word - 2 bytes
- dword - 4 bytes, also called a long
- qword - 8 bytes
Number handling
- signed - Signed values are required to represent negative numbers. Most languages by default assume values are signed. The range of numbers it can assign extends from -1 downwards, depending on the data type.
- unsigned - Despite not being able to assign negative numbers, unsigned values are particularly advantageous for positive ranges. The memory that would have been assigned to the negative range is instead added to the positive range (twice as many positive numbers).
- 2's compliment
Data storage
register
A location where memory can be stored temporarily. A register has the bit-width of a cpu's bit description. So for 32 bit systems, a register is 32 bits (4 bytes or a doubleword, also called long) whereas on a 64 bit system a register is 64 bits in length (8 bytes or a qword).
pointer
An address that points to another location in memory
sub-register
A portion of another register always divisible by 8 bits (1 byte) in size
cpu flag registers
- pflag
- zflag
architecture-specific registers
x86
32 bit general purpose
- eax
- ebp
64 bit general purpose
- rax
- r8-15
mmx
sse
Memory Addressing
- stack pointer - A pointer that points to a location on the stack
- instruction pointer
- base pointer
- addressing mode
- index
Instructions
Syntaxes
- Intel (dest, src)
- ATT (src, dest)
Data manipulation basic primitives
- mov
- push
- pop
Basic arithmetic
- add
- sub
- div
- mul
Bitwise mathematics operators
- and
- not
- or
- xor
Shifts and rotations
- shl
- shr
- rol
- ror
Control flow operators
- cmp
- jmp
- call
- ret
Taking it further
- kernel interrupt
- architecture - i386, i686, x86_64
- operating system