asm_parser/asm_parser.h

37 lines
1.6 KiB
C
Raw Normal View History

/***************************************************************************
* 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. *
* *
***************************************************************************
*
*/
2024-10-30 16:31:10 +08:00
#ifndef ASM_PARSER_H
#define ASM_PARSER_H
#include <ctype.h>
#define ROWS 100
#define COLS 255
2024-10-30 16:31:10 +08:00
int read_asm_file(char *filename, char program[ROWS][COLS]);
int parse_instruction(char *instr, char *instr_bin_str);
2024-10-30 17:34:54 +08:00
int parse_reg(char reg_num, char *instr_bin_str);
2024-10-30 16:31:10 +08:00
int parse_add(char *instr, char *instr_bin_str);
int parse_mul(char *instr, char *instr_bin_str);
int parse_sub(char *instr, char *instr_bin_str);
int parse_div(char *instr, char *instr_bin_str);
int parse_and(char *instr, char *instr_bin_str);
int parse_or(char *instr, char *instr_bin_str);
int parse_xor(char *instr, char *instr_bin_str);
/* add additional helper functions to support other instructions */
/* add additional helper functions to support other instructions */
2024-10-30 16:31:10 +08:00
unsigned short int str_to_bin(char *instr_bin_str);
int write_obj_file(char *filename, unsigned short int program_bin[ROWS], int instr_count);
void int_to_bin_str(int num, int bits, char *bin_str);
void to_uppercase(char *str);
#endif