initial this repos, add template frome students
This commit is contained in:
commit
55efae7c59
17
asm_parser.c
Normal file
17
asm_parser.c
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* file name : asm_parser.c *
|
||||||
|
* author : *
|
||||||
|
* description : the functions are declared in asm_parser.h *
|
||||||
|
* The intention of this library is to parse a .ASM file *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "asm_parser.h"
|
||||||
|
|
||||||
|
/* to do - implement all the functions in asm_parser.h */
|
||||||
22
asm_parser.h
Normal file
22
asm_parser.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* file name : asm_parser.h *
|
||||||
|
* author : *
|
||||||
|
* description : this header file declares the functions for those *
|
||||||
|
* in the "asm_parser.c" library *
|
||||||
|
* standard "string.h" C-library. *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define ROWS 100
|
||||||
|
#define COLS 255
|
||||||
|
|
||||||
|
int read_asm_file (char* filename, char program [ROWS][COLS] ) ;
|
||||||
|
int parse_instruction (char* instr, char* instr_bin_str) ;
|
||||||
|
int parse_reg (char reg_num, char* instr_bin_str) ;
|
||||||
|
int parse_add (char* instr, char* instr_bin_str ) ;
|
||||||
|
int parse_mul (char* instr, char* instr_bin_str ) ;
|
||||||
|
/* add additional helper functions to support other instructions */
|
||||||
|
unsigned short int str_to_bin (char* instr_bin_str) ;
|
||||||
|
int write_obj_file (char* filename, unsigned short int program_bin[ROWS] ) ;
|
||||||
25
assembler.c
Normal file
25
assembler.c
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* file name : assembler.c *
|
||||||
|
* author : *
|
||||||
|
* description : This program will assemble a .ASM file into a .OBJ file *
|
||||||
|
* This program will use the "asm_parser" library to achieve *
|
||||||
|
* its functionality. *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "asm_parser.h"
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
|
||||||
|
char* filename = NULL ; // name of ASM file
|
||||||
|
char program [ROWS][COLS] ; // ASM file line-by-line
|
||||||
|
char program_bin_str [ROWS][17] ; // instructions converted to a binary string
|
||||||
|
unsigned short int program_bin [ROWS] ; // instructions in binary (HEX)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
0
libs/.gitkeep
Normal file
0
libs/.gitkeep
Normal file
7
test1.asm
Normal file
7
test1.asm
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
ADD R1, R0, R1
|
||||||
|
MUL R2, R1, R1
|
||||||
|
SUB R3, R2, R1
|
||||||
|
DIV R1, R3, R2
|
||||||
|
AND R1, R2, R3
|
||||||
|
OR R1, R3, R2
|
||||||
|
XOR R1, R3, R2
|
||||||
0
tests/.gitkeep
Normal file
0
tests/.gitkeep
Normal file
5
tests/files-validation.cfg
Normal file
5
tests/files-validation.cfg
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# This validation config is autogenerated by buildconfigs.sh script
|
||||||
|
# Here you can specify files that user has to enter relative to workplace directory.
|
||||||
|
|
||||||
|
# Allowed file types, default "", but can be name of file like: "submit/my_string.c" and similar
|
||||||
|
ALLOWED_FILE_TYPES="submit/asm_parser.c, submit/assembler.c"
|
||||||
36
tests/runtests.sh
Normal file
36
tests/runtests.sh
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cd /home/codio/workspace/tests
|
||||||
|
|
||||||
|
# make sure source code exists
|
||||||
|
. ./files-validation.cfg
|
||||||
|
FILES_ALLOWED=$(echo "${ALLOWED_FILE_TYPES}" | tr -d '[:space:]')
|
||||||
|
VALIDATION_SUCCESSFULL="0"
|
||||||
|
for file_allowed in $(echo "${FILES_ALLOWED}" | sed -n 1'p' | tr ',' '\n'); do
|
||||||
|
if [ ! -f "../${file_allowed}" ]; then
|
||||||
|
echo "Could not find ${file_allowed}, please check if you have uploaded your files"
|
||||||
|
VALIDATION_SUCCESSFULL="1"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ "${VALIDATION_SUCCESSFULL}" -eq "1" ]; then
|
||||||
|
echo "You have missing files, please check if you have uploaded everything that was required"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "No files are missing."
|
||||||
|
echo "______________________"
|
||||||
|
echo
|
||||||
|
|
||||||
|
# test compile all .c files
|
||||||
|
cd /home/codio/workspace
|
||||||
|
for file_allowed in $(echo "${FILES_ALLOWED}" | sed -n 1'p' | tr ',' '\n'); do
|
||||||
|
if [[ $file_allowed == *.c ]]; then
|
||||||
|
file_name="$(cut -d'/' -f2 <<<$file_allowed)"
|
||||||
|
if clang -c $file_allowed; then
|
||||||
|
echo "$file_name - Compile successful."
|
||||||
|
rm "$(cut -d'.' -f1 <<<$file_name)"".o"
|
||||||
|
else
|
||||||
|
echo "$file_name - Failed to compile!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo
|
||||||
5
tests/weights.cfg
Normal file
5
tests/weights.cfg
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Score weights for all test classes
|
||||||
|
# This file has been generated by buildweightsconfig.sh script
|
||||||
|
# The score weights will work only if you include the weight key as first word of failure message
|
||||||
|
# The score weight can be set between 0 and infinity points :)
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user