Questions tagged [assembly]

A family of very low-level programming languages, just above machine code, where each statement corresponds to a single machine code instruction.

Assembly is a family of very low-level programming languages, just above machine code. In assembly, each statement corresponds to a single machine code instruction. These instructions are converted into executable machine code by a utility program referred to as an [assembler][1]; the conversion process is referred to as assembly, or assembling the code.

Language design

Basic elements

There is a large degree of diversity in the way that assemblers categorize statements and in the nomenclature that they use. In particular, some describe anything other than a machine mnemonic or extended mnemonic as a pseudo-operation (pseudo-op). A typical assembly language consists of three types of instruction statements that are used to define program operations:

  • [Opcode][2] mnemonics
  • Data sections
  • Assembly directives

Opcode mnemonics and extended mnemonics

Instructions (statements) in assembly language are generally very simple, unlike those in [high-level language][3]. Generally, a mnemonic is a symbolic name for a single executable machine language instruction (an opcode), and there is at least one opcode mnemonic defined for each machine language instruction. Each instruction typically consists of an operation or opcode plus zero or more [operands][4]. Most instructions refer to a single value, or a pair of values. Operands can be immediate (value coded in the instruction itself), registers specified in the instruction or implied, or the addresses of data located elsewhere in storage. This is determined by the underlying processor architecture: the assembler merely reflects how this architecture works. Extended mnemonics are often used to specify a combination of an opcode with a specific operand. For example, the System/360 assemblers use B as an extended mnemonic for BC with a mask of 15 and NOP for BC with a mask of 0.

Extended mnemonics are often used to support specialized uses of instructions, often for purposes not obvious from the instruction name. For example, many CPU's do not have an explicit NOP instruction, but do have instructions that can be used for the purpose. In 8086 CPUs the instruction xchg ax,ax is used for nop, with nop being a pseudo-opcode to encode the instruction xchg ax,ax. Some disassemblers recognize this and will decode the xchg ax,ax instruction as nop. Similarly, IBM assemblers for System/360 and System/370 use the extended mnemonics NOP and NOPR for BC and BCR with zero masks. For the SPARC architecture, these are known as synthetic instructions

Some assemblers also support simple built-in macro-instructions that generate two or more machine instructions. For instance, with some Z80 assemblers the instruction ld hl,bc is recognized to generate ld l,c followed by ld h,b. These are sometimes known as pseudo-opcodes.

830 questions
16
votes
3 answers

Purpose of OR EAX,0xFFFFFFFF

I have read the assembly line OR EAX, 0xFFFFFFFF and in the register EAX the program has stored a string. I have problems to understand how we can make a comparison with a string and a value like that. After performing that instruction, EAX has…
user3097712
  • 1,541
  • 1
  • 25
  • 44
7
votes
2 answers

What is the meaning of kernel32.BaseThreadInitThunk?

I tried to analyze a program in assembly using ollydbg. In the first line I have the following: MOV EAX, DWORD PTR FS:[0] In the register window, I've got the information: EAX 7570EE0A kernel32.BaseThreadInitThunk and in another window about FS…
user3097712
  • 1,541
  • 1
  • 25
  • 44
6
votes
1 answer

Relocation table patching

Now working on binary analysis of PE and stuck on tricky (for me), ungoogleable question. For instance, I've binary, that needs to be patched. So after doing that will be awesome, if there is way to insert address of my function to relocation table.…
see ya
  • 823
  • 2
  • 8
  • 20
6
votes
3 answers

What does ds mean in mov instruction?

I am reversing a 32-bits ELF executable. I see something like: mov al, byte ptr ds:xxxxx xxxxx is an absolute address. What is the meaning of ds here?
Bob5421
  • 797
  • 1
  • 9
  • 20
4
votes
1 answer

Understanding assembly loop

I am having trouble understanding how this code knows when to stop looping. I am supposed to figure out what values are put into %edi. But I can't figure out how many times it loops. 0x40106e movl $0x2b,0xffffffdc(%ebp) 0x401075 movl …
duder
  • 81
  • 5
4
votes
2 answers

Tutorial or resource for understanding obscure Assembly idioms?

Assembly seems to have lots of tricks. Set a register to zero (xor reg, reg) Extend the stack by only four bytes (push/pop ecx) Setting a regiseter to -1 (OR reg -1) Mulitiplying by powers of two with bit shifting, or n**2+1 with LEA Is there a…
Evan Carroll
  • 1,779
  • 1
  • 18
  • 50
4
votes
3 answers

REPL for x86 assembly?

New to assembly here. Most dynamic languages have REPLs these days and they're great. I really want a tool like that for x86. Is there any thing open source on the table? Even if it's compiling everything from the start and running it a new or…
Evan Carroll
  • 1,779
  • 1
  • 18
  • 50
4
votes
1 answer

Stack buffer size is different between C and ASM

Given that function: void vuln( char * arg ) { char buf[256]; strcpy(buf, arg); } Disassembled in: 0x0804842b 55 push ebp …
Kartone
  • 439
  • 4
  • 14
3
votes
1 answer

What is the meaning of 00406434 dword_406434 dd 0?

I have the following line in IDA PRO: CODE: 00406434 dword_406434 dd 0 I know that dword_406434 is a place where a value is stored. So, my question is: First : What is that "dd" in that line ? Second: And is the 0 the value stored at…
user3097712
  • 1,541
  • 1
  • 25
  • 44
3
votes
1 answer

How can I interpret mov ds:dword_4870058 , offset loc_4048E0?

I have the following assembly line and I have my problems to understand it, because until now I have always seen lines like this: mov eax, 0 and so on. But now, I have the following (I use IDA PRO): mov ds:dword_4870058 , offset loc_4048E0 When I…
user3097712
  • 1,541
  • 1
  • 25
  • 44
3
votes
2 answers

Understanding of some assembly lines

i have the following assembly lines: .... LEA EAX, DWORD PTR DS:[0x404212] MOV DWORD PTR SS:[EBP-0x3CC], EAX PUSH DWORD PTR SS:[EBP-0x3CC] ... ... ... LEA EAX, DWORD PTR DS:[0x404213] MOV DWORD PTR SS:[EBP-0x3D0], EAX PUSH DWORD PTR…
user3097712
  • 1,541
  • 1
  • 25
  • 44
3
votes
2 answers

Has XOR EAX, EBX another purpose?

I have the following line in an assembler code: XOR EAX, EBX So, then I've searched a little bit and found out that XOR represents a "swap algorithm". You can read it here: http://en.wikipedia.org/wiki/XOR_swap_algorithm But when I look in…
user3097712
  • 1,541
  • 1
  • 25
  • 44
3
votes
0 answers

Is it legal in the US to reverse engineer a product and then share the CAD for free to whoever needs it?

First some background. I have this 3D printer that sucks, is pretty expensive, and unreliable. Whenever you need a spare part, the manufacturer sells you the entire kit! I needed a thermistor and they wanted to sell me the entire kit for $250, not…
3
votes
1 answer

Can the return value of this function be determined with static analysis?

I have an assignment and I tried solving it. However I can't seem to solve it, despite double checking everything and investing multiple hours. My task is to reverse engineer the following functions to high-level C-code and determine the return…
3
votes
2 answers

How to use the book "Reverse Engineering for Beginners" by Yurichev?

I just finished skimming the book Art of Assembly by Randall Hyde. So now to get my feet wet in assembly/reverse engineering reading, I started the book Reverse Engineering for Beginners. The thing is when I write C samples and produce assembly code…
Krsh
  • 31
  • 1
1
2 3 4 5