![]() |
|
#1
|
|||
|
|||
Program Not working, assembly languageHey,
Why won't this program work in assembly? I'm using Microsoft Visual C++ 2005 Express Edition, and using x86 assembly architecture. It's suppose to add the values in the array that are higher than the variable sample(in this case 50) and display the result. The answer should be +358 but I keep getting +0. I know it's one little mistake I'm making. Any ideas? Code: .data sum DWORD 0 sample DWORD 50 array DWORD 10,60,20,33,72,89,45,65,72,18 ArraySize = ($ - array)/ TYPE array .code main PROC mov eax, 0 mov edx, sample mov esi, 0 mov ecx, ArraySize L1: cmp esi,ecx jg L2 jmp L5 L2: cmp array[esi*4], edx jg L3 jmp L4 add eax, array[esi*4] L3: add eax,array[esi*4] L4: inc esi jmp L1 L5: mov sum, eax call Writeint call Crlf exit main ENDP END main |
|
#2
|
|||
|
|||
Re: Program Not working, assembly languageQuote:
Isn't the following logic backwards? Code:
Since the contents of esi are not greater than the contents of ecx, it bails out (by jumping to L5) without ever going through the loop. Regards, Details! Details! The devil is in the details! ---me Dave Footnote: What's up with this: Code:
Beyond removing the superfluous statement, why not make the logic more concise? Instead of a conditional jump followed by an unconditional jump, why not reverse the sense: if the value is less or equal to the threshold, jump around the add statement. |
Recent GIDBlog
Meeting the populace by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Two-Tier data dissemination code installation problem | nidhibansal1984 | Computer Software Forum - Linux | 6 | 16-Sep-2007 10:13 |
| Assemblers & assembly language | BlueFireCO. | Assembly Language | 2 | 26-Mar-2007 09:56 |
| BOOKEEPING program, HELP!! | yabud | C Programming Language | 10 | 17-Nov-2006 03:48 |
| which language ? | onauc | C++ Forum | 2 | 19-Nov-2004 02:53 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The