In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you how to solve the factorial and case conversion problems with ARM assembler. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Environment and hardware
1. The hardware simulation is based on SAMSUNG's S3C44B0X 16/32-bit RISC microprocessor chip and the simulator is J-LINK.
Second, the instruction software is Integrated Development Environment and the software simulation is ARMulate.dll.
Third, it needs C language startup code based on ARM7 hardware platform, which is used to allocate interrupt vector table, initialize ISR address, initialize stack space, initialize application execution environment, configure memory system, set clock cycle, and call main application.
Fourth, there is only the key algorithm code.
ARM assembly to find the factorial of a number
Topic: the factorial operation of the data in the R1 register, the result is stored in R0
Mov R1 recording 6; send the immediate count 6 to R1, that is, the factorial of'6', which can be changed
Mov R0not R1; give the value of R1 to R0
Loop; define a loop body label
Subs R1 to R1; give R1-R1 to R1
Mul R0Query r0Query R1; give the value of R0*R1 to R0
Cmp R1 compare R1 with 1
BNE loop; if the above values are not equal, jump to loop
ARM assembler case conversion and memory storage
Topic: change the string "Welcome to CSUST!" at the beginning of the memory address 0XC100000 The corresponding lowercase letters in are converted to uppercase and uppercase to lowercase.
Note: this algorithm has limitations. It can only convert strings that do not contain ASSIC values greater than '127' and between' 91y96'.
STRING_WELCOME DCB "Welcome to CSUST!\ n\ 0"; declare a string STRING LDR r0preceded stringWELCOME; get the first address of the string mov R1 Node 0x0c100000; give # 0x0c100000 to R1 in order to point R1 to the destination address STRING2 LDRB R2, [R0] Take a character to R2 cmp R2 BIGWORD 97; compare R2 with 97 (that is,'a'); jump to the BIGWORD subroutine cmp R2 # 65 if it is greater than or equal to 97; compare R2 with 65 (i.e.'A') BGE SMALLWORD Jump to SMALLWORD subroutine B MYLOOP if it is greater than or equal to 65; jump to MYLOOP to save characters BIGWORD; uppercase to lowercase subroutine sub R2, R2 MYLOOP 32; ASCI code-32 for uppercase letters can be converted to lowercase B MYLOOP Skip to MYLOOP, save character SMALLWORD; lowercase to uppercase subroutine add R2; 32; convert lowercase ASCI code + 32 to uppercase MYLOOP; character saving subroutine STRB R2, [R1] Store the contents specified by R1: add r0rec r0parentin 1; R0=R0+1 add R1 record1; R1=R1+1 CMP R2 recorder'0'; compare R2 with'\ 0' in order to determine whether the string BNE STRING2 has been fetched If the previous comparison is not equal, jump to STRING2 to continue to fetch characters.
ASSIC code table
The above is how ARM assembler solves the problem of factorial and case conversion. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.