.LC0:
.string "cat"
.LC1:
.string "./01-tiny-access.log"
.LC2:
.string "grep"
.LC3:
.string "\" [3][0-9][0-9]"
.LC4:
.string "cut"
.LC5:
.string "-d\""
.LC6:
.string "-f6"
.LC7:
.string "awk"
.LC8:
.string "BEGIN {FS =\"[/+.;(0-9)]\"} { print $1 }"
.LC9:
.string "-v"
.LC10:
.string "^-$\\|^\\\\$\\|^http:$\\|^<"
.LC11:
.string "sort"
.LC12:
.string "uniq"
.LC13:
.string "-c"
.LC14:
.string "-nr"
.LC15:
.string "head"
.LC16:
.string "BEGIN { -F \" \" } { count[$2] = $1 } END { for (i in count) { total += count[i] } for (i in count) { printf \"%s - %d - %.2f%% \\n\", i, count[i], count[i]/total*100 } }"
.LC17:
.string "-t "
.LC18:
.string "-k3"
main:
push rbp
mov rbp, rsp
sub rsp, 432
mov DWORD PTR [rbp-420], edi
mov QWORD PTR [rbp-432], rsi
mov QWORD PTR [rbp-32], OFFSET FLAT:.LC0
mov QWORD PTR [rbp-24], OFFSET FLAT:.LC1
mov QWORD PTR [rbp-16], 0
mov QWORD PTR [rbp-64], OFFSET FLAT:.LC2
mov QWORD PTR [rbp-56], OFFSET FLAT:.LC3
mov QWORD PTR [rbp-48], 0
mov QWORD PTR [rbp-96], OFFSET FLAT:.LC4
mov QWORD PTR [rbp-88], OFFSET FLAT:.LC5
mov QWORD PTR [rbp-80], OFFSET FLAT:.LC6
mov QWORD PTR [rbp-72], 0
mov QWORD PTR [rbp-128], OFFSET FLAT:.LC7
mov QWORD PTR [rbp-120], OFFSET FLAT:.LC8
mov QWORD PTR [rbp-112], 0
mov QWORD PTR [rbp-160], OFFSET FLAT:.LC2
mov QWORD PTR [rbp-152], OFFSET FLAT:.LC9
mov QWORD PTR [rbp-144], OFFSET FLAT:.LC10
mov QWORD PTR [rbp-136], 0
mov QWORD PTR [rbp-176], OFFSET FLAT:.LC11
mov QWORD PTR [rbp-168], 0
mov QWORD PTR [rbp-208], OFFSET FLAT:.LC12
mov QWORD PTR [rbp-200], OFFSET FLAT:.LC13
mov QWORD PTR [rbp-192], 0
mov QWORD PTR [rbp-240], OFFSET FLAT:.LC11
mov QWORD PTR [rbp-232], OFFSET FLAT:.LC14
mov QWORD PTR [rbp-224], 0
mov QWORD PTR [rbp-256], OFFSET FLAT:.LC15
mov QWORD PTR [rbp-248], 0
mov QWORD PTR [rbp-288], OFFSET FLAT:.LC7
mov QWORD PTR [rbp-280], OFFSET FLAT:.LC16
mov QWORD PTR [rbp-272], 0
mov QWORD PTR [rbp-336], OFFSET FLAT:.LC11
mov QWORD PTR [rbp-328], OFFSET FLAT:.LC14
mov QWORD PTR [rbp-320], OFFSET FLAT:.LC17
mov QWORD PTR [rbp-312], OFFSET FLAT:.LC18
mov QWORD PTR [rbp-304], 0
lea rax, [rbp-416]
mov rdi, rax
call pipe
lea rax, [rbp-416]
add rax, 8
mov rdi, rax
call pipe
lea rax, [rbp-416]
add rax, 16
mov rdi, rax
call pipe
lea rax, [rbp-416]
add rax, 24
mov rdi, rax
call pipe
lea rax, [rbp-416]
add rax, 32
mov rdi, rax
call pipe
lea rax, [rbp-416]
add rax, 40
mov rdi, rax
call pipe
lea rax, [rbp-416]
add rax, 48
mov rdi, rax
call pipe
lea rax, [rbp-416]
add rax, 56
mov rdi, rax
call pipe
lea rax, [rbp-416]
add rax, 64
mov rdi, rax
call pipe
lea rax, [rbp-416]
add rax, 72
mov rdi, rax
call pipe
call fork
test eax, eax
jne .L2
mov eax, DWORD PTR [rbp-412]
mov esi, 1
mov edi, eax
call dup2
mov DWORD PTR [rbp-4], 0
jmp .L3
.L4:
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-416+rax*4]
mov edi, eax
call close
add DWORD PTR [rbp-4], 1
.L3:
cmp DWORD PTR [rbp-4], 19
jle .L4
mov rax, QWORD PTR [rbp-32]
lea rdx, [rbp-32]
mov rsi, rdx
mov rdi, rax
call execvp
jmp .L5
.L2:
call fork
test eax, eax
jne .L6
mov eax, DWORD PTR [rbp-416]
mov esi, 0
mov edi, eax
call dup2
mov eax, DWORD PTR [rbp-404]
mov esi, 1
mov edi, eax
call dup2
mov DWORD PTR [rbp-4], 0
jmp .L7
.L8:
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-416+rax*4]
mov edi, eax
call close
add DWORD PTR [rbp-4], 1
.L7:
cmp DWORD PTR [rbp-4], 19
jle .L8
mov rax, QWORD PTR [rbp-64]
lea rdx, [rbp-64]
mov rsi, rdx
mov rdi, rax
call execvp
jmp .L5
.L6:
call fork
test eax, eax
jne .L9
mov eax, DWORD PTR [rbp-408]
mov esi, 0
mov edi, eax
call dup2
mov eax, DWORD PTR [rbp-396]
mov esi, 1
mov edi, eax
call dup2
mov DWORD PTR [rbp-4], 0
jmp .L10
.L11:
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-416+rax*4]
mov edi, eax
call close
add DWORD PTR [rbp-4], 1
.L10:
cmp DWORD PTR [rbp-4], 19
jle .L11
mov rax, QWORD PTR [rbp-96]
lea rdx, [rbp-96]
mov rsi, rdx
mov rdi, rax
call execvp
jmp .L5
.L9:
call fork
test eax, eax
jne .L12
mov eax, DWORD PTR [rbp-400]
mov esi, 0
mov edi, eax
call dup2
mov eax, DWORD PTR [rbp-388]
mov esi, 1
mov edi, eax
call dup2
mov DWORD PTR [rbp-4], 0
jmp .L13
.L14:
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-416+rax*4]
mov edi, eax
call close
add DWORD PTR [rbp-4], 1
.L13:
cmp DWORD PTR [rbp-4], 19
jle .L14
mov rax, QWORD PTR [rbp-128]
lea rdx, [rbp-128]
mov rsi, rdx
mov rdi, rax
call execvp
jmp .L5
.L12:
call fork
test eax, eax
jne .L15
mov eax, DWORD PTR [rbp-392]
mov esi, 0
mov edi, eax
call dup2
mov eax, DWORD PTR [rbp-380]
mov esi, 1
mov edi, eax
call dup2
mov DWORD PTR [rbp-4], 0
jmp .L16
.L17:
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-416+rax*4]
mov edi, eax
call close
add DWORD PTR [rbp-4], 1
.L16:
cmp DWORD PTR [rbp-4], 19
jle .L17
mov rax, QWORD PTR [rbp-160]
lea rdx, [rbp-160]
mov rsi, rdx
mov rdi, rax
call execvp
jmp .L5
.L15:
call fork
test eax, eax
jne .L18
mov eax, DWORD PTR [rbp-384]
mov esi, 0
mov edi, eax
call dup2
mov eax, DWORD PTR [rbp-372]
mov esi, 1
mov edi, eax
call dup2
mov DWORD PTR [rbp-4], 0
jmp .L19
.L20:
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-416+rax*4]
mov edi, eax
call close
add DWORD PTR [rbp-4], 1
.L19:
cmp DWORD PTR [rbp-4], 19
jle .L20
mov rax, QWORD PTR [rbp-176]
lea rdx, [rbp-176]
mov rsi, rdx
mov rdi, rax
call execvp
jmp .L5
.L18:
call fork
test eax, eax
jne .L21
mov eax, DWORD PTR [rbp-376]
mov esi, 0
mov edi, eax
call dup2
mov eax, DWORD PTR [rbp-364]
mov esi, 1
mov edi, eax
call dup2
mov DWORD PTR [rbp-4], 0
jmp .L22
.L23:
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-416+rax*4]
mov edi, eax
call close
add DWORD PTR [rbp-4], 1
.L22:
cmp DWORD PTR [rbp-4], 19
jle .L23
mov rax, QWORD PTR [rbp-208]
lea rdx, [rbp-208]
mov rsi, rdx
mov rdi, rax
call execvp
jmp .L5
.L21:
call fork
test eax, eax
jne .L24
mov eax, DWORD PTR [rbp-368]
mov esi, 0
mov edi, eax
call dup2
mov eax, DWORD PTR [rbp-356]
mov esi, 1
mov edi, eax
call dup2
mov DWORD PTR [rbp-4], 0
jmp .L25
.L26:
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-416+rax*4]
mov edi, eax
call close
add DWORD PTR [rbp-4], 1
.L25:
cmp DWORD PTR [rbp-4], 19
jle .L26
mov rax, QWORD PTR [rbp-240]
lea rdx, [rbp-240]
mov rsi, rdx
mov rdi, rax
call execvp
jmp .L5
.L24:
call fork
test eax, eax
jne .L27
mov eax, DWORD PTR [rbp-360]
mov esi, 0
mov edi, eax
call dup2
mov eax, DWORD PTR [rbp-348]
mov esi, 1
mov edi, eax
call dup2
mov DWORD PTR [rbp-4], 0
jmp .L28
.L29:
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-416+rax*4]
mov edi, eax
call close
add DWORD PTR [rbp-4], 1
.L28:
cmp DWORD PTR [rbp-4], 19
jle .L29
mov rax, QWORD PTR [rbp-256]
lea rdx, [rbp-256]
mov rsi, rdx
mov rdi, rax
call execvp
jmp .L5
.L27:
call fork
test eax, eax
jne .L30
mov eax, DWORD PTR [rbp-352]
mov esi, 0
mov edi, eax
call dup2
mov eax, DWORD PTR [rbp-340]
mov esi, 1
mov edi, eax
call dup2
mov DWORD PTR [rbp-4], 0
jmp .L31
.L32:
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-416+rax*4]
mov edi, eax
call close
add DWORD PTR [rbp-4], 1
.L31:
cmp DWORD PTR [rbp-4], 19
jle .L32
mov rax, QWORD PTR [rbp-288]
lea rdx, [rbp-288]
mov rsi, rdx
mov rdi, rax
call execvp
jmp .L5
.L30:
call fork
test eax, eax
jne .L5
mov eax, DWORD PTR [rbp-344]
mov esi, 0
mov edi, eax
call dup2
mov DWORD PTR [rbp-4], 0
jmp .L33
.L34:
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-416+rax*4]
mov edi, eax
call close
add DWORD PTR [rbp-4], 1
.L33:
cmp DWORD PTR [rbp-4], 19
jle .L34
mov rax, QWORD PTR [rbp-336]
lea rdx, [rbp-336]
mov rsi, rdx
mov rdi, rax
call execvp
.L5:
mov DWORD PTR [rbp-4], 0
jmp .L35
.L36:
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-416+rax*4]
mov edi, eax
call close
add DWORD PTR [rbp-4], 1
.L35:
cmp DWORD PTR [rbp-4], 19
jle .L36
mov DWORD PTR [rbp-4], 0
jmp .L37
.L38:
lea rax, [rbp-8]
mov rdi, rax
mov eax, 0
call wait
add DWORD PTR [rbp-4], 1
.L37:
cmp DWORD PTR [rbp-4], 19
jle .L38
mov eax, 0
leave
ret 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