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