Question: I'm testing out codes from the book Assembly Language for x86 Processors (7th Edition). Question 2 asks the following: Suppose you are given three data

I'm testing out codes from the book Assembly Language for x86 Processors (7th Edition).

Question 2 asks the following: Suppose you are given three data items that indicate a starting index in a list, an array of characters, and an array of link index. You are to write a program that traverses the links and locates the characters in their correct sequence. For each character you locate, copy it to a new array. Suppose you used the following sample data, and assumed the arrays use zero-based indexes: start = 1 chars: HACEBDFG links: 04562370 Then the values copied (in order) to the output array would be A,B,C,D,E,F,G,H. Declare the character array as type BYTE, and to make the problem more interesting, declare the links array type DWORD.

Here's an already existing code for the problem that I've done some working around with.

__________

TITLE Linking Array Items (linkItems.asm) ; This program displays the ordered character list using ; their links INCLUDE Irvine32.inc SPACE = 32 start = 1 .data str1 BYTE "The ordered character list is: ",0 chars BYTE H,A,I,E,B,D,F,G ; unordered array of ; characters arrSize = ($ - chars) links DWORD 8,1,3,5,2,4,6,7 ; links for ordering ; of characters linkNo DWORD ? orderedArray BYTE arrSize DUP(?) .code main PROC ; calls the procedures call Clrscr ; clears the screen call LinkItems ; calls procedure mov edx,OFFSET str1 call writeString ; writes str1 call Display ; displays ordered ; characters exit main ENDP LinkItems PROC USES ecx esi edi ; Orders the characters & save them in another array ; Receives: Nothing ; Returns: Nothing mov esi,0 ; Initialize ESI to 0 mov edi,0 ; Initialize EDI to 0 mov linkNo,start ; Initialize the linkNo to 1 mov ecx, arrSize ; runs the loop for all characters L1: .IF linkNo == links[esi] mov orderedArray[edi],chars[esi] inc edi ; increment EDI .ELSE inc esi ; increment ESI .ENDIF inc linkNo ; increment linkNo value loop L1 ret LinkItems ENDP Display PROC USES ecx esi ; displays the ordered characters ; Receives: ECX: count of characters ; Returns: Nothing L1: mov al,orderedArray[esi] ; AL= character value call WriteChar inc esi mov al,SPACE ; AL=ASCII value of space ; character call WriteChar loop L1 Display ENDP END main

_______

When built however, it is generating the following errors:

1>------ Rebuild All started: Project: Project, Configuration: Debug Win32 ------ 1>Assembling ..\00 Workin Folder\linkItems.asm... 1>..\00 Workin Folder\linkItems.asm(37): error A2070: invalid instruction operands 1>..\00 Workin Folder\linkItems.asm(58): warning A6001: no return from procedure 1>..\00 Workin Folder\linkItems.asm(36): error A2070: invalid instruction operands 1>..\00 Workin Folder\linkItems.asm(9): error A2006: undefined symbol : H 1>..\00 Workin Folder\linkItems.asm(9): error A2006: undefined symbol : A 1>..\00 Workin Folder\linkItems.asm(9): error A2006: undefined symbol : I 1>..\00 Workin Folder\linkItems.asm(9): error A2006: undefined symbol : E 1>..\00 Workin Folder\linkItems.asm(9): error A2006: undefined symbol : B 1>..\00 Workin Folder\linkItems.asm(9): error A2006: undefined symbol : D 1>..\00 Workin Folder\linkItems.asm(9): error A2006: undefined symbol : F 1>..\00 Workin Folder\linkItems.asm(9): error A2006: undefined symbol : G 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\linkItems.obj" /Fl"Project.lst" /I "c:\Irvine" /W3 /errorReport:prompt /Ta"..\00 Workin Folder\linkItems.asm"" exited with code 1. 1>Done building project "Project.vcxproj" -- FAILED. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

What should be done to get this code up and running?

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!