1.5.3_undException mode program example

Publisher:Blissful444Latest update time:2021-08-10 Source: eefocusKeywords:und  CPU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

When the CPU executes an undefined instruction, an undefined instruction exception is triggered.

insert image description here

Through the exception vector table, we can find that the entry of the undefined instruction exception is at 0x0000,0004. That is, when the CPU executes the undefined instruction exception, the CPU on the hardware will jump to 0x0000,0004 to execute the code.

insert image description here

We trigger the exception by deliberately adding an undefined instruction 0x0300,00000 in the code. The figure below is the structure of a normal instruction. The original figure has the bit marks reversed, and the left to right should be 31-0.

insert image description here
insert image description here

The following table is a description table of interrupt exit and entry. It can be seen from the table that under ARM instructions, before entering the undefined instruction exception, the address of PC+4 will be stored in R14_x, which is lr_und, so when exiting, you only need to pass R14_und to PC.

insert image description here

When handling an undefined instruction exception, we first store the values ​​of the r0-r12 registers on the stack, and then store the value of the lr_exception on the stack. Because these values ​​may be modified, they must be saved first.

insert image description here

The functional definition of the registers is as follows.

insert image description here
insert image description here

After saving the scene, we perform exception handling. In the exception handling function, we print out the cpsr and output an additional string to indicate that an undefined instruction exception has occurred.

insert image description here

The .string directive is used to define the string here. The difference between it and the .ascii directive is that the string defined by the .ascii directive will not automatically add an end character at the end, while the string defined by the .string directive will automatically add an end character.


The following figure is a schematic diagram of the sequence of handling undefined instruction exceptions. After power-on, the CPU starts executing from address 0, then relocates and copies the entire code to SDRAM and jumps to SDRAM for execution. When an undefined instruction is detected, an exception is triggered and jumps back to 0x4, and then jumps to SDRAM at 0x4 to handle the undefined instruction exception.

insert image description here

Keywords:und  CPU Reference address:1.5.3_undException mode program example

Previous article:1.5.2 Exceptions and Interrupts_CPU Mode_State and Registers
Next article:Bidirectional traffic light based on LPC2138 control (green light flashes in the last 3 seconds)

Recommended ReadingLatest update time:2024-11-16 11:36

Four departments in Shenzhen: Focus on breakthroughs in high-end general-purpose chip design such as CPU, GPU, DSP, and FPGA
Today (6), Shenzhen Development and Reform Commission, Shenzhen Science and Technology Innovation Commission, Shenzhen Industry and Information Technology Bureau, and Shenzhen State-owned Assets Supervision and Administration Commission issued the "Shenzhen Action Plan for Cultivating and Developing Semiconductor and
[Mobile phone portable]
51 microcontroller external interrupt experimental design
How should we understand the peripherals of 51 microcontroller? Do the following experiment. Experiment 1: Experiment with external interrupt 0 Experimental steps: Connect one end of a DuPont cable to the P3^2 port, and the other end to the power supply or ground. Experimental procedure: #include sbit led = P1^0;
[Microcontroller]
51 microcontroller external interrupt experimental design
89c51 CPU Timing
The 89C51 series microcontrollers, like other MCUs, fetch instructions from Flash Rom and perform various micro-operations in the process of executing instructions at a certain rhythm. This is because there is a rhythm generator in the 89c51 microcontroller, that is, an oscillating pulse circuit in the chip. The 89c
[Microcontroller]
89c51 CPU Timing
TCP communication between S7-1500 and S7-300PN CPU
1. Configuration 1.1 Allocating IP addresses Configure the IP address of the PC by following the steps below Step Operation Notes 1. Select "Start Control Panel Network and Sharing Local Area Connection Properties" to open Internet Protocol Version 4 (TCP/IPv4). Set the IP address of the
[Embedded]
TCP communication between S7-1500 and S7-300PN CPU
1.5.3_undException mode program example
When the CPU executes an undefined instruction, an undefined instruction exception is triggered. Through the exception vector table, we can find that the entry of the undefined instruction exception is at 0x0000,0004. That is, when the CPU executes the undefined instruction exception, the CPU on the hardware will ju
[Microcontroller]
1.5.3_undException mode program example
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号