Your friend Leticia works at the Lost-and-Found office in a metro station.
Every article found is added to a new entry in a list of items for the day. At the end of the month, any item not retrieved is moved to a deposit in a box labeled with the date it was found. This is all done on paper, so things sometimes get unwieldy!
Leticia asked for your help in automating some of these tasks.
These are the instructions mentioned in this concept:
| Instruction | Description |
|---|---|
| push a | pushes a into the stack, reducing rsp by the size of a |
| pop a | pops a from the stack, increasing rsp by the size of a |
The first thing you need to do is to organize all items, so they can be looked up in a easier way. Each item is identified in storage by its ID, a description, the date it was found and a variable number of categories.
Define a function create_item_entry that has no return value and inserts a new entry for an item in a memory location.
This function may take any number of parameters, of which the first six always are:
Each subsequent parameter is the address for a string with one of the categories.
Values should be stored in the provided memory location in the same order of the arguments: ID, description, day, month, number of categories, and each category in order.
It is cumbersome to search for items in so many different lists. So, you decide to organize everything in a single list for each month. This list is implemented as an array.
Define the create_monthly_list function that allocates space in memory for an array and returns the address of that memory location.
It takes as parameters:
The allocator function takes as parameter a 64-bit unsigned integer corresponding to the size in memory to be allocated, in bytes, and returns the address for the allocated space.
Note that the allocated space has undefined value, so all bytes in that space should be cleared, ie, their value should be set to 0.
At each day, every found item should be inserted in the monthly list.
Define the insert_found_item function that has no return value and takes as parameters:
You may consider that the new entry always fits into the list and that each entry in the list takes up 120 bytes in space.
Searching for a specific entry would be much easier if Leticia could see it printed on the screen.
Define the print_item function that takes as parameters:
This function has no return value and should call the printing function with the following arguments:
0 (as a 64-bit integer) if no string is passed.The introductory string is optional.
If it is used in the printing function, this string must be NUL-terminated (ending in 0) and have at most 50 characters, already considering the NUL terminator.
Otherwise, the value 0 should be passed to the printing function instead.
You may consider that each item in the list takes up 120 bytes in space.
Your friend Leticia works at the Lost-and-Found office in a metro station.
Every article found is added to a new entry in a list of items for the day. At the end of the month, any item not retrieved is moved to a deposit in a box labeled with the date it was found. This is all done on paper, so things sometimes get unwieldy!
Leticia asked for your help in automating some of these tasks.
These are the instructions mentioned in this concept:
| Instruction | Description |
|---|---|
| push a | pushes a into the stack, reducing rsp by the size of a |
| pop a | pops a from the stack, increasing rsp by the size of a |
The first thing you need to do is to organize all items, so they can be looked up in a easier way. Each item is identified in storage by its ID, a description, the date it was found and a variable number of categories.
Define a function create_item_entry that has no return value and inserts a new entry for an item in a memory location.
This function may take any number of parameters, of which the first six always are:
Each subsequent parameter is the address for a string with one of the categories.
Values should be stored in the provided memory location in the same order of the arguments: ID, description, day, month, number of categories, and each category in order.
It is cumbersome to search for items in so many different lists. So, you decide to organize everything in a single list for each month. This list is implemented as an array.
Define the create_monthly_list function that allocates space in memory for an array and returns the address of that memory location.
It takes as parameters:
The allocator function takes as parameter a 64-bit unsigned integer corresponding to the size in memory to be allocated, in bytes, and returns the address for the allocated space.
Note that the allocated space has undefined value, so all bytes in that space should be cleared, ie, their value should be set to 0.
At each day, every found item should be inserted in the monthly list.
Define the insert_found_item function that has no return value and takes as parameters:
You may consider that the new entry always fits into the list and that each entry in the list takes up 120 bytes in space.
Searching for a specific entry would be much easier if Leticia could see it printed on the screen.
Define the print_item function that takes as parameters:
This function has no return value and should call the printing function with the following arguments:
0 (as a 64-bit integer) if no string is passed.The introductory string is optional.
If it is used in the printing function, this string must be NUL-terminated (ending in 0) and have at most 50 characters, already considering the NUL terminator.
Otherwise, the value 0 should be passed to the printing function instead.
You may consider that each item in the list takes up 120 bytes in space.