// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/os8.c
// Function: info
static void info(
  struct mountedFS *mount,
  uint8_t unit
)
{
  struct OS8data *data = &mount->os8data;
  unsigned int dirblk = OS8_DSSTART;

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

  do {
    uint16_t i, entrysz, entries, extra, startblk, off = OS8_DH_SIZE;

    if (os8ReadBlock(mount, unit, dirblk, NULL) == 0)
      return;

    entrysz = OS8_DI_SIZE + (-os8SXT(le16toh(data->buf[OS8_DH_EXTRA])));
    entries = os8Neg(le16toh(data->buf[OS8_DH_ENTRIES]));
    extra = os8Neg(le16toh(data->buf[OS8_DH_EXTRA]));

    startblk = os8Word(le16toh(data->buf[OS8_DH_START]));

    printf("\nDirectory Segment %d:\n\n", dirblk);
    printf(" File  Type  Length    Date       Disk Region\n\n");

    for (i = 0; i < entries; i++) {
      char temp1[16], temp2[16];
      uint16_t length;

      if (os8Word(le16toh(data->buf[off + OS8_DI_FNAME1])) != 0) {
        uint16_t dateval = 0;

        length = os8Neg(le16toh(data->buf[off + extra + OS8_DI_LENGTH]));
        if (extra != 0)
          dateval = os8Word(le16toh(data->buf[off + OS8_DI_DATE]));

        printf("%s    %4hu  %s    %4d - %4d\n",
               os8FileName(mount, off, temp1), length,
               os8Date(dateval, temp2), startblk, startblk + length - 1);

        off += entrysz;
      } else {
        length = os8Neg(le16toh(data->buf[off + OS8_ED_LENGTH]));

        printf("<EMPTY>      %4hu                 %4d - %4d\n",
               os8Neg(le16toh(data->buf[off + OS8_ED_LENGTH])),
               startblk, startblk + length - 1);

        off += OS8_ED_SIZE;
      }
      startblk += length;
    }

    dirblk = os8Word(le16toh(data->buf[OS8_DH_NEXT]));
  } while (dirblk != 0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %esi, %r14d
movq %rdi, %r13
leaq 0x8(%rdi), %rsi
leaq 0x32ec(%rip), %rdi      # 0x12b7a
movl %r14d, %edx
xorl %eax, %eax
callq 0x3160
movl $0x1, %ebp
movzbl %r14b, %eax
movl %eax, 0xc(%rsp)
movq %r13, %rdi
movl 0xc(%rsp), %esi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0xd979
testl %eax, %eax
je 0xfa32
movl %eax, 0x10(%rsp)
movzwl 0x5e(%r13), %ebx
movzwl 0x64(%r13), %r15d
movzwl 0x5c(%r13), %eax
xorl %r14d, %r14d
subw %ax, %r14w
leaq 0x32a5(%rip), %rdi      # 0x12b83
movl %ebp, %esi
xorl %eax, %eax
callq 0x3160
leaq 0x330a(%rip), %rdi      # 0x12bf8
callq 0x30e0
andw $0xfff, %r14w           # imm = 0xFFF
je 0xfa23
movl $0xfff, %eax            # imm = 0xFFF
andl %eax, %ebx
movl %r15d, %ecx
negl %ecx
andl %eax, %ecx
movl %r15d, %edx
andl $0x800, %edx            # imm = 0x800
addl %edx, %edx
andl %eax, %r15d
subl %r15d, %edx
movl %ecx, 0x18(%rsp)
movl %ecx, %eax
addl $0x4, %eax
movq %rax, 0x20(%rsp)
addl $0x5, %edx
movl %edx, 0x14(%rsp)
movw $0x5, %r12w
movzwl %r12w, %r12d
movzwl 0x5c(%r13,%r12,2), %eax
movzwl %bx, %edx
testl $0xfff, %eax            # imm = 0xFFF
je 0xf9e5
movq %rdx, 0x28(%rsp)
movl %ebx, 0x1c(%rsp)
xorl %ebp, %ebp
movl $0x0, %ebx
cmpw $0x0, 0x18(%rsp)
je 0xf977
movl %r12d, %eax
movzwl 0x64(%r13,%rax,2), %ebx
andl $0xfff, %ebx            # imm = 0xFFF
movq 0x20(%rsp), %rax
addl %r12d, %eax
subw 0x5c(%r13,%rax,2), %bp
andl $0xfff, %ebp            # imm = 0xFFF
movq %r13, %rdi
movl %r12d, %esi
leaq 0x30(%rsp), %rdx
callq 0xfa4d
movq %r13, %r15
movzwl %bp, %r13d
movzwl %bx, %edi
leaq 0x40(%rsp), %rbx
movq %rbx, %rsi
callq 0xfae5
movq 0x28(%rsp), %r8
leal (%r8,%r13), %r9d
decl %r9d
leaq 0x31d7(%rip), %rdi      # 0x12b9c
leaq 0x30(%rsp), %rsi
movl %r13d, %edx
movq %r15, %r13
movq %rbx, %rcx
xorl %eax, %eax
callq 0x3160
addl 0x14(%rsp), %r12d
movl 0x1c(%rsp), %ebx
jmp 0xfa12
movl %r12d, %eax
movzwl 0x5e(%r13,%rax,2), %eax
xorl %ebp, %ebp
subw %ax, %bp
andl $0xfff, %ebp            # imm = 0xFFF
leal (%rdx,%rbp), %ecx
decl %ecx
leaq 0x31b4(%rip), %rdi      # 0x12bb9
movl %ebp, %esi
xorl %eax, %eax
callq 0x3160
addl $0x2, %r12d
movzwl %bp, %eax
addl %ebx, %eax
movl %eax, %ebx
decw %r14w
jne 0xf938
movzwl 0x60(%r13), %ebp
andl $0xfff, %ebp            # imm = 0xFFF
movl 0x10(%rsp), %eax
testl %eax, %eax
je 0xfa3e
testl %ebp, %ebp
jne 0xf8a5
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq