*** empty log message ***
[h316.git] / pc-tools / ldc2 / src / data_block.cpp
... / ...
CommitLineData
1#include <stdlib.h>
2#include <string.h>
3
4#include "data_block.hh"
5#include "data_block_0.hh"
6
7#include <stdio.h>
8
9using namespace std;
10
11/***************************************************************/
12/*!
13 *\brief Specialisation constructor.
14 */
15data_block::data_block(tape_block& org)
16 :tape_block(org)
17{
18 m_has_known_type=false;
19}
20
21/***************************************************************/
22/*!
23 *\brief Determine block type.
24 *\return the block type extracted from the block's data.
25 */
26int data_block::get_type(){
27 return (word_data[0]&0xf000)>>12;
28}
29
30/***************************************************************/
31/*!
32 *\brief Get the block's size in 16 bit words.
33 *\return The block's 16-bit data buffer's size including
34 * header and checksum.
35 */
36int data_block::get_word_size(){
37 return word_size;
38}
39
40/***************************************************************/
41/*!
42 *\brief Describe the block.
43 *\return A vector of text lines describing this block.
44 */
45vector<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
53/***************************************************************/
54/*!
55 *\brief Extract 6 byte symbol name from word memory.
56 *
57 *\param firstbyte the first byte of the desired symbol name
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 */
62string data_block::extract_label(int firstbyte){
63 string result=""; // Start with empty string
64
65 // We don't accept negative arguments!
66 if (firstbyte<0) return result;
67
68 // We also don't want segmentation faults!
69 if (word_size<(firstbyte/2+1)) return result;
70
71 // Here we pick out the characters.
72 for (int posi=firstbyte;posi<firstbyte+6;posi++)
73 result+=(word_data[posi/2]>>(8*(1-posi%2)))&0x7f;
74 return result;
75}
76
77
78
79