Question: I'm testing out pseudo-solved problems to better understand MASM based assembly, but I'm getting some errors in the following: Write a program that clears the

I'm testing out pseudo-solved problems to better understand MASM based assembly, but I'm getting some errors in the following:

Write a program that clears the screen, locates the cursor near the middle of the screen, prompts the user for two integers, adds the integers, and displays their sum. Repeat the same steps three times, using a loop. Clear the screen after each loop iteration.

Based on question 4 of chapter 5 of Assembly Language for x86 Processors (7th Edition)

________

.386

.model flat,stdcall

.stack 4096

ExitProcess proto,dwExitCode:dword

COUNT=3

.data

num1 SDWORD? ;variable declaration

num2 SDWORD?

string BYTE "Enter an integer:",0 ; prints on the console

string1 BYTE "The sum is:",0

sum SDWORD 0 ; initialize sum to 0

row BYTE 5 ; initialize row to 5

col BYTE 17 ;and column to 17

.code

main PROC

call Clrscr ; clear console

mov ecx,count ;move count to ecx

mov sum,0 ;assign 0 to sum

; enter integers values until loop fails

L: mov dh,row ; move row to 8 bit DH(high)

mov dl,col ;move col to 8 bit DL(low)

call Gotoxy ;locates the cursor at a

;given row and column in the

;console window

mov edx,OFFSET string1 ;place the offset of str in

;edx

call WriteString ; to write a string to

;console

call ReadInt ; reads an integer

add sum,eax ; add the contents of eax to

;sum

add row,2

loop L

;display the output, sum

mov dh,row

mov dl,col

call Gotoxy

mov edx,OFFSET String1

call WriteString

mov eax,sum

call WriteInt ; write an integer to the console

call Crlf ;writes end-of-line sequence to console

invoke ExitProcess,0

main endp

end main

_______

The errors when built are the following:

1>------ Rebuild All started: Project: Project, Configuration: Debug Win32 ------ 1>Assembling ..\00 Workin Folder\SimpleAddition2.asm... 1>..\00 Workin Folder\SimpleAddition2.asm(8): error A2008: syntax error : num1 1>..\00 Workin Folder\SimpleAddition2.asm(9): error A2008: syntax error : num2 1>..\00 Workin Folder\SimpleAddition2.asm(17): error A2006: undefined symbol : Clrscr 1>..\00 Workin Folder\SimpleAddition2.asm(23): error A2006: undefined symbol : Gotoxy 1>..\00 Workin Folder\SimpleAddition2.asm(28): error A2006: undefined symbol : WriteString 1>..\00 Workin Folder\SimpleAddition2.asm(30): error A2006: undefined symbol : ReadInt 1>..\00 Workin Folder\SimpleAddition2.asm(38): error A2006: undefined symbol : Gotoxy 1>..\00 Workin Folder\SimpleAddition2.asm(40): error A2006: undefined symbol : WriteString 1>..\00 Workin Folder\SimpleAddition2.asm(42): error A2006: undefined symbol : WriteInt 1>..\00 Workin Folder\SimpleAddition2.asm(43): error A2006: undefined symbol : Crlf 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\BuildCustomizations\masm.targets(50,5): error MSB3721: The command "ml.exe /c /nologo /Sg /WX /Zi /Fo"Debug\SimpleAddition2.obj" /Fl"Project.lst" /I "c:\Irvine" /W3 /errorReport:prompt /Ta"..\00 Workin Folder\SimpleAddition2.asm"" exited with code 1. 1>Done building project "Project.vcxproj" -- FAILED. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Based on this, I assume the problem is A: How do I solve the syntax errors for num1 and num2, and B: How do I define a symbol.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!