# arm_asm **Repository Path**: jjinl/arm_asm ## Basic Information - **Project Name**: arm_asm - **Description**: arm gcc 汇编学习 - **Primary Language**: 汇编 - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-11-09 - **Last Updated**: 2023-11-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # arm_asm #### 介绍 arm gcc 汇编学习,加深ARM汇编基础 #### ARM版本 学习ARMv5TE版本,主要我的编译器是 ~~~ jjinl@jjinl-wksp:~/gcc_set/arm-2013.05/bin$ ./arm-none-linux-gnueabi-gcc -v Using built-in specs. COLLECT_GCC=./arm-none-linux-gnueabi-gcc COLLECT_LTO_WRAPPER=/home/jjinl/gcc_set/arm-2013.05/bin/../libexec/gcc/arm-none-linux-gnueabi/4.7.3/lto-wrapper Target: arm-none-linux-gnueabi Configured with: /scratch/jbrown/2013.05-arm-linux-release/src/gcc-4.7-2013.05/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --enable-extra-sgxxlite-multilibs --with-arch=armv5te --with-gnu-as --with-gnu-ld --with-specs='%{save-temps: -fverbose-asm} %{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables} -D__CS_SOURCERYGXX_MAJ__=2013 -D__CS_SOURCERYGXX_MIN__=5 -D__CS_SOURCERYGXX_REV__=24 %{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --enable-shared --enable-lto --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery CodeBench Lite 2013.05-24' --with-bugurl=https://sourcery.mentor.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --with-build-sysroot=/scratch/jbrown/2013.05-arm-linux-release/install/arm-none-linux-gnueabi/libc --with-gmp=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-mpfr=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-mpc=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-ppl=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-cloog=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-libelf=/scratch/jbrown/2013.05-arm-linux-release/obj/pkg-2013.05-24-arm-none-linux-gnueabi/arm-2013.05-24-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --disable-libgomp --disable-libitm --enable-poison-system-directories --with-build-time-tools=/scratch/jbrown/2013.05-arm-linux-release/install/arm-none-linux-gnueabi/bin --with-build-time-tools=/scratch/jbrown/2013.05-arm-linux-release/install/arm-none-linux-gnueabi/bin Thread model: posix gcc version 4.7.3 (Sourcery CodeBench Lite 2013.05-24) ~~~ 默认编译出来的文件是: ~~~ jjinl@jjinl-wksp:~/wksp/fpga/arm9/asm/arm_asm/test1$ /home/jjinl/gcc_set/arm-2013.05/bin/arm-none-linux-gnueabi-readelf -a test1 ELF Header: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: EXEC (Executable file) Machine: ARM Version: 0x1 Entry point address: 0x8b28 Start of program headers: 52 (bytes into file) Start of section headers: 551160 (bytes into file) Flags: 0x5000202, has entry point, Version5 EABI, soft-float ABI Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 6 Size of section headers: 40 (bytes) Number of section headers: 30 Section header string table index: 27 Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 .... .... 4361: 0001d7f8 136 FUNC GLOBAL DEFAULT 3 raise 4362: 0000d2fc 172 FUNC GLOBAL DEFAULT 3 _IO_seekmark 4363: 00075998 72 OBJECT GLOBAL DEFAULT 7 _nl_C_LC_CTYPE_class_alph 4364: 0001267c 156 FUNC GLOBAL DEFAULT 3 free 4365: 00038924 96 FUNC GLOBAL DEFAULT 3 __towctrans 4366: 00035900 356 FUNC GLOBAL DEFAULT 3 _nl_get_era_entry 4367: 0001d9f4 160 FUNC WEAK DEFAULT 3 sigprocmask 4368: 0007164c 84 OBJECT GLOBAL DEFAULT 7 _IO_file_jumps_mmap 4369: 0000c774 100 FUNC GLOBAL DEFAULT 3 _IO_old_init 4370: 00000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__ 4371: 00066c60 36 FUNC GLOBAL DEFAULT 3 __libc_register_dlfcn_hoo 4372: 0006923c 4120 FUNC GLOBAL DEFAULT 3 _dl_map_object_deps 4373: 000700bc 36 OBJECT GLOBAL DEFAULT 7 _nl_C_LC_IDENTIFICATION 4374: 00090134 76 OBJECT GLOBAL DEFAULT 22 _dl_ns 4375: 0004c340 2372 FUNC GLOBAL DEFAULT 3 _nl_load_locale_from_arch 4376: 0003889c 136 FUNC WEAK DEFAULT 3 wctrans No version information found in this file. Notes at offset 0x000000f4 with length 0x00000020: Owner Data size Description GNU 0x00000010 NT_GNU_ABI_TAG (ABI version tag) OS: Linux, ABI: 2.6.16 Attribute Section: aeabi File Attributes Tag_CPU_name: "5TE" Tag_CPU_arch: v5TE Tag_ARM_ISA_use: Yes Tag_THUMB_ISA_use: Thumb-1 Tag_ABI_PCS_wchar_t: 4 Tag_ABI_FP_rounding: Needed Tag_ABI_FP_denormal: Needed Tag_ABI_FP_exceptions: Needed Tag_ABI_FP_number_model: IEEE 754 Tag_ABI_align_needed: 8-byte Tag_ABI_align_preserved: 8-byte, except leaf SP Tag_ABI_enum_size: int ~~~ 默认编译出来的ARM架构是ARMv5TE ### Makefile 我的makefile主要内容如下,之后可能有添加 ~~~makefile CROSS_COMPILE=/home/jjinl/gcc_set/arm-2013.05/bin/arm-none-linux-gnueabi- APP_NAME = test1 APP_SRC = test1.c run: $(CROSS_COMPILE)gcc -o $(APP_NAME) $(APP_SRC) -static qemu-arm $(APP_NAME) dis_bin: $(CROSS_COMPILE)gcc -o $(APP_NAME) $(APP_SRC) $(CROSS_COMPILE)objcopy -O binary $(APP_NAME) $(APP_NAME).bin $(CROSS_COMPILE)objdump -m arm -b binary -D $(APP_NAME).bin dis_elf: $(CROSS_COMPILE)gcc -o $(APP_NAME) $(APP_SRC) $(CROSS_COMPILE)objdump -d $(APP_NAME) ~~~ run 目标,编译后通过qemu-arm运行,这个命令只能在linux运行 dis_bin: 把elf转为bin,并反编译 dis_elf:反编译elf #### 参考文档 在doc目录下 DDI0100E.pdf 包含ARMv5TE指令描述。 ARM指令集如下图: ![instr1](doc/instr1.png) 指令详细说明 ![instr1](doc/instr2.png) ![instr1](doc/instr3.png)