97b26985 |
1 | #include <stdlib.h> |
2 | #include <string.h> |
3 | |
4 | #include "data_block.hh" |
5 | #include "data_block_0.hh" |
6 | |
6c06db96 |
7 | #include <stdio.h> |
8 | |
9 | using namespace std; |
97b26985 |
10 | |
874a2bd8 |
11 | /***************************************************************/ |
09cb0f4f |
12 | /*! |
13 | *\brief Specialisation constructor. |
14 | */ |
15 | data_block::data_block(tape_block& org) |
16 | :tape_block(org) |
874a2bd8 |
17 | { |
18 | m_has_known_type=false; |
19 | } |
97b26985 |
20 | |
874a2bd8 |
21 | /***************************************************************/ |
09cb0f4f |
22 | /*! |
23 | *\brief Determine block type. |
24 | *\return the block type extracted from the block's data. |
25 | */ |
97b26985 |
26 | int data_block::get_type(){ |
7880ae2d |
27 | return (word_data[0]&0xf000)>>12; |
97b26985 |
28 | } |
29 | |
874a2bd8 |
30 | /***************************************************************/ |
6c06db96 |
31 | /*! |
32 | *\brief Get the block's size in 16 bit words. |
09cb0f4f |
33 | *\return The block's 16-bit data buffer's size including |
34 | * header and checksum. |
6c06db96 |
35 | */ |
36 | int data_block::get_word_size(){ |
37 | return word_size; |
38 | } |
39 | |
874a2bd8 |
40 | /***************************************************************/ |
09cb0f4f |
41 | /*! |
42 | *\brief Describe the block. |
43 | *\return A vector of text lines describing this block. |
44 | */ |
45 | vector<string> data_block::get_description(){ |
46 | vector<string> result; |
47 | string r_string="***** "+get_typestring()+"Untyped data block, this \ |
48 | is an illegal condition!"; |
49 | result.insert(result.end(),r_string); |
50 | return result; |
51 | } |
52 | |
874a2bd8 |
53 | /***************************************************************/ |
6c06db96 |
54 | /*! |
55 | *\brief Extract 6 byte symbol name from word memory. |
56 | * |
09cb0f4f |
57 | *\param firstbyte the first byte of the desired symbol name |
6c06db96 |
58 | *\return a string containing the symbol name. |
59 | * Trailing spaces are included. |
60 | *\note The word_data is handled system-intependently big endian! |
61 | */ |
09cb0f4f |
62 | string data_block::extract_label(int firstbyte){ |
6c06db96 |
63 | string result=""; // Start with empty string |
64 | |
65 | // We don't accept negative arguments! |
09cb0f4f |
66 | if (firstbyte<0) return result; |
6c06db96 |
67 | |
68 | // We also don't want segmentation faults! |
09cb0f4f |
69 | if (word_size<(firstbyte/2+1)) return result; |
6c06db96 |
70 | |
71 | // Here we pick out the characters. |
09cb0f4f |
72 | for (int posi=firstbyte;posi<firstbyte+6;posi++) |
6c06db96 |
73 | result+=(word_data[posi/2]>>(8*(1-posi%2)))&0x7f; |
74 | return result; |
75 | } |
09cb0f4f |
76 | |
874a2bd8 |
77 | |
78 | |
79 | |