Question
The purpose of this assignment is to write, load and display a grid in LC-3 assembly language. The grid here is a 4x4 square of
The purpose of this assignment is to write, load and display a grid in LC-3 assembly language. The grid here is a 4x4 square of spaces where each space can hold Simba, a Hyena, or Simbas Home. In this programming assignment, you will learn to write code that interfaces with pre-written code. The input is a linked list of records representing gridblocks with 3 fields: 1. Coordinates (row, col) each ranging [0, 3] 2. A character indicating gridblock type: S (Start), H (Home), # (Blocked) 3. A link to the next record Note: Each record contains a field that is the address to the next record. This field is called a link, thus this data structure is called a linked list. The last record will have a link field with an address of x0000. This is the sentinel that signals the end of the linked list. Notes: The address of the first record in the list will be stored in x6000. (The first record is not at x6000). There is no defined order in which these records occur. For example, it is possible for the Home record to be at the head of the linked list. There will only be one Start gridblock and one Home gridblock in the list. There may be zero or more Hyena records. If there are no records with # in them, then that means there are no Hyenas in the jungle. When processing the list you need to pay special attention to the Start and Home records: 1. For the Start gridblock, you need to put an * in the corresponding entry in the GRID and set the global variables CURRENT_ROW and CURRENT_COL accordingly. (More on these variables below.) 2. For the Home gridblock, you need to put an H in the corresponding entry in the GRID and set the global variables HOME_ROW and HOME_COL accordingly. (More on these variables below.) You need to follow all these rules for processing the input data when writing your subroutine called LOAD_JUNGLE.
Implement the following three subroutines. Two of these subroutines are called by my code, the other (GRID_ADDRESS) is a utility routine that is called by your code. We will test it though. 1. DISPLAY_JUNGLE: This subroutine displays the state of the GRID to the Console. Inputs: None Outputs: None. The jungle GRID is located in memory at the label GRID. It is simply a set of .stringz declarations: GRID .STRINGZ "+-+-+-+-+" ROW0 .STRINGZ "| | | | |" .STRINGZ "+-+-+-+-+" ROW1 .STRINGZ "| | | | |" .STRINGZ "+-+-+-+-+" ROW2 .STRINGZ "| | | | |" .STRINGZ "+-+-+-+-+" ROW3 .STRINGZ "| | | | |" .STRINGZ "+-+-+-+-+" Note that each string is null-terminated. The output is not just a simple print of these strings as can be seen in the figure above. Each column and row number are indicated (shown in pink above) in the display of the grid on the console. You can create your own stringz if you need. 2. LOAD_JUNGLE: This subroutine reads the input linked list and appropriately populates the contents of the jungle GRID. See above for the description of the input format. Inputs: R0 - the address of the head of the linked list of gridblock records Outputs: None Purpose: Populates the GRID with the appropriate characters (*, H, #) Additionally, set the following variables: CURRENT_ROW - initialize with the row of the Start gridblock. CURRENT_COL - initialize with the column of the Start gridblock. HOME_ROW - initialize with the row of the Home gridblock. HOME_COL - initialize with the column of the Home gridblock. GRID_ADDRESS: This subroutine is key. It translates the (row, col) logical GRID coordinates of a gridblock to the physical address in the GRID memory. Inputs: R1 - row number [0, 3]; R2 - column number [0, 3] Outputs: R0 - corresponding memory address of the gridblock in the GRID Hint: There are 9 physical rows of characters and only 4 logical rows.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started