大家記得看嘿 XD
附上 題目出處
以下答案給大家參考囉!
最後修訂 12/26/pm 5:00
1.
#include <stdio.h> int main() { char Value = 0x49; char H,L; _asm{ MOV AX,0 MOV AL,[Value] SHL AX,4 SHR AL,4 MOV [H],AH MOV [L],AL } printf("High = %#x\n",H); printf("Low = %#x\n",L); scanf("123"); return 0; }
2.
#include <stdio.h> int main() { short v1 = 0x7800; short v2 = 0x8010; short Max; _asm{ MOV AX,[v1] CMP AX,[v2] JGE M MOV AX,[v2] M: MOV [Max],AX } printf("Max = %#x\n",Max); scanf("123"); return 0; }
3.
#include <stdio.h> int main() { short n1 = 0x9156; short n2 = 0x1023; short n3 = 0x7849; short Min; _asm{ MOV AX,[n1] CMP AX,[n2] JG N2 JMP N3 N2: MOV AX,[n2] N3: CMP AX,[n3] JL END MOV AX,[n3] END: MOV [Min],AX } printf("Min = %#x\n",Min); scanf("123"); return 0; }
4.
#include <stdio.h> int main() { int n=3; // 資料元素的個數 int sum = 0; // 儲存總和的位置 int x[]={2040,-1222,242}; // 資料由此開始 _asm{ LEA EDI,[x] MOV ECX,[n] R: MOV EAX,[EDI] ADD [sum],EAX ADD EDI,4 LOOP R } printf("Sum = %d\n",sum); scanf("123"); return 0; }
5.
#include <stdio.h> int main() { int n=3; // 資料元素之個數 int cnt=0; // 儲存負數個數 short x[]={0x0f1D, 0x7E0A, 0x824B}; // 資料 _asm{ LEA EDI,[x] MOV ECX,[n] R: MOV AX,[EDI] CMP AX,-1 JG G INC [cnt] G: ADD EDI,2 LOOP R } printf("cnt = %d\n",cnt); scanf("123"); return 0; }
6.
#include <stdio.h> int main() { short n = 4; short Max = 0; short x[]={0xA484, 0x71AC, 0xE57A, 0x32F1}; _asm{ LEA EDI,[x] MOV CX,[n] R: MOV AX,[EDI] CMP [Max],AX JG G MOV [Max],AX G: ADD EDI,2 LOOP R } printf("Max = %#x\n",Max); scanf("123"); return 0; }
7.
#include <stdio.h> int main() { int n = 6; int Pos = 0, Zer = 0, Neg = 0; short Start[]={0x7602, 0x8D48, 0x2120, 0, 0xE605, 4}; _asm{ LEA EDI,[Start] MOV ECX,[n] R: MOV AX,[EDI] CMP AX,0 JG G JE E INC [Neg] JMP Next G: INC [Pos] JMP Next E: INC [Zer] Next: ADD EDI,2 LOOP R } printf("Pos = %d\n",Pos); printf("Zer = %d\n",Zer); printf("Neg = %d\n",Neg); scanf("123"); return 0; }
8.
#include <stdio.h> int main() { char Start[]="Hello, this is my first program."; int Len = 0; _asm{ LEA EDI,[Start] R: MOV AL,[EDI] AND [EDI],0xff JZ END INC [Len] ADD EDI,1 JMP R END: } printf("Len = %d\n",Len); scanf("123"); return 0; }
9.
#include <stdio.h> int main() { char Start[]="Hello 101+-*/, this is my first PROGRAM."; int c = 0; _asm{ LEA EDI,[Start] R: CMP [EDI],0 JZ END CMP [EDI],65 JNGE E CMP [EDI],97 JNL E ADD [EDI],32 E: ADD EDI,1 JMP R END: } printf("%s\n",Start); scanf("123"); return 0; }
10.
#include <stdio.h> int main() { char number = 0x5a; char Start[8]; _asm{ LEA EDI,[Start] MOV AL,[number] MOV ECX,8 R: SAR AL,1 JC ONE MOV [EDI],0x30 JMP C ONE: MOV [EDI],0x31 C: ADD EDI,1 LOOP R END: } for(int i=0;i<8;i++) printf("Start[%d] = %#x\n",i,Start[i]); scanf("123"); return 0; }
作者已經移除這則留言。
回覆刪除看過去 大概有一半是錯的
回覆刪除