Assembly Language for x86 Processors --- 4.2 课后习题答案

21 篇文章 0 订阅
13 篇文章 1 订阅

4.2 Addition and Subtraction

1 Is it possible to set the Overflow flag if you add a positive integer to a negative integer?(如果将正整数加到负整数,是否可以设置溢出标志?)

答 :No

2 Will the Overflow flag be set if you add a negative integer to a negative integer and produce a positive result?(如果将负整数加到负整数并产生正结果,是否会设置溢出标志?)

答 :Yes

3 Is it possible for the NEG instruction to set the Overflow flag?(NEG指令是否可以设置溢出标志?)

答 :Yes

4 Is it possible for both the Sign and Zero flags to be set at the same time?(是否可以同时设置符号和零标志?)

答 :No

5 Use the following data:
.data
val1 BYTE 10h
val2 WORD 8000h
val3 DWORD 0FFFFh
val4 WORD 7FFFh

a. Write an instruction that subtracts val3 from EAX.
b. Write an instruction that increments val2.
c. Write instructions that subtract val4 from val2.
d. If val2 is incremented by 1 using the ADD instruction, what will be the values of the Carry and Sign flags?
e. If val4 is incremented by 1 using the ADD instruction, what will be the values of the Overflow and Sign flags?

答 :
a. sub eax,val3

b. inc val2

c. mov ax,val4
sub val2,ax

d. CF = 0
SF = 1

e. OF = 1
SF = 1

6 Implement the following expression in assembly language: AX = (-val2 + BX) - val4.

答 :
mov ax,val2
neg ax
add ax,bx
sub ax,val4.

7 Write a sequence of two instructions that set both the Carry and Overflow flags at the same time.(编写两条指令的序列,同时设置进位和溢出标志。)

答 :
mov al,80h
add al,80h

8 Where indicated, write down the values of the Carry, Sign, Zero, and Overflow flags after each instruction has executed:

mov ax,7FF0h
add al,10h
; a. CF = SF = ZF = OF =

add ah,1
; b. CF = SF = ZF = OF =

add ax,2
; c. CF = SF = ZF = OF =

答 :
a. CF = 1 SF = 0 ZF = 1 OF = 0
b. CF = 0 SF = 1 ZF = 0 OF = 1
c. CF = 0 SF = 1 ZF = 0 OF = 0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

吃不起饭的小陈

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值