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

Functions

void test_rw_byte_w (struct pdp_11_t *pdp)
 
void test_rw_word_w (struct pdp_11_t *pdp)
 
void test_w2b_rword_w (struct pdp_11_t *pdp)
 
void test_wword_r2b_w (struct pdp_11_t *pdp)
 
void test_word_buffer (struct pdp_11_t *pdp)
 

Function Documentation

◆ test_rw_byte_w()

void test_rw_byte_w ( struct pdp_11_t pdp)
13{
14 //пишем байт, читаем байт
15
17 word_t b0, bres;
18
19 adr = 0;
20 b0 = 0x12;
21
22 DEBUG("\nПишем и читаем байт по четному адресу\r\n", "");
23
24 b_write(pdp, adr, b0);
25 bres = b_read(pdp, adr);
26
27 DEBUG("\na = %06o\t b0 = %hhx\t bres = %hhx\r\n", adr, b0, bres);
28 assert(bres == b0);
29}
#define DEBUG(fmt,...)
Definition logger.h:40
byte_t b_read(struct pdp_11_t *, const address_byte_t)
Читает байт из памяти PDP-11.
Definition pdp_11.c:92
void b_write(struct pdp_11_t *, const address_byte_t, byte_t)
Записывает байт в память PDP-11.
Definition pdp_11.c:79
unsigned short int word_t
Definition types.h:7
unsigned int address_word_t
Definition types.h:11
Here is the call graph for this function:

◆ test_rw_word_w()

void test_rw_word_w ( struct pdp_11_t pdp)
33{
34 // пишем слово, читаем слово.
35
37 word_t w, wres;
38
39 adr = 8;
40 w = 0x3456;
41
42 DEBUG("\nПишем и читаем слово\r\n", "");
43
44 w_write(pdp, adr, w);
45 wres = w_read(pdp, adr);
46 if (adr & 1)
47 (adr--);
48
49 DEBUG("\na = %06x\t w = %04x\t wres = %04x\n", adr, w, wres);
50 assert(w == wres);
51}
void w_write(struct pdp_11_t *, const address_word_t, word_t)
Записывает слово (16 бит) в память PDP-11.
Definition pdp_11.c:105
word_t w_read(struct pdp_11_t *, const address_word_t)
Читает слово (16 бит) из памяти PDP-11.
Definition pdp_11.c:118
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_w2b_rword_w()

void test_w2b_rword_w ( struct pdp_11_t pdp)
55{
56 // пишем 2 байта, читаем 1 слов;
58 byte_t b0, b1;
59 word_t w, wres;
60 DEBUG("\nПишем 2 байта, читаем слово\n", "");
61 a = 4; // другой адрес
62 w = 0xa1b2;
63 // little-endian, младшие разряды по меньшему адресу
64 b0 = 0xb2;
65 b1 = 0xa1;
66 b_write(pdp, a, b0);
67 b_write(pdp, a + 1, b1);
68 wres = w_read(pdp, a);
69 // тут полезно написать отладочную печать a, w, wres
70 DEBUG("\na=%06o\t b1=%02hhx\t b0=%02hhx\t wres=%04x\n", a, b1, b0, wres);
71 assert(w == wres);
72}
unsigned char byte_t
Definition types.h:6
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_word_buffer()

void test_word_buffer ( struct pdp_11_t pdp)
101{
102 TRACE("\r\n\t\t TEST_WORD\r\n\n", "");
103
104 test_rw_word_w(pdp);
105 test_rw_word_w(pdp);
106 test_w2b_rword_w(pdp);
107 test_wword_r2b_w(pdp);
108}
#define TRACE(fmt,...)
Definition logger.h:39
void test_wword_r2b_w(struct pdp_11_t *pdp)
Definition test_word.c:75
void test_rw_word_w(struct pdp_11_t *pdp)
Definition test_word.c:32
void test_w2b_rword_w(struct pdp_11_t *pdp)
Definition test_word.c:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_wword_r2b_w()

void test_wword_r2b_w ( struct pdp_11_t pdp)
76{
77
79 byte_t b0, b1, res_b0, res_b1;
80 word_t w;
81 DEBUG("\nПишем слово читаем 2 байтита\n", "");
82 a = 4; // другой адрес
83 w = 0xa1b2;
84 // little-endian, младшие разряды по меньшему адресу
85 res_b0 = 0xb2;
86 res_b1 = 0xa1;
87 w_write(pdp, a, w);
88 b0 = b_read(pdp, a);
89 b1 = b_read(pdp, a + 1);
90 // тут полезно написать отладочную печать a, w, wres
91 DEBUG("\na=%06o\t b1=%02hhx\t b0=%02hhx\t w=%04x\n", a, b1, b0, w);
92 assert(b1 == res_b1);
93 assert(b0 == res_b0);
94}
Here is the call graph for this function:
Here is the caller graph for this function: