EMULATOR_PDP_11
STEPIC Учебный проект на 'С', эмулятор PDP_11 в стиле ООП
Loading...
Searching...
No Matches
dev_files_io.c File Reference
#include "pdp_11/pdp_11.h"
#include "types/types.h"
#include "utils/logger/logger.h"
#include "utils/utils.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for dev_files_io.c:

Functions

void load_data_file (struct pdp_11_t *pdp, byte_t *filename)
 

Function Documentation

◆ load_data_file()

void load_data_file ( struct pdp_11_t pdp,
byte_t filename 
)
13{
14 enum {
15 res_input_data = 2
16 }; // Введены два параметра addr,
17 // и количество байт
18
19 file_t *fp;
20 word_t addr, count_str, data, res_input;
21
22 addr = count_str = data = res_input = 0x00;
23 fp = pdp_file_open(filename, (byte_t *) "rb");
24 assert(fp);
25
26 res_input = fscanf(fp, "%hx%hx", &addr, &count_str);
27 assert(res_input);
28 if (!(res_input == res_input_data)) {
30 // fprintf(stderr,"Error Readeng Files file\r\n");
31 ERROR("Error Readeng File [%s]\r\n", filename);
32 assert(res_input == res_input_data);
33 abort();
34 }
35 do {
36 for (byte_t ind = 0x0; ind < count_str; ind++) {
37 fscanf(fp, "%hx", &data);
38 b_write(pdp, (addr | ind), data);
39 }
40 res_input = fscanf(fp, "%hx%hx", &addr, &count_str);
41 } while (res_input == res_input_data);
42 // fprintf(stdout, "\nREAD FILE EXIT\n\n");
43 INFO("\nREAD FILE EXIT\n\n", "");
45 return;
46}
#define ERROR(fmt,...)
Definition logger.h:36
#define INFO(fmt,...)
Definition logger.h:37
void b_write(struct pdp_11_t *, const address_byte_t, byte_t)
Записывает байт в память PDP-11.
Definition pdp_11.c:79
unsigned char byte_t
Definition types.h:6
unsigned short int word_t
Definition types.h:7
FILE file_t
Definition types.h:10
void pdp_file_close(const file_t *)
Definition utils.c:44
file_t * pdp_file_open(const byte_t *, const byte_t *)
Definition utils.c:31
Here is the call graph for this function:
Here is the caller graph for this function: