// File: /workspace/github_c_makefile_star2_O2/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, %rbx
leaq 0x8(%rdi), %rsi
leaq 0x36a2(%rip), %rdi      # 0x11b7a
movl %r14d, %edx
xorl %eax, %eax
callq 0x3160
pushq $0x1
popq %rbp
movzbl %r14b, %eax
movl %eax, 0x8(%rsp)
movq %rbx, (%rsp)
movq (%rsp), %rdi
movl 0x8(%rsp), %esi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0xc5d7
movq (%rsp), %rcx
testl %eax, %eax
je 0xe67e
movzwl 0x64(%rcx), %ebx
movl %ebx, %eax
movl $0xfff, %edx            # imm = 0xFFF
andl %edx, %eax
movl %ebx, %r15d
andl $0x800, %r15d           # imm = 0x800
addl %r15d, %r15d
subl %eax, %r15d
movzwl 0x5c(%rcx), %eax
xorl %r14d, %r14d
subw %ax, %r14w
andl %edx, %r14d
negl %ebx
andl %edx, %ebx
movzwl 0x5e(%rcx), %r12d
andl %edx, %r12d
leaq 0x3637(%rip), %rdi      # 0x11b83
movl %ebp, %esi
xorl %eax, %eax
callq 0x3160
leaq 0x369c(%rip), %rdi      # 0x11bf8
callq 0x30e0
movl %ebx, 0x10(%rsp)
movl %ebx, %eax
movl %r12d, %ebx
addl $0x4, %eax
movq %rax, 0x18(%rsp)
addl $0x5, %r15d
movl %r15d, 0xc(%rsp)
movw $0x5, %r13w
subw $0x1, %r14w
jb 0xe66a
movzwl %r13w, %r12d
movq (%rsp), %rdi
movzwl 0x5c(%rdi,%r12,2), %ecx
movl %r12d, %eax
movzwl %bx, %r15d
testw $0xfff, %cx             # imm = 0xFFF
je 0xe62b
movl %ebx, 0x14(%rsp)
xorl %ebp, %ebp
movl $0x0, %ebx
cmpw $0x0, 0x10(%rsp)
je 0xe5c9
movzwl 0x64(%rdi,%rax,2), %ebx
andl $0xfff, %ebx            # imm = 0xFFF
movq 0x18(%rsp), %rax
addl %r12d, %eax
subw 0x5c(%rdi,%rax,2), %bp
andl $0xfff, %ebp            # imm = 0xFFF
movl %r12d, %esi
leaq 0x20(%rsp), %rdx
callq 0xe68d
addl 0xc(%rsp), %r12d
movzwl %bp, %r13d
movzwl %bx, %edi
leaq 0x30(%rsp), %rbx
movq %rbx, %rsi
callq 0xe725
leal (%r15,%r13), %r9d
decl %r9d
leaq 0x358c(%rip), %rdi      # 0x11b9c
leaq 0x20(%rsp), %rsi
movl %r13d, %edx
movq %rbx, %rcx
movl %r15d, %r8d
xorl %eax, %eax
callq 0x3160
movl 0x14(%rsp), %ebx
jmp 0xe65b
movzwl 0x5e(%rdi,%rax,2), %eax
xorl %ebp, %ebp
subw %ax, %bp
andl $0xfff, %ebp            # imm = 0xFFF
leal (%r15,%rbp), %ecx
decl %ecx
leaq 0x3571(%rip), %rdi      # 0x11bb9
movl %ebp, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x3160
addl $0x2, %r13d
movl %r13d, %r12d
movzwl %bp, %eax
addl %ebx, %eax
movl %eax, %ebx
movl %r12d, %r13d
jmp 0xe580
movq (%rsp), %rbx
movzwl 0x60(%rbx), %ebp
andl $0xfff, %ebp            # imm = 0xFFF
jne 0xe4f1
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq