// File: /workspace/github_c_makefile_star2_O2/Edilbert[P]BS9/bs9.c
// Function: ParseStoreData
char *ParseStoreData(char *p)
{
   int Start,Length,FileFormat,Entry;
   char *Filename,*EndPtr;

   if (Pass) return p + strlen(p);
   p = EvalOperand(p,&Start,0);
   if (Start < 0 || Start > 0xfffff)
   {
      ErrorMsg("Illegal start address for STORE %d\n",Start);
      exit(1);
   }
   p = NeedChar(p,',');
   if (!p)
   {
      ErrorMsg("Missing ',' after start address\n");
      exit(1);
   }
   p = EvalOperand(p+1,&Length,0);
   if (Length < 0 || Length > 0x10000)
   {
      ErrorMsg("Illegal length for STORE %d\n",Length);
      exit(1);
   }
   p = NeedChar(p,',');
   if (!p)
   {
      ErrorMsg("Missing ',' after length\n");
      exit(1);
   }
   p = NeedChar(p+1,'"');
   if (!p)
   {
      ErrorMsg("Missing quote for filename\n");
      exit(1);
   }
   EndPtr = ++p;
   while (*EndPtr != '\0' && *EndPtr != '"') ++EndPtr;
   Filename = (char *)StrNDup(p, EndPtr - p);
   FileFormat = BINARY;
   Entry = -1;
   p = NeedChar(EndPtr+1,',');
   if (p)
   {
      ++p;
           if (StrMatch(p, "BIN"))  FileFormat = BINARY;
      else if (StrMatch(p, "SREC")) FileFormat = SRECORD;
      else if (StrMatch(p, "S19"))  FileFormat = SRECORD;
      else if (StrMatch(p, "SPARROW"))  FileFormat = SPARROW;
      else
      {
         ErrorMsg("Unknown output file format\n");
         exit(1);
      }
      if (df) fprintf(df,"Filefornat = %d\n",FileFormat);
      p = NeedChar(p,',');
      if (p)
      {
         p = EvalOperand(p+1,&Entry,0);
         if (Entry < 0 || Entry > 0xffff)
         {
            ErrorMsg("Illegal execution start address for STORE %d\n",Entry);
            exit(1);
         }
      } else p = EndPtr;
   } else p = EndPtr;

   SFA[StoreCount] = Start;
   SFL[StoreCount] = Length;
   SFE[StoreCount] = Entry;
   SFF[StoreCount] = Filename;
   SFT[StoreCount] = FileFormat;
   if (df)
   {
      fprintf(df,"Storing %4.4x - %4.4x <%s>,",
           Start,Start+Length-1,Filename);
           if (FileFormat == SPARROW) fprintf(df,"SPARROW\n");
      else if (FileFormat == SRECORD) fprintf(df,"SRECORD\n");
      else                            fprintf(df,"BINARY\n");
   }
   if (StoreCount < SFMAX) ++StoreCount;
   else
   {
      ErrorMsg("number of storage files exceeds %d\n",SFMAX);
      exit(1);
   }
   PrintLine();
   p += strlen(p);
   return p;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
cmpl $0x0, 0x1fdf7(%rip)     # 0x24a18
jne 0x4e60
leaq 0x14(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x37d5
movl (%r14), %r14d
cmpl $0x100000, %r14d        # imm = 0x100000
jae 0x4e7a
pushq $0x2c
popq %rsi
movq %rax, %rdi
callq 0x2f15
testq %rax, %rax
je 0x4e86
incq %rax
leaq 0x10(%rsp), %rbx
movq %rax, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x37d5
movl (%rbx), %r15d
cmpl $0x10001, %r15d         # imm = 0x10001
jae 0x4e8f
pushq $0x2c
popq %rsi
movq %rax, %rdi
callq 0x2f15
testq %rax, %rax
je 0x4e9b
incq %rax
pushq $0x22
popq %rsi
movq %rax, %rdi
callq 0x2f15
testq %rax, %rax
je 0x4ea4
incq %rax
xorl %esi, %esi
movq %rax, %rbx
movzbl (%rbx), %ecx
testl %ecx, %ecx
je 0x4cc8
cmpl $0x22, %ecx
je 0x4cc8
incq %rbx
incl %esi
jmp 0x4cb5
movq %rax, %rdi
callq 0x258f
movq %rax, (%rsp)
orl $-0x1, 0xc(%rsp)
leaq 0x1(%rbx), %rdi
pushq $0x2c
popq %rsi
callq 0x2f15
pushq $-0x1
popq %r13
testq %rax, %rax
je 0x4dab
movq %rax, %r12
incq %r12
leaq 0x6adc(%rip), %rsi      # 0xb7db
movq %r12, %rdi
callq 0x269d
xorl %ebp, %ebp
testq %rax, %rax
jne 0x4d54
pushq $0x1
popq %rbp
leaq 0x6ac7(%rip), %rsi      # 0xb7df
movq %r12, %rdi
callq 0x269d
testq %rax, %rax
jne 0x4d54
leaq 0x79c2(%rip), %rsi      # 0xc6ee
movq %r12, %rdi
callq 0x269d
testq %rax, %rax
jne 0x4d54
leaq 0x6aa4(%rip), %rsi      # 0xb7e4
movq %r12, %rdi
callq 0x269d
testq %rax, %rax
je 0x4ed9
pushq $0x2
popq %rbp
movq 0x1fcb5(%rip), %rdi     # 0x24a10
testq %rdi, %rdi
je 0x4d70
leaq 0x6aa1(%rip), %rsi      # 0xb808
movl %ebp, %edx
xorl %eax, %eax
callq 0x2210
pushq $0x2c
popq %rsi
movq %r12, %rdi
callq 0x2f15
testq %rax, %rax
je 0x4dad
incq %rax
leaq 0xc(%rsp), %r12
movq %rax, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x37d5
movl (%r12), %r13d
cmpl $0x10000, %r13d         # imm = 0x10000
jae 0x4ec0
movq %rax, %rbx
jmp 0x4dad
xorl %ebp, %ebp
movq (%rsp), %r8
movslq 0x1efb8(%rip), %rax     # 0x23d70
leaq 0x7f4c1(%rip), %rcx     # 0x84280
movl %r14d, (%rcx,%rax,4)
leaq 0x7f506(%rip), %rcx     # 0x842d0
movl %r15d, (%rcx,%rax,4)
leaq 0x7f54b(%rip), %rcx     # 0x84320
movl %r13d, (%rcx,%rax,4)
leaq 0x7f590(%rip), %rcx     # 0x84370
movq %r8, (%rcx,%rax,8)
leaq 0x7f625(%rip), %rcx     # 0x84410
movl %ebp, (%rcx,%rax,4)
movq 0x1fc1b(%rip), %rdi     # 0x24a10
testq %rdi, %rdi
je 0x4e48
leal (%r14,%r15), %ecx
decl %ecx
leaq 0x6a40(%rip), %rsi      # 0xb847
movl %r14d, %edx
xorl %eax, %eax
callq 0x2210
movq 0x1fbf8(%rip), %rcx     # 0x24a10
cmpl $0x1, %ebp
je 0x4e2b
cmpl $0x2, %ebp
jne 0x4e36
leaq 0x6a3a(%rip), %rdi      # 0xb863
jmp 0x4e32
leaq 0x6a3a(%rip), %rdi      # 0xb86c
pushq $0x8
jmp 0x4e3f
leaq 0x6a38(%rip), %rdi      # 0xb875
pushq $0x7
popq %rsi
pushq $0x1
popq %rdx
callq 0x2300
movl 0x1ef22(%rip), %eax     # 0x23d70
cmpl $0x13, %eax
jg 0x4eb4
incl %eax
movl %eax, 0x1ef15(%rip)     # 0x23d70
callq 0x2d99
movq %rbx, %rdi
callq 0x2110
addq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x68c2(%rip), %rdi      # 0xb743
movl %r14d, %esi
jmp 0x4eca
leaq 0x68da(%rip), %rdi      # 0xb767
jmp 0x4eab
leaq 0x68f2(%rip), %rdi      # 0xb788
movl %r15d, %esi
jmp 0x4eca
leaq 0x6903(%rip), %rdi      # 0xb7a5
jmp 0x4eab
leaq 0x6914(%rip), %rdi      # 0xb7bf
xorl %eax, %eax
callq 0x2af7
jmp 0x4ed1
leaq 0x69c2(%rip), %rdi      # 0xb87d
pushq $0x14
popq %rsi
jmp 0x4eca
leaq 0x6952(%rip), %rdi      # 0xb819
movl %r13d, %esi
xorl %eax, %eax
callq 0x2af7
pushq $0x1
popq %rdi
callq 0x22f0
leaq 0x690c(%rip), %rdi      # 0xb7ec
jmp 0x4eab