Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m testing out pseudo-solved problems to better understand MASM based assembly

ID: 3590282 • Letter: I

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 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 .. Workin FolderSimpleAddition2.asm...
1>.. Workin FolderSimpleAddition2.asm(8): error A2008: syntax error : num1
1>.. Workin FolderSimpleAddition2.asm(9): error A2008: syntax error : num2
1>.. Workin FolderSimpleAddition2.asm(17): error A2006: undefined symbol : Clrscr
1>.. Workin FolderSimpleAddition2.asm(23): error A2006: undefined symbol : Gotoxy
1>.. Workin FolderSimpleAddition2.asm(28): error A2006: undefined symbol : WriteString
1>.. Workin FolderSimpleAddition2.asm(30): error A2006: undefined symbol : ReadInt
1>.. Workin FolderSimpleAddition2.asm(38): error A2006: undefined symbol : Gotoxy
1>.. Workin FolderSimpleAddition2.asm(40): error A2006: undefined symbol : WriteString
1>.. Workin FolderSimpleAddition2.asm(42): error A2006: undefined symbol : WriteInt
1>.. Workin FolderSimpleAddition2.asm(43): error A2006: undefined symbol : Crlf
1>C:Program Files (x86)Microsoft Visual Studio7CommunityCommon7IDEVCVCTargetsBuildCustomizationsmasm.targets(50,5): error MSB3721: The command "ml.exe /c /nologo /Sg /WX /Zi /Fo"DebugSimpleAddition2.obj" /Fl"Project.lst" /I "c:Irvine" /W3 /errorReport:prompt /Ta".. Workin FolderSimpleAddition2.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.

Explanation / Answer

Looking at your code, i think it is trying to call the functions that are available in KIP's IRVINE32 Library.

Looking at your code, i think it is trying to call the functions that are available in KIP's IRVINE32 Library.

So just gaive a try by installing it and try including Irvine32.inc into your ASM code. INCLUDE Irvine32.inc I dont have the resources to test it. I found a perfect setup guide in kipirvine.com where it nicely explains how to setup Visual Studio for ASM. Just try to setup your environment based on that.