whatsapp

Connect on Whatsapp : +1 206 673 2541, Uninterrupted Access 24x7, 100% Confidential. Connect Now

Computer Science – Assembly Language Assignment | Get Paper Help

Description

fix this code: .386 .model flat,stdcall .stack 4096 ExitProcess proto,dwExitCode:dword .data array DWORD 1h, 2h, 3h, 4h, 5h, 6h, 9h, 0h, 1h, 2h, 3h, 4h, 5h, 0h, 1h, 2h, 3h, 4h max DWORD 0 arraySize DWORD 18 .code main proc COMMENT ! equivalent code in c++, now convert it to assembly language int main(){ const unsigned ARRAY_SIZE = 18; long array[] = { 1, 2, 3, 4, 5, 6, 9, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4 }; int max = 0; int tem = 0; for (int i = 0; i < 18; i++){ if (array[i] < array[i+1]) tem++; else tem = 0; if (tem > max) max = tem; } cout << max << endl; ;output 7 } ! ;================================START================================= mov eax, 0 ;1. set tem = 0 mov ecx, arraySize – 1 ;2. set the time of loop mov esi, 0 ;4. get the first index of the array ;====================================================================== l1: mov ebx, array[esi * 4] inc esi mov edx, array[esi * 4] ;====================================================================== cmp ebx, edx ;5. if (array[i] < array[i+1]) ja l2 ;6. if it’s false, jump to l2, set (eax)tem = 0 add eax, 1 ;7. else, increase the value of (eax)tem ;====================================================================== cmp eax, max ;10. compare eax and max, which actually compare the ‘tem’ and ‘max’ ja l3 ;11. if eax > max, jump to l3 ;====================================================================== l5: loop l1 ;====================================================================== jmp l4 ;15. loop end, jump to l4 ;====================================================================== ;====================================================================== l3: mov max, eax ;12. set the (longest increasing sequence) max = eax (current number of count) jmp l5 ;13. jump back to the loop l2: mov eax, 0 ;8. if array[i] < array[i+1], set the tem = 0, execute the loop again jmp l5 ;9. if the tem = 0, there’s no need to compare tem and max ;====================================================================== l4: ;16. no any statement in l4, loop end invoke ExitProcess,0 main endp end main

Solution:

Looking for help with your homework?
Grab a 30% Discount and Get your paper done!

30% OFF
Turnitin Report
Formatting
Title Page
Citation
Place an Order

Calculate your paper price
Pages (550 words)
Approximate price: -