parameters - Can someone explain what I need to change in this 80x86 assembly program? -


Here's the code:

  .586. Model FLAT is included io.h; Header file for input / output. STACK 4096 DATA prompt1 BYTE "Enter n1", 0 prompt2 BYTE "Enter n2", 0 n1 dword? N2 dword? Gcdp dword? Remd dword? Straight BYTE 40 DUP (?) ResultsLL BYTE "GCD:", 0 .CODE _MainProc PROC input prompt1, string, 40 etode string MOV n1, EX input prompt 1, string, 40 etode string MOV N2, EX push N2 push N1 Call GCD ASP, 8 Detof String, EX Output Outcome LL, String Mov EX, 0 ART MimProx ENDP GCD Prok Push EBP MOU EBP, ASP Push N2 Push N1 MOUX AX, N1 MG GCDP, EXEx EX, N2ME P RimP, EX L1: Mop EX, GCDP CDX IDIR RIM MOB EBX, RIMP MOWO GCDP, EBX MIM RIMP, ADX CMP EDX, 0GnJ L1 MOOX, GCDP EBX POP ADX POP EBP Rate GCD ENDP &   

And here's the problem (as my teacher has told): "Reading stack parameters is unavailable. Please make sure you have your N2 and N1 You are also reading with White PTR [EPP + 8] and byte PTR [EBP +12], you also

then ... what is happening? What is needed to change and what is redundant? < / P>

What is needed to change and what is redundant?

These globals are not required:

  n1 dword? N2 dword? Gcdp dword? Remd dword?   

Use registers instead. The string from the .data section (initial data) and .data? allows to move into sections (unseen data) too:

 . DATA prompt1 BYTE "Enter n1", 0 prompt2 BYTE "Enter n2", 0 resultLL BYTE "GCD:", 0 .Data? String Byte 40 DUP (?) .CODE _MainProc PROC input prompt1, string, 40 atodw string mov esi, eax input prompt1, string, 40 atod string mV EDI, push eax push eii push esi call to add gcd esp, 8 dtoa string, Eax output resultLbl, string mov eax, 0 retired _MainProc ENDP gcd PROC push push ESI push EDI push EBX MOV ESI, [esp + 16]; N1 mov edi, [esp + 20]; N2l1: mov eax, esi cdq idiv edi mov ebx, edi mov esi, ebx mov edi, edx cmp edx, 0 jnz l1 mov eax, esi pop ebx pop ei pop esi ret gcd endp end_mainprakt  < / Pre> 

We do not have "technically" to save esi , or ebx to gcd proc The external code is not going to interface with our code, but we can learn to start correctly if we do not save those registers, then the parameter [esp + 4] , and [Esp + 8] . We can also get a bit advanced and can get rid of string global var and use the stack to capture the string.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -