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