In Chess, different pieces can move in specific patterns on the chessboard. The movement of chess pieces is summarized here: https://en.wikipedia.org/wiki/Chess_piece#Moves_of_the_pieces For this assignment, you will write a RISC-V assembly program to check the validity of a chess move. Your program should be organized into two functions: checkMove, which determines whether a move is valid or not; and main, which reads a user-specified move from the .data program section, calls the checkMove function and passes it data about the move, and displays an appropriate message.
American University of Beirut Maroun Semaan Faculty of Engineering and Architecture Department of Electrical and Computer Engineering EECE 321: Computer Organization | Spring 2021 Programming Assignment #1 This assignment is due by 8:00 am on Monday, March 22, 2021. Please submit your assembly source program to Moodle. 1 Introduction In Chess, different pieces can move in specific patterns on the chessboard. The movement of chess pieces is summarized here: https://en.wikipedia.org/wiki/Chess_piece#Moves_of_the_pieces For this assignment, you will write a RISC-V assembly program to check the validity of a chess move. Your program should be organized into two functions: checkMove, which determines whether a move is valid or not; and main, which reads a user-specified move from the .data program section, calls the checkMove function and passes it data about the move, and displays an appropriate message. 2 The checkMove Function If checkMove were written as a C++ function, it would have the following declaration: int checkMove (char piece, char srcCol, char srcRow, char dstCol, char dstRow); The function takes five parameters: • piece: One of: ‘K’ = King; ‘Q’ = Queen; ‘R’ = Rook (castle); ‘B’ = Bishop (elephant); ‘N’ = Knight, ‘X’ = Pawn (soldier) moving from bottom to top; or ‘Y’ = Pawn moving from top to bottom. • srcCol, dstCol: Source and destination columns, respectively. On a chessboard, columns are identified by the letters ‘a’ to ‘h’ from left to right. Columns are also called files. • srcRow, dstRow: Source and destination rows, respectively. On a chessboard, rows are identified by the numbers ‘1’ to ‘8’ from bottom to top. Rows are also called ranks. The function also returns one of two possible values: 0 if the move is valid, and 1 if the move is invalid. The validity of a move depends on the piece and its source and destination locations. For pawns, capture moves should be considered valid. 1 3 The main Function The main function is responsible for reading a chess move from the program’s data region where it should be stored as an ASCII string. For example, “Xc2c4" represents a pawn moving from square c2 to c4; similarly, “Nb5d4" represents a knight moving from square b5 to d4. Both these moves are valid. On the other hand, “Rc6e4" is an invalid rook movement, while “Mk9z2” is an invalid chess move. Here is program template showing how the data section can be initialized: .data move: .asciiz "Qb4e7" .text .glbl main main: # main function goes here checkMove: # checkMove function goes here After reading the string, the main function should pass the appropriate parameters to the checkMove function and call it. The call should follow the appropriate conventions in saving and restoring registers on the stack. Once control returns to main, it should print an appropriate message (e.g. “Valid move") and exit. The main function should also check the syntax of the move before passing it on to checkMove. If the syntax is invalid, it should print an appropriate message and exit. 4 Deliverable and Due Date Please upload a copy of your source program to Moodle by 8:00 am on Monday, March 22, 2021. 2