[Disclaimer: All Rights Reserved. You are welcome to reprint it. Do not use it for commercial purposes. Contact Email: feixiaoxing @ 163.com]
It is also a x86 CPU, but it can be expressed in different forms of assembly languages. In Windows, we use intel-format assembly languages, while in Linux systems, at&t-format assembly languages are often used. So what is at&t-format assembly code? Let's write a try.
.datamessage: .string "hello!\n"length = . - message.text.global _start_start:movl $length, %edxmovl $message, %ecxmovl $1, %ebxmovl $4, %eaxint $0x80movl $0, %ebxmovl $1, %eaxint $0x80
This is a simple assembly file. We can compile it in two steps. First, enter as-ststabs-O hello. O hello. s, and then enter LD-O hello. O. To verify whether the execution file is correct, enter./hello to verify.
In the as command, because we use the-gstabs option, debugging information is contained in the hello execution file. Therefore, if you want to debug in one step, you can input GDB hello for debugging.
So what is the code for the disassembly of the hello execution file? Enter objdump-s-d hello.
08048074 <_start>:.text.global _start_start: movl $length, %edx 8048074: ba 08 00 00 00 mov $0x8,%edx movl $message, %ecx 8048079: b9 9c 90 04 08 mov $0x804909c,%ecx movl $1, %ebx 804807e: bb 01 00 00 00 mov $0x1,%ebx movl $4, %eax 8048083: b8 04 00 00 00 mov $0x4,%eax int $0x80 8048088: cd 80 int $0x80 movl $0, %ebx 804808a: bb 00 00 00 00 mov $0x0,%ebx movl $1, %eax 804808f: b8 01 00 00 00 mov $0x1,%eax int $0x80 8048094: cd 80 int $0x80 ret 8048096: c3 ret