*** empty log message ***
[h316.git] / pc-tools / ldc2 / src / data_block.cpp
CommitLineData
4741aa72 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
97b26985 15#include <stdlib.h>
16#include <string.h>
17
18#include "data_block.hh"
19#include "data_block_0.hh"
20
6c06db96 21#include <stdio.h>
22
23using namespace std;
97b26985 24
874a2bd8 25/***************************************************************/
09cb0f4f 26/*!
27 *\brief Specialisation constructor.
28 */
29data_block::data_block(tape_block& org)
30 :tape_block(org)
874a2bd8 31{
32 m_has_known_type=false;
33}
97b26985 34
874a2bd8 35/***************************************************************/
09cb0f4f 36/*!
37 *\brief Determine block type.
38 *\return the block type extracted from the block's data.
39 */
97b26985 40int data_block::get_type(){
7880ae2d 41 return (word_data[0]&0xf000)>>12;
97b26985 42}
43
874a2bd8 44/***************************************************************/
6c06db96 45/*!
46 *\brief Get the block's size in 16 bit words.
09cb0f4f 47 *\return The block's 16-bit data buffer's size including
48 * header and checksum.
6c06db96 49 */
50int data_block::get_word_size(){
51 return word_size;
52}
53
874a2bd8 54/***************************************************************/
09cb0f4f 55/*!
56 *\brief Describe the block.
57 *\return A vector of text lines describing this block.
58 */
59vector<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
874a2bd8 67/***************************************************************/
6c06db96 68/*!
69 *\brief Extract 6 byte symbol name from word memory.
70 *
09cb0f4f 71 *\param firstbyte the first byte of the desired symbol name
6c06db96 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 */
09cb0f4f 76string data_block::extract_label(int firstbyte){
6c06db96 77 string result=""; // Start with empty string
78
79 // We don't accept negative arguments!
09cb0f4f 80 if (firstbyte<0) return result;
6c06db96 81
82 // We also don't want segmentation faults!
09cb0f4f 83 if (word_size<(firstbyte/2+1)) return result;
6c06db96 84
85 // Here we pick out the characters.
09cb0f4f 86 for (int posi=firstbyte;posi<firstbyte+6;posi++)
6c06db96 87 result+=(word_data[posi/2]>>(8*(1-posi%2)))&0x7f;
88 return result;
89}
09cb0f4f 90
874a2bd8 91
92
93
de6b6757 94