在组装运算code的二进制 [英] The binary of opcode in assembly
问题描述
我有以下的code(产生列表文件,英特尔80x86的写入后):
I have the following code (after producing the listing file, written for intel 80x86):
1 global _start
2
3 section .data
4 00000000 03000000 x: dd 3
5
6 ;section .text
7
8 _start:
9 00000004 8B0D[00000000] mov ecx, [x]
10 0000000A 000D[16000000] r: add byte [l+6], cl
11 00000010 C605[00000000]30 l: mov byte [x], 48
12 00000017 51 push ecx
13 00000018 B804000000 mov eax, 4 ; For "Write" system call
14 0000001D BB01000000 mov ebx, 1 ; to standard output
15 00000022 B9[00000000] mov ecx, x ; "buffer"
16 00000027 BA01000000 mov edx, 1 ; byte counter
17 0000002C CD80 int 0x80
18 0000002E 59 pop ecx
19 0000002F E2D9 loop r, ecx
20
21 00000031 BB00000000 mov ebx, 0
22 00000036 B801000000 mov eax, 1 ; For "exit" system call
23 0000003B CD80 int 0x80
我现在集中在19行,我不完全理解它。
据我所知,OP code'循环'的二进制是E2
I'm concentrating now on row 19, and I don't completely understand it. I understand that the binary of the opcode 'loop' is E2.
但是,从其中D9字节?它是怎么计算出来的?
But from where the D9 byte? how it was calculated?
推荐答案
19 0000002F E2D9环R,ECX
在什么地方第二个运算code(D9)来自哪里?
Where does the second opcode (D9) come from?
第二运算code( 0xD9
在这种情况下)是在相关目的地补地址 - 因为你跳向后,它是负在这种情况下:
The second opcode (0xD9
in this case) is the relative destination address in two's complement - since you are jumping backwards, it is negative in this case:
0x00000031 (The address following the loop instruction)
+ 0xFFFFFFD9 (Signed-extended representation of 0xD9 - actually a negative number, -39 decimal)
============
0x0000000A (The address of the r label)
注意目的地地址是基于地址计算的在循环指令。
又见<一个href=\"http://www.mathemainzel.info/files/x86asmref.html#loop\">http://www.mathemainzel.info/files/x86asmref.html#loop
这篇关于在组装运算code的二进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!