I am in x64 MASM assembly language in Visual Studio. I am trying to read a txt file that contains an array. Then find the mode of that array and return it to the user. I include the standard library.
INCLUDE Irvine64.inc
; Define the maximum size of the array
.MAX_ARRAY_SIZE 100
I define the prototype for the function that reads the array from the file
.PROTO ReadArrayFromFile, fileName:PTR BYTE
I define the prototype for the function that finds the mode of the array
.PROTO FindMode, array:PTR DWORD, arraySize:DWORD:PTR DWORD
I define the prototype for the function that prints the mode to the console
.PROTO PrintMode, mode:DWORD
I define the main function
mainPROC:
I declare the variables
fileName:PTR BYTE, array:PTR DWORD, arraySize:DWORD, mode:DWORD
I allocate memory for the array
array = MALLOC(DWORD * .MAX_ARRAY_SIZE)
I read the array from the file
fileName = "array.txt"
CALL ReadArrayFromFile, fileName
I find the mode of the array
CALL FindMode, array, arraySize
I print the mode to the console
CALL PrintMode, mode
I exit the program
EXIT
Function to read the array from the file
ReadArrayFromFile PROC, fileName:PTR BYTE
I open the file
fileHandle = OPEN(fileName, READ)
No issues found
Entire Solution
Include the standard library INCLUDE Irvine64.inc
17
Define the maximum size of the array MAX_ARRAY_SIZE 100
5
6
Define the prototype for the function that reads the array from the file .PROTO ReadArrayFromFile, fileName:PTR BYTE
8
6
10 11 12
I define the prototype for the function that finds the mode of the array .PROTO FindMode, array:PTR DWORD, arraySize:DWORD:PTR DWORD
13
Define the prototype for the function that prints the mode to the console .PROTO PrintMode, mode:DWORD
15 16 17
Define the main function mainPROC:
18
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
Declare the variables
fileNamePTR BYTE, array:PTR DWORD, arraySize:DWORD, mode:DWORD
Allocate memory for the array array =MALLOC(DWORD*.MAX_ARRAY_SIZE)
: read the array from the file fileName="array.txt" CALL ReadArrayFromFile,fileName
Find the mode of the array CALL FindMode,array,arraySize
Print the mode to the console CALL PrintMode, mode
Exit the program EXIT
38 39
Function to read the array from the file ReadArrayFromFile PROC,fileName:PTR BYTE
The open the file fileHandle = OPEN(fileName, READ)
42 43
chncl,ifthnfiln AnAnAA No issues found
83 %
Error List
Entire Solution
2 Errors
0 Warnings
0 Messages
Build+ IntelliSense
Code
Description
MSB3721The command"ml64.exe/c/nologo/Zi/Fox64DebugMyAssembly.obj"/W3/errorReport:prompt /TaMyAssembly.asm"exited with code 1.
A1000
cannot open file Irvine64.inc