HotCode
Programmer
- Sep 29, 2011
- 4
Hello, I got this simple program worked up and I just dont think it is doing what is is suppose to do. Now admittedly I am just starting in assembly language and I am still a bit lost.
This is in MASM and I want to sum every number in the array that is less than 50 (sample varable) I think I got it working but then its giving a rather large number, but that might be the index, I might be adding up the index by accident I think I am using the number in the array but not quite sure. Well thanks for any help here is the code
heads up
call WriteInt
call Crlf
call WriteSting
are from a lib from this guys book
Irvine
This is in MASM and I want to sum every number in the array that is less than 50 (sample varable) I think I got it working but then its giving a rather large number, but that might be the index, I might be adding up the index by accident I think I am using the number in the array but not quite sure. Well thanks for any help here is the code
heads up
call WriteInt
call Crlf
call WriteSting
are from a lib from this guys book
Irvine
Code:
TITLE MASM AM5 (AM5.asm)
; Description:
;
; Revision date:
INCLUDE Irvine32.inc
.data
myMessage BYTE "Assignment 5",0dh,0ah,0
myMess2 BYTE "The Sum is: " , 0
array DWORD 10, 60, 20, 33, 72, 89, 45, 65, 72, 18
sample DWORD 50
ArraySize = ($ - Array) / TYPE array
sum DWORD 0
.code
main PROC
call Clrscr
mov edx,offset myMessage
call WriteString
mov ecx,0
.WHILE ecx < ArraySize ;while( index < ArraySize)
mov eax,array[ecx] ;put whats in the array into a register for easy typeing
.IF eax <= sample ;is what in the eax/array <= sample
add sum,eax ;if so then add it to sum
.ENDIF
inc ecx ;index++
.ENDW
mov edx,offset myMess2
call WriteString ;display sum message
mov edi, sum ;display sum
call WriteInt
call Crlf
exit
main ENDP
END main