Chapter 1 of gba asm of gbaguy

Source: Internet
Author: User

Chapter 1: Overview

 

The GBA processor is a Nintendo-customized CPU. Many people call it ARM7TDMI, which is also true. However, the arm7tbit is only a core and there are many other things on this chip. Another interesting thing is that arm didn't make the chip, but he authorized the design. But in general (we don't care;), there is a 32-bit ARM7TDMI in GBA.

 

This CPU has two instruction sets: arm and thumb. (It's just an overview. It doesn't matter if you don't understand these things .)

 

Arm instruction sets are versatile. Most of them have built-in displacement commands. That is to say, things like "R3 = r2 + R1 <4" are contained in a single instruction (of course, ). The instruction length is fixed to 32 bits, so it is impossible to load a 32-bit immediate number. Only one memory access can be performed, but this will be slow. Of course, I will demonstrate a (or two) faster method. One more thing to know is that these commands can be executed with conditions! Many commands allow you to choose whether to update to the condition flag (for example, you can execute a subtraction command without affecting the carry mark ). Most commands have their own displacement operations, so there is no separate displacement command.

 

The thumb instruction set is simple. In fact, most of them only have one function. The size of the thumb command is fixed to 16 bits. The same command (most commands have a corresponding value in both sets) will run faster than arm, but only from Rom, because Rom is a 16-bit bus. Only branch commands are executed by conditions, and you cannot prohibit instructions from being updated to condition marks (for example, add always affects carry, overflow, and all zero-sum sign ).

 

The ARM7 processor has 16 32-bit registers (although only the first 7 register r0-r6 is valid for the thumb mode ):
R0-r12: GRPS (general purpose registers)
R13: generally used as a stack pointer (SP). If you do not use a stack (small program or something), it can also be used as a GPR.
R14: link register can also be used as GPR. However, it is mainly used to save the return address when executing branch or connection commands (called by subfunctions.
R15: program counter (PC), which stores the current instruction address + 8. Step 7 uses a three-phase pipeline, so when you read the PC, you get the address of the Second 2nd Command after the READ command.
The first stage obtains the instruction, the second stage decodes the instruction, and the third stage actually executes the instruction. Therefore, the program counter always exceeds the two commands currently executed.
This parameter must be included when calculating the offset for the branch command .)

The following lists the advantages and disadvantages of the two instruction sets:
Arm
Advantages:
Multiple Functions
All commands can be executed with conditions.
You can choose whether to update to the condition flag.
Disadvantages:
Slower than thumb in ROM
Thumb
Advantages:
Faster than arm in ROM
Small commands
Disadvantages:
The command must update the condition flag.
Only branch commands can be executed with conditions.
Most commands only use r0-r6

 

 

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.