微机原理ch04 ARTHIMETIC AND LOGICA INSTRUCTIONS AND PROGRAMS.docVIP

微机原理ch04 ARTHIMETIC AND LOGICA INSTRUCTIONS AND PROGRAMS.doc

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
微机原理ch04 ARTHIMETIC AND LOGICA INSTRUCTIONS AND PROGRAMS

PAGE 44 ARTHIMETIC AND LOGICAL INSTRUCTIONS AND PROGRAMS USING ADDITION AND SUBTRATION Addition of unsigned numbers The form of the ADD/ADC instruction is: add dest, source ;dest = dest + source adc dest, source ;dest = dest + source + CF The instructions ADD and ADC are used to add two operands. The destination operand can be: a register in memory The source operand can be: a register in memory, or immediate Remember that memory-to-memory operation are NEVER allowed in 80x86 assembly language. The instruction could change any of the ZF, SF, AF, CF, or PF bit of the flag register, depending on the operands involved. Example: Show how the flag register is affected by: mov al, 0f5h add al, 0bh Solution: F5 1111 0101 + 0B 0000 1011 100 0000 0000 After the addition, the AL register (destination) contains 00H and the flags are as follows: CF = 1, since there is a carry out from d7 SF = 0, the status of d7 of the result PF = 1, the number of 1s is zero (zero is an even number) AF = 1, there is a carry out from d3 to d4 ZF = 1, the result of the addition is zero (for 8 bits) Case 1: Addition of individual byte and word data Example 1: Write a program to calculate the total of 5 bytes of data. The decimal data is as follow: 125, 235, 197, 91, and 48. title prog3-1A adding 5 bytes .model small .stack 64 ; .data count equ 05 data1 db 125, 235, 197, 91, 48 org 0008h sum dw ? ; .code main proc far mov ax, @data mov ds, ax mov cx, count ;CX is the loop counter mov si, offset data1 ;SI is the data pointer mov ax, 00 ;AX will be hold the sum back: add al, [si] ;add the next byte to AL jnc over ;if no carry, continue inc ah ;else accumulate the carry in AH over: inc si ;increment the data pointer dec cx ;decrement the loop counter jnz back ;if not finished, go add next byte mov sum, ax ;store sum mov ah, 4ch int 21h ;go back to DOS main endp end main Code segment Data segment and stack segment Example 2: Write a program to calculate the

文档评论(0)

junzilan11 + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档