0000000000001000 <_init>: 1000: f3 0f 1e fa endbr64 1004: 48 83 ec 08 sub $0x8,%rsp 1008: 48 8b 05 d9 2f 00 00 mov 0x2fd9(%rip),%rax # 3fe8 <__gmon_start__> 100f: 48 85 c0 test %rax,%rax 1012: 74 02 je 1016 <_init+0x16> 1014: ff d0 callq *%rax 1016: 48 83 c4 08 add $0x8,%rsp 101a: c3 retq Disassembly of section .plt: 0000000000001020 <.plt>: 1020: ff 35 8a 2f 00 00 pushq 0x2f8a(%rip) # 3fb0 <_GLOBAL_OFFSET_TABLE_+0x8> 1026: f2 ff 25 8b 2f 00 00 bnd jmpq *0x2f8b(%rip) # 3fb8 <_GLOBAL_OFFSET_TABLE_+0x10> 102d: 0f 1f 00 nopl (%rax) 1030: f3 0f 1e fa endbr64 1034: 68 00 00 00 00 pushq $0x0 1039: f2 e9 e1 ff ff ff bnd jmpq 1020 <.plt> 103f: 90 nop 1040: f3 0f 1e fa endbr64 1044: 68 01 00 00 00 pushq $0x1 1049: f2 e9 d1 ff ff ff bnd jmpq 1020 <.plt> 104f: 90 nop 1050: f3 0f 1e fa endbr64 1054: 68 02 00 00 00 pushq $0x2 1059: f2 e9 c1 ff ff ff bnd jmpq 1020 <.plt> 105f: 90 nop Disassembly of section .plt.got: 0000000000001060 <__cxa_finalize@plt>: 1060: f3 0f 1e fa endbr64 1064: f2 ff 25 8d 2f 00 00 bnd jmpq *0x2f8d(%rip) # 3ff8 <__cxa_finalize@GLIBC_2.2.5> 106b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) Disassembly of section .plt.sec: 0000000000001070 <putchar@plt>: 1070: f3 0f 1e fa endbr64 1074: f2 ff 25 45 2f 00 00 bnd jmpq *0x2f45(%rip) # 3fc0 <putchar@GLIBC_2.2.5> 107b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) 0000000000001080 <__stack_chk_fail@plt>: 1080: f3 0f 1e fa endbr64 1084: f2 ff 25 3d 2f 00 00 bnd jmpq *0x2f3d(%rip) # 3fc8 <__stack_chk_fail@GLIBC_2.4> 108b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) 0000000000001090 <sleep@plt>: 1090: f3 0f 1e fa endbr64 1094: f2 ff 25 35 2f 00 00 bnd jmpq *0x2f35(%rip) # 3fd0 <sleep@GLIBC_2.2.5> 109b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) Disassembly of section .text: 00000000000010a0 <_start>: 10a0: f3 0f 1e fa endbr64 10a4: 31 ed xor %ebp,%ebp 10a6: 49 89 d1 mov %rdx,%r9 10a9: 5e pop %rsi 10aa: 48 89 e2 mov %rsp,%rdx 10ad: 48 83 e4 f0 and $0xfffffffffffffff0,%rsp 10b1: 50 push %rax 10b2: 54 push %rsp 10b3: 4c 8d 05 36 02 00 00 lea 0x236(%rip),%r8 # 12f0 <__libc_csu_fini> 10ba: 48 8d 0d bf 01 00 00 lea 0x1bf(%rip),%rcx # 1280 <__libc_csu_init> 10c1: 48 8d 3d c1 00 00 00 lea 0xc1(%rip),%rdi # 1189 <main> 10c8: ff 15 12 2f 00 00 callq *0x2f12(%rip) # 3fe0 <__libc_start_main@GLIBC_2.2.5> 10ce: f4 hlt 10cf: 90 nop 00000000000010d0 <deregister_tm_clones>: 10d0: 48 8d 3d 39 2f 00 00 lea 0x2f39(%rip),%rdi # 4010 <__TMC_END__> 10d7: 48 8d 05 32 2f 00 00 lea 0x2f32(%rip),%rax # 4010 <__TMC_END__> 10de: 48 39 f8 cmp %rdi,%rax 10e1: 74 15 je 10f8 <deregister_tm_clones+0x28> 10e3: 48 8b 05 ee 2e 00 00 mov 0x2eee(%rip),%rax # 3fd8 <_ITM_deregisterTMCloneTable> 10ea: 48 85 c0 test %rax,%rax 10ed: 74 09 je 10f8 <deregister_tm_clones+0x28> 10ef: ff e0 jmpq *%rax 10f1: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 10f8: c3 retq 10f9: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 0000000000001100 <register_tm_clones>: 1100: 48 8d 3d 09 2f 00 00 lea 0x2f09(%rip),%rdi # 4010 <__TMC_END__> 1107: 48 8d 35 02 2f 00 00 lea 0x2f02(%rip),%rsi # 4010 <__TMC_END__> 110e: 48 29 fe sub %rdi,%rsi 1111: 48 89 f0 mov %rsi,%rax 1114: 48 c1 ee 3f shr $0x3f,%rsi 1118: 48 c1 f8 03 sar $0x3,%rax 111c: 48 01 c6 add %rax,%rsi 111f: 48 d1 fe sar %rsi 1122: 74 14 je 1138 <register_tm_clones+0x38> 1124: 48 8b 05 c5 2e 00 00 mov 0x2ec5(%rip),%rax # 3ff0 <_ITM_registerTMCloneTable> 112b: 48 85 c0 test %rax,%rax 112e: 74 08 je 1138 <register_tm_clones+0x38> 1130: ff e0 jmpq *%rax 1132: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) 1138: c3 retq 1139: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 0000000000001140 <__do_global_dtors_aux>: 1140: f3 0f 1e fa endbr64 1144: 80 3d c5 2e 00 00 00 cmpb $0x0,0x2ec5(%rip) # 4010 <__TMC_END__> 114b: 75 2b jne 1178 <__do_global_dtors_aux+0x38> 114d: 55 push %rbp 114e: 48 83 3d a2 2e 00 00 cmpq $0x0,0x2ea2(%rip) # 3ff8 <__cxa_finalize@GLIBC_2.2.5> 1155: 00 1156: 48 89 e5 mov %rsp,%rbp 1159: 74 0c je 1167 <__do_global_dtors_aux+0x27> 115b: 48 8b 3d a6 2e 00 00 mov 0x2ea6(%rip),%rdi # 4008 <__dso_handle> 1162: e8 f9 fe ff ff callq 1060 <__cxa_finalize@plt> 1167: e8 64 ff ff ff callq 10d0 <deregister_tm_clones> 116c: c6 05 9d 2e 00 00 01 movb $0x1,0x2e9d(%rip) # 4010 <__TMC_END__> 1173: 5d pop %rbp 1174: c3 retq 1175: 0f 1f 00 nopl (%rax) 1178: c3 retq 1179: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 0000000000001180 <frame_dummy>: 1180: f3 0f 1e fa endbr64 1184: e9 77 ff ff ff jmpq 1100 <register_tm_clones> 0000000000001189 <main>: 1189: f3 0f 1e fa endbr64 118d: 55 push %rbp 118e: 48 89 e5 mov %rsp,%rbp 1191: 48 83 ec 30 sub $0x30,%rsp 1195: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax 119c: 00 00 119e: 48 89 45 f8 mov %rax,-0x8(%rbp) 11a2: 31 c0 xor %eax,%eax 11a4: 48 b8 de fd f8 46 02 movabs $0x246f8fdde,%rax 11ab: 00 00 00 11ae: 48 89 45 d8 mov %rax,-0x28(%rbp) 11b2: e9 96 00 00 00 jmpq 124d <main+0xc4> 11b7: 48 83 7d d8 01 cmpq $0x1,-0x28(%rbp) 11bc: 77 57 ja 1215 <main+0x8c> 11be: 48 b8 e6 ea e9 e4 e7 movabs $0x8e90dee7e4e9eae6,%rax 11c5: de 90 8e 11c8: 48 ba e5 c6 ce fa e7 movabs $0xc994d0e7facec6e5,%rdx 11cf: d0 94 c9 11d2: 48 89 45 e0 mov %rax,-0x20(%rbp) 11d6: 48 89 55 e8 mov %rdx,-0x18(%rbp) 11da: c7 45 f0 8e fa 90 92 movl $0x9290fa8e,-0x10(%rbp) 11e1: 66 c7 45 f4 d7 d8 movw $0xd8d7,-0xc(%rbp) 11e7: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%rbp) 11ee: eb 1a jmp 120a <main+0x81> 11f0: 8b 45 d4 mov -0x2c(%rbp),%eax 11f3: 48 98 cltq 11f5: 0f b6 44 05 e0 movzbl -0x20(%rbp,%rax,1),%eax 11fa: 0f be c0 movsbl %al,%eax 11fd: 34 a5 xor $0xa5,%al 11ff: 89 c7 mov %eax,%edi 1201: e8 6a fe ff ff callq 1070 <putchar@plt> 1206: 83 45 d4 01 addl $0x1,-0x2c(%rbp) 120a: 8b 45 d4 mov -0x2c(%rbp),%eax 120d: 83 f8 15 cmp $0x15,%eax 1210: 76 de jbe 11f0 <main+0x67> 1212: 90 nop 1213: eb 43 jmp 1258 <main+0xcf> 1215: 48 8b 45 d8 mov -0x28(%rbp),%rax 1219: 83 e0 01 and $0x1,%eax 121c: 48 85 c0 test %rax,%rax 121f: 74 17 je 1238 <main+0xaf> 1221: 48 8b 55 d8 mov -0x28(%rbp),%rdx 1225: 48 89 d0 mov %rdx,%rax 1228: 48 01 c0 add %rax,%rax 122b: 48 01 d0 add %rdx,%rax 122e: 48 83 c0 01 add $0x1,%rax 1232: 48 89 45 d8 mov %rax,-0x28(%rbp) 1236: eb 0b jmp 1243 <main+0xba> 1238: 48 8b 45 d8 mov -0x28(%rbp),%rax 123c: 48 d1 e8 shr %rax 123f: 48 89 45 d8 mov %rax,-0x28(%rbp) 1243: bf 01 00 00 00 mov $0x1,%edi 1248: e8 43 fe ff ff callq 1090 <sleep@plt> 124d: 48 83 7d d8 00 cmpq $0x0,-0x28(%rbp) 1252: 0f 85 5f ff ff ff jne 11b7 <main+0x2e> 1258: b8 00 00 00 00 mov $0x0,%eax 125d: 48 8b 4d f8 mov -0x8(%rbp),%rcx 1261: 64 48 33 0c 25 28 00 xor %fs:0x28,%rcx 1268: 00 00 126a: 74 05 je 1271 <main+0xe8> 126c: e8 0f fe ff ff callq 1080 <__stack_chk_fail@plt> 1271: c9 leaveq 1272: c3 retq 1273: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1) 127a: 00 00 00 127d: 0f 1f 00 nopl (%rax) 0000000000001280 <__libc_csu_init>: 1280: f3 0f 1e fa endbr64 1284: 41 57 push %r15 1286: 4c 8d 3d 1b 2b 00 00 lea 0x2b1b(%rip),%r15 # 3da8 <__frame_dummy_init_array_entry> 128d: 41 56 push %r14 128f: 49 89 d6 mov %rdx,%r14 1292: 41 55 push %r13 1294: 49 89 f5 mov %rsi,%r13 1297: 41 54 push %r12 1299: 41 89 fc mov %edi,%r12d 129c: 55 push %rbp 129d: 48 8d 2d 0c 2b 00 00 lea 0x2b0c(%rip),%rbp # 3db0 <__do_global_dtors_aux_fini_array_entry> 12a4: 53 push %rbx 12a5: 4c 29 fd sub %r15,%rbp 12a8: 48 83 ec 08 sub $0x8,%rsp 12ac: e8 4f fd ff ff callq 1000 <_init> 12b1: 48 c1 fd 03 sar $0x3,%rbp 12b5: 74 1f je 12d6 <__libc_csu_init+0x56> 12b7: 31 db xor %ebx,%ebx 12b9: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 12c0: 4c 89 f2 mov %r14,%rdx 12c3: 4c 89 ee mov %r13,%rsi 12c6: 44 89 e7 mov %r12d,%edi 12c9: 41 ff 14 df callq *(%r15,%rbx,8) 12cd: 48 83 c3 01 add $0x1,%rbx 12d1: 48 39 dd cmp %rbx,%rbp 12d4: 75 ea jne 12c0 <__libc_csu_init+0x40> 12d6: 48 83 c4 08 add $0x8,%rsp 12da: 5b pop %rbx 12db: 5d pop %rbp 12dc: 41 5c pop %r12 12de: 41 5d pop %r13 12e0: 41 5e pop %r14 12e2: 41 5f pop %r15 12e4: c3 retq 12e5: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1) 12ec: 00 00 00 00 00000000000012f0 <__libc_csu_fini>: 12f0: f3 0f 1e fa endbr64 12f4: c3 retq Disassembly of section .fini: 00000000000012f8 <_fini>: 12f8: f3 0f 1e fa endbr64 12fc: 48 83 ec 08 sub $0x8,%rsp 1300: 48 83 c4 08 add $0x8,%rsp 1304: c3 retq
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