Chapter 7 multiplication in gba asm of gbaguy

Source: Internet
Author: User

Fortunately, the GBA processor has some multiplication commands. They are Mul, MLA, umull, umlal, smull, and smlal. These commands can use s to specify whether to affect the status mark. In addition, these commands can only use registers as the operands without any displacement.

 

The command Mul is the most basic. It performs a 32-bit multiplication in the following format:

Mul DEST, OP1, OP2 @ DEST = OP1 * OP2. The result may be larger than 32 bits, but if the Mul command is used, the extra part will be lost.

The command MLA is similar to Mul, but it has an additional operand, like this:

Mla dest, OP1, OP2, OP3 @ DEST = (OP1 * OP2) + OP3. Multiply the first two operands and add the last one.

MLA means multiply with accumulate. For example:

MLA R9, R0, R1, R2 @ R9 = (R0 * R1) + R2!

The umull and smull commands are 32-bit unsigned and symbolic multiplication, respectively. The difference between Mul and Mul is that they allow 64-bit results in the following format:

Umull DEST (upper 32), DEST (lower 32), OP1, OP2 @ The first register stores the result of the high 32 bits, the second register stores the low 32 bits, and OP1 and OP2 multiply.

Command umlal and smlal are 64-bit MLA versions. They can also save the 64-bit multiplication results and then perform a 64-bit addition. For example:

Umlal r0, R1, R2, R3 @ R0 and R1 constitute a 64-digit number. R2 is multiplied by R3 and the result is added to R0/R1. The final result is stored in R0 and R1.

I want you to understand what DEST, opx, and so on mean when I talk about the format. You can replace these with any register. OP1, OP2, and DEST are not real Register names.

 

I would like to write the subtraction command, but there is no subtraction command. However, be sure to use the multiplication command. Unlike the subtraction command, these commands are fast.

Related Article

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.