English 中文(简体)
如何将第DIV号法典翻译成《刑法》
原标题:Assembly How to translate opcode DIV to C Code

我知道,我曾问过几个问题,但希望这样做将帮助今后试图从事类似项目的人们,但我总是想到解决办法,但我从未去过第一页。

I looked at that Intel manual Alex posted, seems pretty alien to me http://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-software-developer-vol-2a-2b-instruction-set-a-z-manual.html

So I thought I knew how a simple DIV opcode worked. Since it s just divide after all. I had no difficulty adding ADD,SUB, of course IMUL had problems you guys helped me out on that one. Seems DIV falls into the same category as IMUL in terms of difficulty.

如果没有使用手册,就与OllyDbg进行自我分解测试。

我发现,各司的答案总是储存在上。 其余部分还保存在<编码>EDX上。

从研究这一算法来看,谁知道,谁会利用随机编号的其余部分来产生从零到10的 pre子的开关。 但我仍要问。

我从未想象过六分之二数的六分数,而其余小小点甚至属于其中。

DIV ECX

希望

regs.d.eax /= regs.d.ecx;
regs.d.edx = regs.d.eax % regs.d.ecx;

我认为,首先可能要剩下剩余部分,只是事情。

regs.d.edx = regs.d.eax % regs.d.ecx;
regs.d.eax /= regs.d.ecx;

奥凯·我几乎不与数学方案合作,因此给我带来一点混淆。 我再说一番谎言,把结果 store起来,然后把结果 by倒在奇迹上,我知道如何把其余部分拿到来。

Ok well. 查看C代码I, 或许必须储存EAXECX, 然后再在临时变量中进行区分,或首先处理其余代码。 我不知道。

Well I ll see maybe you guys can provide me with a better answer perhaps it cannot be done in one line but maybe I made a few mistakes.. I can t really test the things I do right now due to many other things I have to fix before I can even compile the software.

最佳回答

The manuals are no easy reading, true, but they have all the answers to your questions (well, most of them, there are occasional omissions and mistakes in the docs).

你在猜测算法中再次遗漏的一件事是,四肢解器通常会分出2N轨,即当你填写<代码>时。 DIV ECX, 您将EDX:EAX中包含的64-bit未签名价值按ECX的32-bit未签名价值分列。 然后,该引人储存在欧安会,其余则存放在EDX。

You should also remember about the possibility of a division overflow (in this case EDX>=ECX is the condition for it) and flags that the instruction modifies in the EFLAGS register.

问题回答

我认为,合理的翻译是:

  int16_t a=42,b=7;
  int16_t div = a/7;
  int16_t remainder = a - (div*b);

实际上,可或不得相当于remainder = a % b(需要研究标准光谱)。 如果你仔细考虑有消极数字发生的情况,就会更有意思。

尽管如此,从来就没有玩.,因此我看不出你为什么在那个岗位上提到这一点。

perhaps 不能在一线上做 [......]

我高度怀疑编辑将重新使用低压,并在适用时自动使用(E)DX的剩余部分。 (对于汇编者来说,这是微不足道的优化)





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签