关于vivi程序里head.s中一段程序的疑惑,恳请大家帮忙看看

内核编译和嵌入式产品的设计与开发
回复
头像
tonychen123
帖子: 101
注册时间: 2009-04-03 20:52
来自: Guangzhou -China

关于vivi程序里head.s中一段程序的疑惑,恳请大家帮忙看看

#1

帖子 tonychen123 » 2009-06-14 23:25

今晚大概看了下vivi中的head.s,有段看不懂,郁闷了好久……

代码: 全选

#if 0
	mov	r2, #'U'
	str	r2, [r1, #oUTXHL]

1:	ldr	r3, [r1, #oUTRSTAT]
	and	r3, r3, #UTRSTAT_TX_EMPTY
	tst	r3, #UTRSTAT_TX_EMPTY
	bne	1b	

	mov	r2, #'0'
	str	r2, [r1, #oUTXHL]

1:	ldr	r3, [r1, #oUTRSTAT]
	and	r3, r3, #UTRSTAT_TX_EMPTY
	tst	r3, #UTRSTAT_TX_EMPTY
	bne	1b	
#endif
并且我发现,编译vivi时,这里将会报警告,哎

代码: 全选

arch/s3c2440/head.S:458:8: warning: extra tokens at end of #endif directive
有谁懂的可以讲解下吗,万分感谢呐
喜欢死ubuntu论坛里的人了,ubuntu万岁……
There should be one-- and preferably only one --obvious way to do it.
头像
tonychen123
帖子: 101
注册时间: 2009-04-03 20:52
来自: Guangzhou -China

Re: 关于vivi程序里head.s中一段程序的疑惑,恳请大家帮忙看看

#2

帖子 tonychen123 » 2009-06-14 23:47

代码: 全选

1:	b	1b		@ infinite loop 
程序中n次出现这指令,说是进入死循环,不懂“1:”标志这段程序是1吗? 怎么可以多出定义“1”这个地址标记呢?“1b”又是什么,都不见定义唉
百思不得其解……
There should be one-- and preferably only one --obvious way to do it.
头像
tonychen123
帖子: 101
注册时间: 2009-04-03 20:52
来自: Guangzhou -China

Re: 关于vivi程序里head.s中一段程序的疑惑,恳请大家帮忙看看

#3

帖子 tonychen123 » 2009-06-15 11:23

代码: 全选

自己搞明白了,似乎只是我在自言自语, :em06 
Local Labels

Local labels help compilers and programmers use names temporarily. They create symbols which are guaranteed to be unique over the entire scope of the input source code and which can be referred to by a simple notation. To define a local label, write a label of the form ‘N:’ (where N represents any positive integer). To refer to the most recent previous definition of that label write ‘Nb’, using the same number as when you defined the label. To refer to the next definition of a local label, write ‘Nf’—the ‘b’ stands for “backwards” and the ‘f’ stands for “forwards”.

There is no restriction on how you can use these labels, and you can reuse them too. So that it is possible to repeatedly define the same local label (using the same number ‘N’), although you can only refer to the most recently defined local label of that number (for a backwards reference) or the next definition of a specific local label for a forward reference. It is also worth noting that the first 10 local labels (‘0:’...‘9:’) are implemented in a slightly more efficient manner than the others.

Here is an example:

代码: 全选

     1:        branch 1f
     2:        branch 1b
     1:        branch 2f
     2:        branch 1b
Which is the equivalent of:

代码: 全选

     label_1:  branch label_3
     label_2:  branch label_1
     label_3:  branch label_4
     label_4:  branch label_3
There should be one-- and preferably only one --obvious way to do it.
回复