; *********************************************************************** ; * * ; * Convert Lower Case ASCII Into Upper Case (Assembly Language) * ; * * ; *********************************************************************** ; Authors: Saeid Nooshabadi and John Zaitseff ; Date: 29th April, 2003 ; Version: 1.4 ; This very simple program converts the lower case character in "lower" ; into upper case by subtracting 0x20. It is essentially the assembly ; language equivalent of chsub-c.c. The essential points to note are the ; use of "ldrb" and "strb" to load and store the characters (bytes) and, ; of course, the subtraction instruction "sub". ; ----------------------------------------------------------------------- ; Assembly-language preamble for the main module .text ; Executable code follows _start: .global _start ; "_start" is required by the linker .global main ; "main" is our main program b main ; Start running the main program ; ----------------------------------------------------------------------- ; Start of the main program ; This program loads the character in the variable "lower", subtracts the ; constant 0x20 and stores the result in the variable "upper". main: ldr r3, =lower ; Load the address of "lower" into R3 ldrb r0, [r3] ; R0 = 0x00000061 (the character 'a') sub r0, r0, #0x20 ; R0 = 'a' - 0x20 = 'A' ldr r3, =upper ; Load the address of "upper" into R3 strb r0, [r3] ; Store the (byte) value in R0 to "upper". exit: mov pc, lr ; Stop the program (and return to the OS) ; ----------------------------------------------------------------------- ; Program variables (stored together with the code) lower: .byte 'a' ; Variable "lower"; 'a' is used as an example upper: .byte 0 ; Variable "upper" ; ----------------------------------------------------------------------- .end