// File: /workspace/github_c_makefile_star2_O3/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 $0x48, %rsp
movl %esi, %r14d
movq %rdi, %r13
leaq 0x8(%rdi), %rsi
leaq 0x3634(%rip), %rdi      # 0x12b9a
movl %r14d, %edx
xorl %eax, %eax
callq 0x3160
movl $0x1, %ebp
movzbl %r14b, %eax
movl %eax, (%rsp)
movq %r13, %rdi
movl (%rsp), %esi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0xd707
testl %eax, %eax
je 0xf706
movzwl 0x5e(%r13), %ebx
movzwl 0x64(%r13), %r15d
movzwl 0x5c(%r13), %eax
xorl %r14d, %r14d
subw %ax, %r14w
leaq 0x35f3(%rip), %rdi      # 0x12ba3
movl %ebp, %esi
xorl %eax, %eax
callq 0x3160
leaq 0x3658(%rip), %rdi      # 0x12c18
callq 0x30e0
andw $0xfff, %r14w           # imm = 0xFFF
je 0xf6f5
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, 0x8(%rsp)
movl %ecx, %eax
addl $0x4, %eax
movq %rax, 0x10(%rsp)
addl $0x5, %edx
movl %edx, 0x4(%rsp)
movw $0x5, %bp
movzwl %bp, %ebp
movzwl 0x5c(%r13,%rbp,2), %eax
movzwl %bx, %edx
testl $0xfff, %eax            # imm = 0xFFF
je 0xf6b3
movq %rdx, 0x18(%rsp)
movl %ebx, 0xc(%rsp)
xorl %r12d, %r12d
movl $0x0, %ebx
cmpw $0x0, 0x8(%rsp)
je 0xf647
movl %ebp, %eax
movzwl 0x64(%r13,%rax,2), %ebx
andl $0xfff, %ebx            # imm = 0xFFF
movq 0x10(%rsp), %rax
addl %ebp, %eax
subw 0x5c(%r13,%rax,2), %r12w
andl $0xfff, %r12d           # imm = 0xFFF
movq %r13, %rdi
movl %ebp, %esi
leaq 0x20(%rsp), %rdx
callq 0xf715
movq %r13, %r15
movzwl %r12w, %r13d
movzwl %bx, %edi
leaq 0x30(%rsp), %rbx
movq %rbx, %rsi
callq 0xf7ad
movq 0x18(%rsp), %r8
leal (%r8,%r13), %r9d
decl %r9d
leaq 0x3528(%rip), %rdi      # 0x12bbc
leaq 0x20(%rsp), %rsi
movl %r13d, %edx
movq %r15, %r13
movq %rbx, %rcx
xorl %eax, %eax
callq 0x3160
addl 0x4(%rsp), %ebp
movl 0xc(%rsp), %ebx
jmp 0xf6e3
movl %ebp, %eax
movzwl 0x5e(%r13,%rax,2), %eax
xorl %r12d, %r12d
subw %ax, %r12w
andl $0xfff, %r12d           # imm = 0xFFF
leal (%rdx,%r12), %ecx
decl %ecx
leaq 0x3503(%rip), %rdi      # 0x12bd9
movl %r12d, %esi
xorl %eax, %eax
callq 0x3160
addl $0x2, %ebp
movzwl %r12w, %eax
addl %ebx, %eax
movl %eax, %ebx
decw %r14w
jne 0xf609
movzwl 0x60(%r13), %ebp
andl $0xfff, %ebp            # imm = 0xFFF
jne 0xf57c
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq