How to work with vector in the hack language

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to work with vector in the hack language

souz21
I want to do the following program, in hack, but I do not know how to work with array in that language, it follows the enuado of the program:

Write a program that looks for a value inside an array. The inputs and outputs of the
Program are:
Appetizer:
Address 0: The base address of the array.
Address 1: The number of array elements.
Address 2: the element to be searched for.
Output:
Address 3: 1 if element is present in the array, 0 otherwise.

Thanks for helping me.
Reply | Threaded
Open this post in threaded view
|

Re: How to work with vector in the hack language

ybakos
What a fun exercise!

Perhaps you should start with a drawing of the Hack hardware memory. Write a few values of the array in memory somewhere. Write the base address in R0, the number of elements in R1, etc.

Think about the Hack instruction set - there are only so many commands at your disposal.