Untitled
unknown
assembly_x86
3 years ago
3.5 kB
13
Indexable
//Übung 3.2 movsx eax, byte ptr[sc] -> schiebe sc nach eax un mach signed extend. movsx ebx, word ptr[ssh] imul eax, ebx -> multipliziere eax mit ebx imul eax, dword ptr[sint] -> multipliziere eax mit sint movzx ebx, word ptr[us] add ebx, dword ptr[ui] sub esp, 8 -> 8 byte platz machen aufm Stack mov dword ptr[esp], ebx mov dword ptr[esp + 4], 0 fild qword ptr[esp] fld dword ptr[f] fmul mov dword ptr[esp], eax fiadd dword ptr[esp] fist dword ptr[l] //Übung 3.3 fild qword ptr[ll1] -> gespeichert in st0 fild qword ptr[ll2] -> gespeichert in st1 fmul -> multipliziere st0 und st1 fist qword ptr[ll1] -> lade von st0 in ll1 //Übung 3.4 mov eax, dword ptr [l] mov ebx, dword ptr [i] A: cmp ebx, 0 jle Ende imul eax, ebx dec ebx jmp A Ende: mov dword ptr[l], eax mov dword ptr[i], ebx //Alternativ(nicht für Intel): mov eax, dword ptr [l] mov ecx, dword ptr [i] loop Ende imul eax, ecx Ende: mov dword ptr[l], eax mov dword ptr[i], ebx //Übung 4.1 mov dword ptr[summe], 0 xor ecx, ecx mov ebx, dword ptr[a] A: cmp ecx, dword ptr[n] jge Ende add ecx, dword ptr[ebx+4*ecx] //Alternativ: mov dword ptr[summe], 0 xor ecx, ecx A: cmp ecx, dword ptr[n] jge Ende lea ebx, [a] mov ebx, [ebx + 4 * ecx] add dword ptr[summe], ebx inc ecx jmp A Ende: mov dword ptr[i], ecx //Übung 4.2 //noch nicht zu ende gecodet xor ebx, ebx xor ecx, ecx lea eax, [a] mov edx, dword ptr [N] A: cmp ebx, dword ptr [N] jge EndeA B: cmp ecx, dword ptr [N] jge EndeB mov [eax+4*ecx+N*4*ebx],something inc ecx jmp B EndeB: inc ebx jmp A EndeA: //Übung 6.1 __asm{ Prolog: push EBX push ESI push EDI push EBP MOV EBP, ESP SUB ESP, 4 MOV EAX, DWORD PTR[EBP + 20] MOV DWORD PTR[EBP - 4], EAX CMP EAX, 2 JAE ELSE //Jump Above Equal da unsigned MOV EAX, 1 JMP EPILOG ELSE: /* MOV EBX, DWORD PTR[EBP + 20] DEC EBX PUSH EBX Allgemeiner Funktionsaufruf CALL fibonacci ADD ESP, 4 */ MOV ESI, EAX //Speichere return Wert MOV EBX, DWORD PTR[EBP + 20] SUB EBX, 2 PUSH EBX Allgemeiner Funktionsaufruf CALL fibonacci ADD ESP, 4 4 weil 1 mal PUSH */ ADD EAX, ESI Epilog: MOV ESP, EBP pop EBP pop EDI pop ESI pop EBX RET //Übung 6.2 auf Stack => n, c, b, a n den größten Offset, a den kleinsten Offset Prolog: push EBX push ESI push EDI push EBP MOV EBP, ESP CMP DWORD PTR[EBP + 32], 1 JNE ELSE PUSH DWORD PTR[EBP + 28] PUSH DWORD PTR[EBP + 20] LEA EAX, [string1] PUSH EAX CALL printf ADD ESP, 12 //12 weil 4 mal 3 mal PUSH Anweisungen ELSE: //bewege(a, c, b, n-1); MOV EAX, DWORD PTR[EBP + 32] //PUSH von rechts nach Links ( Parameter in richtiger Reihenfolge) DEC EAX PUSH EAX PUSH DWORD PTR[EBP + 24] PUSH DWORD PTR[EBP + 28] PUSH DWORD PTR[EBP + 20] CALL bewege ADD ESP, 16 //16 weil 4 mal 4 mal PUSH //bewege(a, b, c, 1); MOV EAX, 1 PUSH EAX PUSH DWORD PTR[EBP + 28] PUSH DWORD PTR[EBP + 24] PUSH DWORD PTR[EBP + 20] CALL bewege ADD ESP, 16 //bewege(b, a, c, n-1); MOV EAX, DWORD PTR[EBP + 32] //PUSH von rechts nach Links ( Parameter in richtiger Reihenfolge) DEC EAX PUSH EAX PUSH DWORD PTR[EBP + 28] PUSH DWORD PTR[EBP + 20] PUSH DWORD PTR[EBP + 24] CALL bewege ADD ESP, 16 //16 weil 4 mal 4 mal PUSH Epilog: MOV ESP, EBP pop EBP pop EDI pop ESI pop EBX RET
Editor is loading...