Raised an exception. Cause: Undefined instruction

Source: Internet
Author: User

Problems in arm assembly
Arm assembler is similar to x86 assembler. Use ";" to comment. Such as start and loop. Entry indicates the start of the program, and end indicates the end. Of course, these two must be written in alignment.
The following describes the first arm assembler I wrote. It deserves to be a difficult problem.


I think this code can be viewed as a new handwriting. The Line "Stop B stop". However, even such a line of code is hard to produce.
In the first arm assembly code, I did not add this line. After running the program directly, the following error occurs: processor.
ARM7TDMI raised an exception. cause: Undefined instruction. When you run the command in a single step, the result is obtained. However, an error box will pop up at the end, and all the last columns in the box are undefined. this problem is hard to understand. But now I understand.
Why is there such a problem?
In a multi-task operating system, a program is actually a task, which is scheduled by the system. Every task is actually executed cyclically. In embedded products, the program always performs one or more cycles, and the user stops running only when the power supply is disabled. In Windows, the program you designed does not require Loops because the development tool provides you with a default loop program instead of running it cyclically.

The program counter stores the address of your next instruction. The CPU constantly reads the instruction and decodes and executes the instruction. Then, the value is adjusted to the next instruction address of the executed instruction. If there is no loop, after the program ends, it will still read the next instruction. However, your program has been running and no commands have been defined for the program counter to read. In this way, a non-definition error occurs.

After knowing the cause, I thought of the simplest method. Since arm does not stop assembling it. Undefined will be reported if there is no next command, so I will let it loop. So we have the above Code. That is, results are not affected. No error is reported. However, after the actual operation, the program will not stop, like a crash. This makes me feel a little lacking.
I have read many examples in the installation files. Most of the final sections are found to be:
Stop mov r0, #0x18; angel_swireason_reportexception
LDR R1, = 0x20026; adp_stopped_applicationexit
SWI 0x123456
Since it is stop, I guess this should be the code that stops the program. The three lines are indeed stopping the program with interruptions. But the meaning of the specific Code cannot be said. Continue to find information. I finally asked the specific meaning in an arm technology group.
The stop segment is used to exit the program. The first statement "mov r0, #0x18" assigns R0 to 0x18, which corresponds to the macro angel_swireason_reportexception. Indicates the execution status stored in R1. Statement "LDR"
R1, = 0x20026 "sets the value of R1 to adp_stopped_applicationexit. This macro indicates that the program Exits normally. Then, use the SWI statement "SWI
0x123456 "ends the program and returns the CPU control to the debugger.
So far, an arm assembler is born.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.