First, let me explain the tools you need
. 1. QEMU This emulator can not only simulate x86, but also ARM and MIPS, which is very powerful.
2. GDB (source code) Needless to say, it is a universal debugger, but it needs to be compiled from source code.
3. arm-linux cross toolchain I use the 3.4 version that comes with my own development board, but you can just download one from www.uclinux.org
(but it seems that uclinux has been blocked by GFW...)
Compile GDB first and set the target to the ARM platform:
$ ./configure --target=arm-linux
$ make
$ make install
Note: The default directory is /usr/local/bin/
OK, start writing the assembly program. The sample code is very simple. It assigns values to three registers and then loops endlessly. Note that there must be an endless loop, otherwise illegal instructions or unknown instructions will be encountered.
=======test.S========
.globl _start
_start:
mov r0, #0
mov r1, #1
mov r2, #2
loop:
b loop
=======EOF=========
Compile:
$ arm-linx-as -o test.o test.SLink
:
$ arm-linux-ld -o test test.oNow
you can use objdump to view the contents of test:
$ arm-linux-objdump -d testThe
next step is debugging. Use qemu to start gdb port monitoring:
$ qemu-arm -g 11111 testAfter
starting gdb, note that test must be specified when starting. You cannot use file to specify test after starting (why not, it's not clear, but it's the test result):
$ arm-linux-gdb /PATH_TO_TEST Note that the gdb here is not the system's gdb, but the gdb just compiled
(gdb) target remote localhost:11111 Set the target to the local port 11111
(gdb) disassemble Disassembly
(gdb) display /10i $pc-16 This command displays the 10 instructions near the current pc, replacing the list command for debugging x86 programs
(gdb) si si, not s, is a single-step execution instruction. If it is s, it will execute to the next label. Similar to ni
(gdb) info register Well, this is to view the value of the register~
(gdb) x /16 0 This is to view the memory information of the 16 words (32 bits per word) starting from 0x00000000
That's about it. There is a problem that I don't know how to set the breakpoint of the instruction. I'll try it later...
If you run the program directly, directly
qemu-arm test
Now you can practice while reading the book~ QEMU also supports Thumb instruction set and Jazelle instruction set, which should be debugged in this way
Previous article:Conversion between ARM assembly and Gnu assembly
Next article:In Ubuntu, when connected to the arm development board, use the wireless network card to set up Internet access
Recommended ReadingLatest update time:2024-11-17 07:36
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- 【TI recommended course】#Achieving a new generation of test and measurement applications#
- Differences in op amps result in different levels of output signal fluctuations
- How did the company calculate the air gap of the switching transformer?
- This is my first post, so please take good care of me.
- How to change the Linux boot screen?
- TB5128FTG stepper motor driver selection
- Baidu MP3
- I heard that USB has built-in CRC verification. Does the USB virtual serial port not need verification?
- Share some public closed-loop stepper data collected
- EEWORLD University - Video tutorial on how to use a tablet oscilloscope