後的結果)(20%)
AL CF ZF SF OF PF mov AL, 127 add AL, -128 11111111 0 0 1 0 1 mov AL, 127 sub AL, -128 11111111 1 0 1 1 1 mov AL, -1 add AL, 1 00000000 1 1 0 0 1 mov AL, 127 inc AL 10000000 X 0 1 1 0 mov AL, 127 neg AL 10000001 1 0 1 0 1 mov AL, 0 neg AL 00000000 0 1 0 0 1
2. mov BL, 59 statement1 statement2 mov AL, 0 jump end1 skip1:
mov AL, 1 end1:
在上面的程式片斷中,若statement1與statement2為下列之指令,請問執行
後AL的值等於多少?(20%) statement1 statement2 AL cmp BL, 58 jc skip1 0 cmp BL, 59 jc skip1 0 cmp BL, 60 jc skip1 1 cmp BL, 60 jnae skip1 1 cmp BL, 60 jge skip1 0 add BL, 129 jae skip1 1 add BL, 129 jnge skip1 1 add BL, 197 jz skip1 1 mov AL, 10 jo skip1 1 mul BL or BL, BL jp skip1 0
3.請將下列
C語言程式片斷翻譯為組合語言(10%)
for(i = 0; i < 10; i++) index[i] = i;
index DW 10 DUP(?)
mov DI, 0 mov CX, 0 for_loop:
cmp CX, 10 jge end_for
mov index[DI], CX inc CX add DI, 2 jmp for_loop end_for:
4.請用partial evaluation方式將下列之程式用組合語言寫出(10%) if((c != ‘q’) and (c != ‘Q’) and (c >= ‘A’) and (c <= ‘z’)) quit = 0; else
quit = 1;
cmp c, ‘q’ je else_part cmp c, ‘Q’ je else_part cmp c, ‘A’ jb else_part cmp c, ‘z’ ja else_part mov quit, 0 jmp end_if else_part:
mov quit, 1 end_if:
5. Is it possible to set both the overflow and zero flags? If so, give an example that could set both these flags; otherwise, explain why not.(10%) Yes
mov AL, -128 add AL, -128
6. 兩個64位元的數字A, B分別放在暫存器中,A=EBX:EAX, B=EDX:ECX,請寫一個procedure計算A=A-B/2。(20%) addtest PROC
shr EDX, 1 rcr ECX, 1 sub EAX, ECX sbb EBX, EDX ret
addtest ENDP
7. What are forward and backward jumps?(10%)
forward jump:所跳到的目的地是在該jump instruction的下面。
backward jump:所跳到的目的地是在該jump instruction的前面。
因篇幅问题不能全部显示,请点此查看更多更全内容