日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【ARM】在Uboot中运行第一个汇编程序

發布時間:2024/4/24 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【ARM】在Uboot中运行第一个汇编程序 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

00. 目錄

文章目錄

    • 00. 目錄
    • 01. 匯編程序
    • 02. 編譯
    • 03. 下載執行
    • 04. 文件對比
    • 05. 程序示例二
    • 06. 附錄

01. 匯編程序

匯編程序

.section .rodata.align 2 .LC0:.string "hello arm\n".section .text.align 2.global _start _start:stmfd sp!, {lr}ldr r0, =.LC0mov lr, pc@uboot中printf的地址ldr pc, =0x43e11a2cldmfd sp!, {pc}

0x43e11a2c地址的獲取

查看System.map文件

[root@itcast uboot_tiny4412-master]# cat System.map | grep printf 43e1188c T serial_printf 43e11978 T fprintf 43e11a2c T printf 43e11a70 T vprintf 43e26b74 T vsprintf 43e271ac T sprintf [root@itcast uboot_tiny4412-master]#

02. 編譯

編譯生成二進制文件

# 第一步:生成目標文件 [root@itcast 8th]# arm-linux-gcc -c 1hello.s -o 1hello.o# 第二步:鏈接 生成可執行文件 [root@itcast 8th]# arm-linux-ld -Ttext=0x40008000 1hello.o -o 1hello# 第三步:生成不帶頭信息的二進制文件 [root@itcast 8th]# arm-linux-objcopy -O binary 1hello 1hello.bin [root@itcast 8th]#

03. 下載執行

在minicom端

DengJin # dnw 70000000 OTG cable Connected! Now, Waiting for DNW to transmit data Download Done!! Download Address: 0x70000000, Download Filesize:0x28 Checksum is being calculated. Checksum Value => MEM:fb3 DNW:1083 Checksum failed.DengJin #

在PC端

# 將bin文件通過dnw下載到開發板 [root@itcast 8th]# dnw 1hello.bin load address: 0x57E00000 Writing data... 100% 0x00000032 bytes (0 K) speed: 0.000076M/S [root@itcast 8th]#

執行

DengJin # go 70000000 ## Starting application at 0x70000000 ... hello arm ## Application terminated, rc = 0xA DengJin #

04. 文件對比

[root@itcast 8th]# file 1hello.bin 1hello.bin: data[root@itcast 8th]# file 1hello 1hello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, not stripped[root@itcast 8th]# ls -l 1hello 1hello.bin -rwxr-xr-x. 1 root root 33565 8月 4 10:34 1hello -rwxr-xr-x. 1 root root 40 8月 4 10:42 1hello.bin [root@itcast 8th]#

05. 程序示例二

匯編程序

.section .rodata.align 2 .LC0:.string "hello arm\n".section .text.align 2.global _start _start:stmfd sp!, {lr}ldr r0, =.LC0 mov lr, pcldr pc, =0x43e11a2cmov r4, #'a' 1:mov r0, r4mov lr, pcldr pc, =0x43e119f4add r4, #1cmp r4, #'z'ble 1bmov r0, #'\n'mov lr, pcldr pc, =0x43e119f4ldmfd sp!, {pc}

編譯生成二進制文件

[root@itcast 2main]# arm-linux-gcc -c main.s [root@itcast 2main]# arm-linux-ld -Ttext=0x40008000 main.o -o main [root@itcast 2main]# arm-linux-objcopy -O binary main main.bin

執行結果

DengJin # go 40008000 ## Starting application at 0x40008000 ... hello arm abcdefghijklmnopqrstuvwxyz ## Application terminated, rc = 0xD DengJin #

06. 附錄

總結

以上是生活随笔為你收集整理的【ARM】在Uboot中运行第一个汇编程序的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。