goonj 0 Newbie Poster

I am new to assembly so I need help with fixing some things in my code.
I need to add three integers and print their sum.
The prompt for "Enter the integer" changes color each 3 time it asks the user for entering the number, on a white background. I need to use puch and pop for register to save and restore
Then , I need to put this array of 3 integers in a loop, using loop. Then , I need to use Gotoxy to locate the cursor position. Also, the prompts should be in the middle of the window->

Enter the integer: 3 (For eg-red color)
Enter the integer: 3 (For eg-blue color)
Enter the integer: 3 (For eg-cyan color)
The sum is : 9 (For eg-magenta color)

What I have done is-->

TITLE Program Template     (asgn3a.asm)

; Calculate the sum of three integers using loops and change the text color with every loop proceeding.
; Author: Verma Goonj
;Creation Date: 24th October 2010
;Date: 25th October, 2010

Include Irvine32.inc
.data

str1 BYTE"Enter an integer : ",0
stra BYTE"Enter an integer : ",0
str3 BYTE"Enter an integer : ",0
sum BYTE "The sum is :", 0

val1 DWORD ?
val2 DWORD ?
val3 DWORD ?
x DWORD    ?
xyz DWORD  ?

.code
main PROC

;Set the first text color and Prompt the user for the first integer value
mov eax, blue + (white * 16)
call SetTextColor
mov edx, OFFSET stra
call WriteString                            ;Display the prompt(blue foreground and white background)
call Clrscr                                 ; clear the screen
call WriteSTring                            
call ReadInt                                ;input the integer
mov val1,eax

;Set the second text color and Prompt the user for the second integer value
mov eax, magenta + (white * 16)
call SetTextColor
mov edx, OFFSET str3
call WriteString                        ;Display the prompt(magenta forground,white background)
call ReadInt                             ;input the integer
mov val2,eax                             ;move the value in eax to val2

;set the third text color and prompt user for the third integer value
mov eax, cyan + (white * 16)
call SetTextColor
mov edx,OFFSET str1
call WriteSTring                         ;Display the prompt(cyan forground,white background)
call ReadInt                             ;input the integer
mov val3,eax

;Adding the first two numbers(x=val1+val2)
mov eax, val1                     ;move val1 into eax
add eax, val2                     ;move val2 into eax and add it to val1
mov x,eax                         ;save in another variable called x

;Adding the first and second number to the third number(xyz=x+val3)

mov eax, x                      ;move the value of x into eax
add eax, val3                   ;move the value into eax and add it to x
mov xyz,eax                      ;move the value of eax to another variable called xyz
 

;Display the inetger 
call Crlf                                ;new line
;Set the text color to blue
mov eax, blue + (white * 16)
call SetTextColor
mov eax, xyz                    ;move the value of xyz to eax

mov edx,OFFSET sum             ;display the prompt
call WriteString              
call WriteInt            ;display the integer (value in xyz)
call Crlf                 ;new line

exit
main ENDP
END main
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.