|
|
|
|
 请大家讨论一个汇编的概念 - amtb [ 2002-12-26 12:03 | 132 byte(s)]
 Re: 请大家讨论一个汇编的概念 - bx_bird [ 2002-12-26 12:40 | 152 byte(s)]
 Re: 请大家讨论一个汇编的概念 - xexz [ 2002-12-26 15:31 | 6 byte(s)]
 Re: 请大家讨论一个汇编的概念 - amtb [ 2002-12-26 14:47 | 201 byte(s)]
 Re: 请大家讨论一个汇编的概念 - bx_bird [ 2002-12-26 12:38 | 431 byte(s)]
 Re: 请大家讨论一个汇编的概念 - amtb [ 2002-12-26 14:37 | 140 byte(s)]
 Re: 请大家讨论一个汇编的概念 - bx_bird [ 2002-12-26 16:54 | 449 byte(s)]
 大体上搞明白了,是否如此? - amtb [ 2002-12-28 18:48 | 2,566 byte(s)]
 Re: 请大家讨论一个汇编的概念 - amtb [ 2002-12-27 09:56 | 3,354 byte(s)]
 Re: 请大家讨论一个汇编的概念 - snowsky [ 2002-12-26 12:26 | 42 byte(s)]
|
|
|
|
[Original]
[Print]
[Top]
|
绝对跳转(Absolute jump)到底是个什么跳转?
在as.info中多次提到absolute这个词,但不好把握在各处的中文意思。大家多多指点一下!
|
|
----
一切有为法 如梦幻泡影
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
arm cpu
b label----------------------相对
机器码:
op of "b" | (current address - address of "label")<<2
跳转的地址在机器码里表现为目标地址与跳转语句地址之间的差值
ldr r0,label
mov pc,r0-----------------绝对
机器码:忘了:(
跳转的地址在机器码里表现为目标地址的值,与这句跳转指令在什么地方没有关系
|
|
|
----
--------笨又不是我的錯
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
不会吧,我已陆续收到几个章节的翻译,不过现在校订这几章,没有时间和大家联系。迟些征求作者同意后,我会陆续贴出来的。
如果哪位无法完成原计划的,也请给我打个招呼。参加和退出都是自愿的:-)
|
|
|
----
一切有为法 如梦幻泡影
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
jump table常用在share lib里:
JMP_FUNC1:
jmp func1
JMP_FUNC2:
jmp func2
.......-----------------------以上就是jmp table,就是一串跳转指令,指令长度相同,我想应该都是长跳转吧,跳到实际的函数入口
func1:
.........
func2:
........
share lib把JMP_FUNC1,JMP_FUNC2的地址作为lib函数func1,func2的入口export出去,可以使lib格式整齐,便于update
:
|
|
|
----
--------笨又不是我的錯
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
多谢您的指点!
现在有一段文挡,按原文翻译出来,思路不太清晰。原文如下:
7.92 .word expressions
This directive expects zero or more expressions, of any section, separated by commas.
The size of the number emitted, and its byte order, depend on what target computer
the assembly is for.
Warning: Special Treatment to support Compilers
Machines with a 32-bit address space, but that do less than 32-bit addressing, require
the following special treatment. If the machine of interest to you does 32-bit addressing
(or doesn’t require it; see Chapter 8 [Machine Dependencies], page 61), you can ignore this
issue.
In order to assemble compiler output into something that works, as occasionally does
strange things to ‘.word’ directives. Directives of the form ‘.word sym1-sym2’ are often
emitted by compilers as part of jump tables. Therefore, when as assembles a directive of
the form ‘.word sym1-sym2’, and the dierence between sym1 and sym2 does not fit in 16
bits, as creates a secondary jump table, immediately before the next label. This secondary
jump table is preceded by a short-jump to the first byte after the secondary table. This
short-jump prevents the flow of control from accidentally falling into the new table. Inside
the table is a long-jump to sym2. The original ‘.word’ contains sym1 minus the address of
the long-jump to sym2.
If there were several occurrences of ‘.word sym1-sym2’ before the secondary jump table,
all of them are adjusted. If there was a ‘.word sym3-sym4’, that also did not fit in sixteen
bits, a long-jump to sym4 is included in the secondary jump table, and the .word directives
are adjusted to contain sym3 minus the address of the long-jump to sym4; and so on, for as
many entries in the original jump table as necessary.
===========================================
译文如下:7.92 .word expressions
本命令可不带表达式或带多个表达式,这些表达式可以属于任意段,每个表达式由逗号分隔。汇编生成的数字的大小,字节顺序视生成程序运行的目标机器而定。
警告:支持编译器的特殊处理
有些机器具有32位地址空间,但不能完全进行32位寻址,需要下列的特殊处理。如果您关心的机器能够进行32位寻址,(或者根本不需要32位寻址;见第8章[机器相关性],61页)则可以忽略这个问题。
为了使由编译器产生源码的汇编结果能够正确地运行,as偶尔会对‘.word’命令进行些奇怪的操作。编译器在跳转表部分经常生成类似‘.word s ym1-sym2’形式的命令。所以,当as汇编一条形如‘.word sym1-sym2’的命令,且sym1和sym2之间的偏移量大于16位时,as会在下个标签前处创建一个‘第2跳转表’,在‘第2跳转表’中加插一个短跳转语句,目的地址为紧跟在第2个标签(sym2)后的第1个字节。 这个短跳转防止控制流程意外地落入其他跳转表。在表内是个到sym2的长跳转。原来的‘.word’包含sym1减去至sym2的长-跳转语句的地址。
如果在第2跳转表前有几个‘.word sym1-sym2’,这些命令都要进行调整。如果存在一个‘.word sym3-sym4’,且地址差也大与16位,第2跳转表中将包含一个长-跳转语句,目的地址为sym4,且.word命令将被调整为包含sym3减去到sym4长-跳转语句的地址; 如是类推,原始跳转表中的表项数目视需要而定。
============================================
能否分析一下这段文字说明的是什么情况?
|
|
|
----
一切有为法 如梦幻泡影
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
新的译文:
============================================
7.92 .word expressions
本命令可不带表达式或带多个表达式,这些表达式可以属于任意段,每个表达式由逗号分隔。汇编生成的数字的大小,字节顺序视生成程序运行的目标机器而定。
警告:支持编译器的特殊处理
有些机器具有32位地址空间,但不能完全进行32位寻址,需要下列的特殊处理。如果您关心的机器能够进行32位寻址,(或者根本不需要32位寻址;见第8章[机器相关性],61页)则可以忽略这个问题。
为了使由编译器产生源码的汇编结果能够正确地运行,as偶尔会对‘.word’命令进行些奇怪的操作。编译器在跳转表部分经常生成类似‘.word sym1-sym2’形式的命令。所以,当as汇编一条形如‘.word sym1-sym2’的命令,且sym1和sym2之间的偏移量大于16位时,as会在下个标签前处创建一个‘次级跳转表’,在‘次级跳转表’前面加插上一个短-跳转指令,这个短-跳转指令的目的地址是‘次级跳转表’之后的第一个字节。 这个短跳转防止控制流程意外地落入新的跳转表(次级跳转表)。在‘次级跳转表’内是个目的地址为sym2的长-跳转指令。原来的‘.word’命令调整为包含sym1减去至sym2的长-跳转指令的地址。
如果在次级跳转表前出现了几个‘.word sym1-sym2’,这些命令都要进行调整。如果存在一个‘.word sym3-sym4’,且地址差也大与16位,次级跳转表中将包含一个至sym4的长-跳转指令,且.word命令将被调整为包含sym3减去到sym4长-跳转指令的地址; 如是类推,处理原始跳转表中的需要处理的各个表项。
============================================
例子:
original JUMP TABLE
LABLE_FUNC1:
jmp (.word(LABLE_FUNC1-func1)) //相对跳转的伪代码,后面简化为jmp LABLE_FUNC1 - func1的形式。
LABLE_FUNC2:
jmp (.word(LABLE_FUNC2-func2))
LABLE_FUNC3:
jmp (.word(LABLE_FUNC3-func3))
func1:
........
func2:
........
func3:
........
func2与当前位置之间的偏移量大于16位,机器不能寻址,所以as将跳转表改为
original JUMP TABLE
LABLE_FUNC1:
jmp LABLE_FUNC1 - func1
LABLE_FUNC2:
jmp LABLE_FUNC2 - L1 //跳转到long-jump to func2指令处
jmp . - LABLE_FUNC3 //‘.’代表当前位置
secondary_jump_table: //次级跳转表
L1:
long-jump to func2 //长跳转伪代码
secondary_jump_table_end:
LABLE_FUNC3:
jmp LABLE_FUNC3-func3
func1:
........
func2:
........
func3:
........
当secondary_jump_table前有多个相对跳转指令,且偏移量大于16位时,在次级跳转表中逐个增加相应的长跳转。
|
|
|
----
一切有为法 如梦幻泡影
|
|
[Original]
[Print]
[Top]
|
|
|