*** empty log message ***
[h316.git] / pc-tools / ldc2 / src / data_block.cpp
index 15702b56661acf21752c8287ddbda36175496ab8..f0c91538c0480daabbb430b16aa3fea01dc4b58e 100644 (file)
@@ -4,6 +4,9 @@
 #include "data_block.hh"
 #include "data_block_0.hh"
 
+#include <stdio.h>
+
+using namespace std;
 
 data_block::data_block(tape_block& idol)
   :tape_block(idol)
@@ -25,3 +28,34 @@ int data_block::get_subtype(){
     return (new data_block_0(*this))->get_subtype();
   else return 0;
 }
+
+/*!
+ *\brief Get the block's size in 16 bit words.
+ *\return The block's 16-bit data buffer's size including header and checksum.
+ */
+int data_block::get_word_size(){
+  return word_size;
+}
+
+/*!
+ *\brief Extract 6 byte symbol name from word memory.
+ *
+ *\param  startbyte the first byte of the desired symbol name
+ *\return a string containing the symbol name. 
+ *        Trailing spaces are included.
+ *\note The word_data is handled system-intependently big endian!
+ */
+string data_block::extract_string(int startbyte){
+  string result="";  // Start with empty string
+  
+  // We don't accept negative arguments!
+  if (startbyte<0) return result; 
+  
+  // We also don't want segmentation faults!
+  if (word_size<(startbyte/2+1)) return result; 
+  // Here we pick out the characters.
+  for (int posi=startbyte;posi<startbyte+6;posi++)
+    result+=(word_data[posi/2]>>(8*(1-posi%2)))&0x7f;
+  return result;
+}