装配到比较两个数 [英] assembly to compare two numbers

查看:131
本文介绍了装配到比较两个数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是汇编语法,以确定哪两个数字是更大?

What is the assembler syntax to determine which of two numbers is greater?

什么是它的较低水平(机$ C $三)?我们可以去甚至更低?一旦我们得到的位水平,会发生什么?它是如何重新$ P $ 0的psented和1?

What is the lower level (machine code) for it? Can we go even lower? Once we get to the bit level, what happens? How is it represented in 0's and 1's?

推荐答案

从汇编程序而异的汇编。
大多数机器提供的寄存器,符号名
像R1或EAX(英特尔X86),和具有指导
像CMP名字进行比较。而对于一个比较
指令,你需要另外一个操作数,有时
寄存器,有时文字。通常装配
允许注释指令的权利。

It varies from assembler to assembler. Most machines offer registers, which have symbolic names like R1, or EAX (the Intel x86), and have instruction names like "CMP" for compare. And for a compare instruction, you need another operand, sometimes a register, sometimes a literal. Often assemblers allow comments to the right of instruction.

这是指令行如下:

<opcode>   <register> <operand>   ; comment

您汇编可能有所不同。

有关微软X86汇编程序,你可以写:

For the Microsoft X86 assembler, you can write:

CMP EAX,23;比较寄存器EAX恒23

CMP EAX, 23 ; compare register EAX with the constant 23

CMP EAX,XYZ;比较名为XYZ的内存位置的内容EAX寄存器

CMP EAX, XYZ ; compare register EAX with contents of memory location named XYZ

通常可以写在操作数区域情结前pressions
,使该指令,如果它有能力,来解决
内存多种方式。但我认为这回答了你的问题。

Often one can write complex "expressions" in the operand field that enable the instruction, if it has the capability, to address memory in variety of ways. But I think this answers your question.

这篇关于装配到比较两个数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆