免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3262 | 回复: 2
打印 上一主题 下一主题

会as语法的进来一下!!! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-03-16 17:45 |只看该作者 |倒序浏览
有个例子


        .text
        .global _start

        .equ        num, 20                ; Number of words to be copied???????????

_start:
        ldr        sp,=stack_top        ; Set up the stack pointer (R13) to some memory
                                ; reserved for this purpose



        ldr     r0,=src                ; R0 = pointer to source block
        ldr     r1,=dst                ; R1 = pointer to destination block
        mov     r2,#num                ; R2 = number of words to copy

blockcopy:
        movs        r3,r2,lsr #3        ; R3 = number of eight-word multiples
        beq        copywords        ; Do we have less than eight words to move?

        stmfd        sp!,{r4-r11}        ; Save our working registers (R4-R11)

octcopy:
        ldmia        r0!,{r4-r11}        ; Load 8 words from the source; update R0
        stmia        r1!,{r4-r11}        ; and store them at the destination; update R1
        subs        r3,r3,#1        ; Decrement the counter (num. of 8-words)
        bne        octcopy                ; and repeat if necessary

        ldmfd        sp!,{r4-r11}        ; Restore original register contents

copywords:
        ands        r2,r2,#7        ; Number of words left to copy
        beq        done

wordcopy:
        ldr        r3,[r0],#4        ; Load a word from the source
        str        r3,[r1],#4        ; and store it at the destination
        subs        r2,r2,#1        ; Decrement the counter (num. of words)
        bne        wordcopy        ; and repeat if necessary

done:                                ; Finished copying!

exit:        swi        0x11


        .data                        ; Read/write data follows
        .align                        ; Make sure data is aligned on 32-bit
                                ; boundaries

src:        .word         1,  2,  3,  4,  5,  6,  7,  8,  9, 10
        .word        11, 12, 13, 14, 15, 16, 17, 18, 19, 20

dst:        .skip        num * 4                ; Reserve 80 bytes (num 32-bit words)


        .section .bss                ; Uninitialised storage space follows
        .align



stack:                .skip        1024        ; Allow 1KB for the local stack
stack_top:                        ; The stack grows downwards in memory, so we
                                ; need a label to its top

        .end

我就是想问,这里的num怎么没有在.data里面定义??????
这样定义一个东西可以吗?????????
这种定义是不是常量或则是局部变量的意思????

论坛徽章:
3
2015年迎新春徽章
日期:2015-03-04 09:56:11数据库技术版块每日发帖之星
日期:2016-08-03 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
2 [报告]
发表于 2007-03-16 19:29 |只看该作者
先理解什么叫立即数再来学习汇编

论坛徽章:
0
3 [报告]
发表于 2007-04-16 12:37 |只看该作者
.equ        num, 20
这里并没有定义什么。只是在符号表里增加了一组对应值:num和20。在汇编时,将在所有使用num处填入20。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP