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