云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 汇编语言复习资料天津大学王建荣

汇编语言复习资料天津大学王建荣

  • 62 次阅读
  • 3 次下载
  • 2025/5/31 22:24:20

5.Task: Jump to a label if unsigned EAX is greater than EBX Solution: Use CMP, followed by JA cmp eax,ebx ja Larger

6.Compare unsigned AX to BX, and copy the larger of the two into a variable named Large

mov Large,bx cmp ax,bx jna Next

mov Large,ax Next:

7.Compare signed AX to BX, and copy the smaller of the two into a variable named Small

mov Small,ax cmp bx,ax jnl Next

mov Small,bx Next:

8.Task: Jump to label L1 if bits 0, 1, and 3 in AL are all set. Solution: Clear all bits except bits 0, 1,and 3. Then compare the result with 00001011 binary.

and al,00001011b ; clear unwanted bits cmp al,00001011b ; check remaining bits je L1 ; all set? jump to L1

9.Write code that jumps to label L1 if either bit 4, 5, or 6 is set in the BL register

and bl , 01110000b cmp bl , 0 jne L1

10.Write code that jumps to label L1 if bits 4, 5, and 6 are all set in the BL register

and bl , 01110000b cmp bl , 01110000b je L1

25

11.Locate the first nonzero value in the array. If none is found, let ESI point to the sentinel value:

.data

array SWORD 50 DUP(?) sentinel SWORD 0FFFFh .code

mov esi,OFFSET array mov ecx,LENGTHOF array

L1: cmp WORD PTR [esi],0 pushfd ; push flags on stack add esi,TYPE array

popfd ; loope L1 ; continue loop jz quit ; none found

sub esi,TYPE array ; ESI points to value quit:

(三)、高级语句和汇编语句的转化 1.

if( ebx <= ecx ) {

eax = 5; edx = 6; }

cmp ebx,ecx ja next mov eax,5 mov edx,6 next: 2.

if( var1 <= var2 ) var3 = 10; else {

var3 = 6; var4 = 7; }

26

; check for zero pop flags from stack

mov eax,var1 cmp eax,var2 jle L1 mov var3,6 mov var4,7 jmp L2

L1: mov var3,10 L2: 3.

if (al > bl) AND (bl > cl) X = 1;

cmp al,bl ; first expression... ja L1 jmp next L1:

cmp bl,cl ; second expression... ja L2 jmp next

L2: ; both are true mov X,1 ; set X to 1 next: 4.

if (al > bl) AND (bl > cl) X = 1;

cmp al,bl ; first expression... jbe next ; quit if false

cmp bl,cl ; second expression... jbe next ; quit if false mov X,1 ; both are true next: 5.

if( ebx <= ecx && ecx > edx ) {

eax = 5; edx = 6;

27

}

cmp ebx,ecx ja next cmp ecx,edx jbe next mov eax,5 mov edx,6 next: 6.

if (al > bl) OR (bl > cl) X = 1;

cmp al,bl ; is AL > BL? ja L1 ; yes

cmp bl,cl ; no: is BL > CL?

jbe next ; no: skip next statement L1: mov X,1 ; set X to 1 next: 7.

while( ebx <= val1) {

ebx = ebx + 5; val1 = val1 - 1 }

top: cmp ebx,val1 ; check loop condition ja next ; false? exit loop add ebx,5 ; body of loop dec val1

jmp top ; repeat the loop next:

(四)、习题6.5.5的参考答案

1.

cmp bx ,cx jna next move x ,1

28

搜索更多关于: 汇编语言复习资料天津大学王建荣 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

5.Task: Jump to a label if unsigned EAX is greater than EBX Solution: Use CMP, followed by JA cmp eax,ebx ja Larger 6.Compare unsigned AX to BX, and copy the larger of the two into a variable named Large mov Large,bx cmp ax,bx jna Next mov Large,ax Next: 7.Compare signed AX to BX, and copy the smaller of the two into a variable named Small mov Smal

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com