This assembly program is written in x86 architecture using AT&T syntax. It demonstrates the implementation of operations related to matrix manipulations and binary string handling, leveraging system calls and file I/O operations. The program is designed for a Computer Systems Architecture lab to demonstrate knowledge of assembly language, matrix operations, and memory management.
- in.txt: The input file that contains matrix dimensions and data required for the operations.
- out.txt: The output file where the results of matrix operations are stored.
- main.asm: The assembly source code that implements the main functionality of the program.
- Matrix: A matrix is stored in memory in a linear fashion. The program supports operations on multiple matrices, such as copying, setting elements, and performing binary operations on the matrix contents.
- Binary Vectors: The binary vectors extracted from strings are stored and manipulated in the program to demonstrate XOR operations and conversions between different formats.
- The program reads two matrix dimensions,
mandn, from the input. - It populates a matrix using input values and performs several operations on it based on conditions. The second script performs encription and decription based on keys.
- The program also supports incrementing the matrix dimensions and manipulating matrix elements in different scenarios.
- The program reads a string from user input, converts it into its binary representation, and performs XOR operations on the binary data with the matrix elements.
- Hexadecimal strings are also supported, which are converted to binary for further processing.
- The program reads initial matrix dimensions and matrix data from the
in.txtfile and writes the final matrix and results to theout.txtfile.
-
Matrix Initialization:
- The matrix is initialized based on the dimensions
mandnprovided by the user. - The input matrices are populated using the values read from the
in.txtfile.
- The matrix is initialized based on the dimensions
-
Binary String Manipulation:
- After initializing the matrices, the program reads a binary string, converts it to binary or hexadecimal, and performs XOR operations with matrix data.
-
Matrix Updating:
- The program repeatedly updates the matrix contents based on XOR results and predefined rules for incrementing/decrementing matrix elements.
-
File Writing:
- The resulting matrix is printed to
out.txt.
- The resulting matrix is printed to
- Assemble the program using
asor any assembler for the x86 architecture.as -o main.o main.s
- Link the object file to create an executable:
ld -o main main.o
- Ensure
in.txtis in the same directory as the executable with valid matrix data. - Run the program:
./main
- Check
out.txtfor the program's output.
- The input file (
in.txt) must follow a specific format:- First, the matrix dimensions
mandn. - Then, the number of matrix elements to be read.
- Subsequent lines contain matrix data.
- First, the matrix dimensions
Example in.txt:
3 3
4
1 2
2 3
3 1
The output will be stored in out.txt, containing the final state of the matrix after performing the required operations.