- 1、本文档共39页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
[经济学]Basic Assembly Language
Basic Assembly Language Outline Working with integers Control structures Translating standard control structures Example: finding prime numbers Working with integers Integer representation Sign extension Two’s complement arithmetic Example program Extended precision arithmetic Integer representation Integers come in two flavors: unsigned and signed. Unsigned integers are represented in a very straightforward binary manner. Three general techniques that have been used to represent signed integers. All of these methods use the most significant bit of the integer as a sign bit. This bit is 0 if the number is positive and 1 if negative. Signed magnitude One’s complement Two’s complement Signed magnitude(原码) The first method is the simplest and is called signed magnitude. E.g., 56 would be represented as the byteand ?56 would be drawbacks two possible values of zero, +0 and ?0 . general arithmetic is also complicated. E.g., If 10 is added to ?56, this must be recast as 10 subtracted by 56. One’s complement(反码) 正数的反码=正数的原码 负数的反码=原码(符号位除外)各位取反而得到的 As for the first method, there are two representations of zero:(+0) and(?0). Two’s complement(补码) 正数的补码=正数的原码 负数的补码=负数的反码加1 原码、反码和补码 十进制 原码 反码 补码 + 0 0000 0000B 0000 0000B 0000 0000B +4 0000 0100B 0000 0100B 0000 0100B +127 0111 1111B 0111 1111B 0111 1111B -0 1000 0000B 1111 1111B 0000 0000B -4 1000 0100B 1111 1011B 1111 1100B -127 1111 1111B 1000 0000B 1000 0001B -128 字长8位无法表示 1000 0000B Sign extension: Decreasing size of data The rule for unsigned numbers is that all the bits being removed must be 0 for the conversion to be correct. The rule for signed numbers is that the bits being removed must be either all 1’s or all 0’s. The first bit not being removed must have the same value as the removed bits. Sign extension: Increasing size of data In general, to extend an unsigned number, one makes all the new bits of the expanded number 0. e.g., F
文档评论(0)