0

I am new to PASCAL and I am working on a PASCAL code. I would really appreciate if somebody helped me understand this piece of code.

readagain1:     
        Write(' ', (BYWORD(fileio_dcb.usr_buf^[WRD((2*j)+1)], fileio_dcb.usr_buf^[WRD((2*j)+0)])):4:16);     
        Write(' ', (BYWORD(fileio_dcb.usr_buf^[WRD((2*j)+3)], fileio_dcb.usr_buf^[WRD((2*j)+2)])):4:16);     
        Write(' ', (BYWORD(fileio_dcb.usr_buf^[WRD((2*j)+5)], fileio_dcb.usr_buf^[WRD((2*j)+4)])):4:16);     
        Write(' ', (BYWORD(fileio_dcb.usr_buf^[WRD((2*j)+7)], fileio_dcb.usr_buf^[WRD((2*j)+6)])):4:16);     
        Write(' ', (BYWORD(fileio_dcb.usr_buf^[WRD((2*j)+9)], fileio_dcb.usr_buf^[WRD((2*j)+8)])):4:16);     
        Write(' ', (BYWORD(fileio_dcb.usr_buf^[WRD((2*j)+11)], fileio_dcb.usr_buf^[WRD((2*j)+10)])):4:16);     
        Write(' ', (BYWORD(fileio_dcb.usr_buf^[WRD((2*j)+13)], fileio_dcb.usr_buf^[WRD((2*j)+12)])):4:16);     
        WriteLn(' ', (BYWORD(fileio_dcb.usr_buf^[WRD((2*j)+15)], fileio_dcb.usr_buf^[WRD((2*j)+14)])):4:16);     
        j := j+8;     
        IF (j < 100) THEN GOTO readagain1;
        j := 0;     
        int_dcb.txt_buf.r := 0;     
        WriteLn;
        WriteLn('Reading txt_buf ; ');

readagain1 is a label that has already been declared.

Hexdecimal numbers are being read from a file into a buffer(fileio_dcb.usr_buf) ans some operation is being performed on the hex number read. I would appreciate any help with understanding the operation being performed on the number.

1 Answers1

0

My guess is that each iteration it writes out 13 (=100/8 rounded up) lines with 8 (16-bit) word sized hex numbers per line. Each line has a leading space.

It is probably an atypical (non Borland) dialect that can write hexvalues using :4:16 (I assume this means base 16, 4 digits wide). Most typical dialects (and the standard?) only use :x:y for floating point.

BYWORD() and WRD() are not standard identifiers, my guess this is some embedded dialect that combines two bytes into a word. Maybe it can only read words from aligned addresses, and are these builtins/macros workarounds for that.

Note that this is all based on "most likely it does that". The fragment is not complete enough, and the dialect not standard.

Marco van de Voort
  • 25,628
  • 5
  • 56
  • 89