write an assembly program to print out the first 5 consecutive integers: n+1 , n
ID: 3535180 • Letter: W
Question
write an assembly program to print out the first 5 consecutive integers: n+1 , n+2,n+3,n+4 and n+5 where n is a given integer from input panel
*output the sum of all printed numbers for example = 3, output will be 4 5 6 7 8 sum=30
it should look like this
mvB IR,ARR
mv X IR,d#0
//address For
MV A RR,i
COMP A IR,Max
GoGE EndFor
mV X RR,i
ASL X
outputDec BX
MV A RR,i
ADD A IR,d#1
STORE A RR,i
MV X RR,s
ADD X IR,i
Store X RR,i
GoTo For
//address EndFor
STOP
//constant Max d#7
//address i
//allocation 2 d#0
//address ARR
//allocation 14 h#0001000200030004000500060007
//address s
//allocation 2 d#0
Explanation / Answer
Please rate it.
586
.MODEL FLAT
.STACK 4096
.DATA
num1 BYTE 13;Initialize number to count to
totall BYTE 0;Total of all counted numbers
temp BYTE 0;Temp for loop adding
shiftme BYTE 1;Start of counting 2^0 so I can reach 2^6
.CODE
main PROC
;code here
increment:
;Increment label
inc temp ;Increment temp by 1
mov eax, temp
add totall, eax ;Add temp+totall and store in totall
cmp eax, num1;Compare for jump
jne increment;Jump if not equal
;this part should store each value 1,2,4,8,32.. in consecutive memory locat
shiftallthethings: Â Â ;Shift label
shl shiftme,1;Shifting bits to the left one
cmp shiftme, 64;Comparing for the jump
jne shiftallthethings;Jump if not equal to
ret
main ENDP
END
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.