Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

; This is the starter code. Use LC-3 to develop the assembly code for this. You are given the main program ; and some declarations.

; This is the starter code. Use LC-3 to develop the assembly code for this. You are given the main program

; and some declarations. The subroutines you are responsible for

; are given as empty stubs at the bottom. Follow the contract.

; You are free to rearrange your subroutines if the need were to

; arise.

;***********************************************************

.ORIG x3000

;***********************************************************

; Main Program

;***********************************************************

JSR DISPLAY_JUNGLE

LEA R0, JUNGLE_INITIAL

TRAP x22

LDI R0,BLOCKS

JSR LOAD_JUNGLE

JSR DISPLAY_JUNGLE

LEA R0, JUNGLE_LOADED

TRAP x22 ; output end message

TRAP x25 ; halt

JUNGLE_LOADED .STRINGZ " Jungle Loaded "

JUNGLE_INITIAL .STRINGZ " Jungle Initial "

BLOCKS .FILL x6000

;***********************************************************

; Global constants used in program

;***********************************************************

ASCII_OFFSET .FILL x0030

ASCII_NEWLINE .FILL x000A

;***********************************************************

; This is the data structure for the Jungle grid

;***********************************************************

GRID .STRINGZ "+-+-+-+-+"

ROW0 .STRINGZ "| | | | |"

.STRINGZ "+-+-+-+-+"

ROW1 .STRINGZ "| | | | |"

.STRINGZ "+-+-+-+-+"

ROW2 .STRINGZ "| | | | |"

.STRINGZ "+-+-+-+-+"

ROW3 .STRINGZ "| | | | |"

.STRINGZ "+-+-+-+-+"

;***********************************************************

; this data stores the state of current position of Simba and his Home

;***********************************************************

CURRENT_ROW .BLKW 1 ; row position of Simba

CURRENT_COL .BLKW 1 ; col position of Simba

HOME_ROW .BLKW 1 ; Home coordinates (row and col)

HOME_COL .BLKW 1

;***********************************************************

;***********************************************************

;***********************************************************

;***********************************************************

;***********************************************************

;***********************************************************

; The code above is provided for you.

; DO NOT MODIFY THE CODE ABOVE THIS LINE.

;***********************************************************

;***********************************************************

;***********************************************************

;***********************************************************

;***********************************************************

;***********************************************************

;***********************************************************

;***********************************************************

; DISPLAY_JUNGLE

; Displays the current state of the Jungle Grid indicating

; where Simba is (*) and any Hyena's(#) and

; Simba's Home (H).

; Input: None

; Output: None

; Notes: The displayed grid must have the row and column numbers

;***********************************************************

DISPLAY_JUNGLE

RET

;***********************************************************

; LOAD_JUNGLE

; Input: R0 has the address of the head of a linked list of

; gridblock records. Each record has four fields:

; 1. row # (0-3)

; 2. col # (0-3)

; 3. Symbol (can be S->start,H->Home or #->Hyena)

; 4. Address of the next gridblock in the list

; The list is guaranteed to:

; * have only one Start and one Home gridblock

; * have zero or more gridboxes with Hyenas

; * be terminated by a gridblock whose next address

; field is a zero

; Output: None

; This function loads the JUNGLE from a linked list by inserting

; the appropriate characters in boxes (S(*),#,H)

; You must also change the contents of these

; locations:

; 1. (CURRENT_ROW, CURRENT_COL) to hold the (row, col)

; numbers of Simba's Start gridblock

; 2. (HOME_ROW, HOME_COL) to hold the (row, col)

; numbers of the Home gridblock

;

;***********************************************************

LOAD_JUNGLE

; This file has the linked list for the

; Jungle's layout

.ORIG x6000

.FILL Head

blk2

.FILL 1

.FILL 1

.FILL x23

.FILL blk4

Head

.FILL 3

.FILL 1

.FILL x23

.FILL blk1

blk1

.FILL 1

.FILL 2

.FILL x48

.FILL blk3

blk3

.FILL 2

.FILL 1

.FILL x53

.FILL blk2

blk4

.FILL 0

.FILL 2

.FILL x23

.FILL 0

.END

RET

;***********************************************************

; GRID_ADDRESS

; Input: R1 has the row number (0-4)

; R2 has the column number (0-4)

; Output: R0 has the corresponding address of the space in the GRID

; Notes: This is a key routine. It translates the (row, col) logical

; GRID coordinates of a gridblock to the physical address in

; the GRID memory.

;***********************************************************

GRID_ADDRESS

RET

.END

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

Students also viewed these Databases questions

Question

5. Do you have any foreign language proficiency?

Answered: 1 week ago