// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/rt11.c
// Function: info
static void info(
  struct mountedFS *mount,
  uint8_t unit
)
{
  struct RT11data *data = &mount->rt11data;
  uint16_t entrysz, startblk, dsseg = 1;
  char temp[32];

  printf("%s%o:\n\n", mount->name, unit);

  do {
    uint16_t off = RT11_DH_SIZE;

    if (rt11ReadDirSegment(mount, unit, dsseg) == 0)
      return;

    printf("\nDirectory Segment %2d:\n\n", dsseg);
    printf(" File  Type     Date     Status   Class   Length    Disk Region\n\n");

    entrysz = RT11_DI_SIZE + (le16toh(data->buf[RT11_DH_EXTRA]) >> 1);
    startblk = le16toh(data->buf[RT11_DH_START]);

    /*
     * Loop until we see and end-of-segment marker or there is no room for
     * another directory entry.
     */
    while (!RT11EOS(le16toh(data->buf[off + RT11_DI_STATUS])) &&
           ((RT11_DS_SIZE - off) >= entrysz)) {
      uint16_t status = le16toh(data->buf[off + RT11_DI_STATUS]);

      /*
       * Tentative and empty files are reported as "UNUSED"
       */
      if ((status & (RT11_E_TENT | RT11_E_MPTY)) == 0) {
        r50Asc(le16toh(data->buf[off + RT11_DI_FNAME1]), &temp[0]);
        r50Asc(le16toh(data->buf[off + RT11_DI_FNAME2]), &temp[3]);
        temp[6] = '.';
        r50Asc(le16toh(data->buf[off + RT11_DI_FTYPE]), &temp[7]);
        temp[10] = ' ';
        temp[11] = ' ';
        rt11Date(le16toh(data->buf[off + RT11_DI_CREATE]), &temp[12]);

        printf("%s  %07o  %s     %5d     %5d-%5d\n",
               temp, status,
               (status & RT11_E_PRE) != 0 ? "PRE" : "   ",
               le16toh(data->buf[off + RT11_DI_LENGTH]),
               startblk,
               startblk + le16toh(data->buf[off + RT11_DI_LENGTH]) - 1);
      } else {
        printf("< UNUSED >                                %5d     %5d-%5d\n",
               le16toh(data->buf[off + RT11_DI_LENGTH]),
               startblk,
               le16toh(data->buf[off + RT11_DI_LENGTH]) == 0 ? startblk :
                 startblk + le16toh(data->buf[off + RT11_DI_LENGTH]) - 1);
      }
      startblk += le16toh(data->buf[off + RT11_DI_LENGTH]);

      off += entrysz;
    }

    dsseg = le16toh(data->buf[RT11_DH_NEXT]);
  } while (dsseg != 0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x8(%rdi), %rsi
leaq 0x7292(%rip), %rdi      # 0x11b7b
movl %ebp, %edx
xorl %eax, %eax
callq 0x3160
movw $0x1, %ax
movzbl %bpl, %ecx
movl %ecx, 0x14(%rsp)
movzwl %ax, %r15d
movq %rbx, %rdi
movl 0x14(%rsp), %esi
movl %r15d, %edx
callq 0x89c6
testl %eax, %eax
je 0xaa79
leaq 0x6a39(%rip), %rdi      # 0x11359
movl %r15d, %esi
xorl %eax, %eax
callq 0x3160
leaq 0x6aba(%rip), %rdi      # 0x113eb
callq 0x30e0
movzwl 0x478(%rbx), %eax
shrl %eax
movzwl 0x47a(%rbx), %r14d
movl $0x1f9, %ecx            # imm = 0x1F9
subl %eax, %ecx
movl %ecx, 0x1c(%rsp)
addl $0x7, %eax
movl %eax, 0x18(%rsp)
pushq $0x5
popq %rax
movl %eax, %r13d
movzwl %r13w, %r13d
movzwl 0x472(%rbx,%r13,2), %r12d
btl $0xb, %r12d
jb 0xaa69
cmpl 0x1c(%rsp), %r13d
jg 0xaa69
movzwl %r14w, %r15d
testw $0x300, %r12w           # imm = 0x300
je 0xa9bb
leal 0x4(%r13), %ebp
movzwl 0x472(%rbx,%rbp,2), %esi
testl %esi, %esi
leal -0x1(%r15,%rsi), %ecx
cmovel %r15d, %ecx
leaq 0x69ed(%rip), %rdi      # 0x11399
movl %r15d, %edx
xorl %eax, %eax
callq 0x3160
jmp 0xaa56
movl %r13d, %ebp
movzwl 0x474(%rbx,%rbp,2), %edi
leaq 0x20(%rsp), %rsi
callq 0x5068
movzwl 0x476(%rbx,%rbp,2), %edi
leaq 0x23(%rsp), %rsi
callq 0x5068
movb $0x2e, 0x26(%rsp)
movzwl 0x478(%rbx,%rbp,2), %edi
leaq 0x27(%rsp), %rsi
callq 0x5068
movw $0x2020, 0x2a(%rsp)     # imm = 0x2020
movzwl 0x47e(%rbx,%rbp,2), %edi
leaq 0x2c(%rsp), %rsi
callq 0x8aff
testb $0x10, %r12b
leaq 0x6978(%rip), %rcx      # 0x11395
leaq 0x6931(%rip), %rax      # 0x11355
cmoveq %rax, %rcx
leal 0x4(%r13), %ebp
movzwl 0x472(%rbx,%rbp,2), %r8d
leal -0x1(%r15,%r8), %eax
movl %eax, (%rsp)
leaq 0x692f(%rip), %rdi      # 0x11373
leaq 0x20(%rsp), %rsi
movl %r12d, %edx
movl %r15d, %r9d
xorl %eax, %eax
callq 0x3160
addw 0x472(%rbx,%rbp,2), %r14w
addl 0x18(%rsp), %r13d
jmp 0xa95f
movzwl 0x474(%rbx), %eax
testw %ax, %ax
jne 0xa8fe
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq