// File: sundale[P]gcode/rs274ngc/interp_read.cc
// Function: Interp::store_named_param(char*, double)
int Interp::store_named_param(
    char *nameBuf, //!< pointer to name to be written
    double value   //!< value to be written
    )   
{
  struct named_parameters_struct *nameList;

  int level;
  int i;

  // now look it up
  if(nameBuf[0] != '_') // local scope
  {
      level = _setup.call_level;
  }
  else
  {
      // call level zero is global scope
      level = 0;
  }

  nameList = &_setup.sub_context[level].named_parameters;

  logDebug("store_named_parameter: nameList[%d]=0x%x storing:|%s|", level,
           nameList, nameBuf);
  logDebug("store_named_parameter: named_parameter_used_size=%d",
           nameList->named_parameter_used_size);


  for(i=0; i<nameList->named_parameter_used_size; i++)
  {
#if 0
      logDebug("store_named_parameter: named_parameter[%d]=|%s|",
               i, nameList->named_parameters[i]);
#endif
      if(0 == strcmp(nameList->named_parameters[i], nameBuf))
      {
          nameList->named_param_values[i] = value;
          logDebug("store_named_parameter: level[%d] %s value=%lf",
                   level, nameBuf, value);

          return INTERP_OK;
      }
  }

  logDebug("%s: param:|%s| returning not defined", "store_named_param",
           nameBuf);

  ERS(_("Internal error: Could not assign #<%s>"), nameBuf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5f, %eax
je 0x6521b
movq 0x21d50(%rip), %rax     # 0x86f60
movl 0xef90(%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x65222
movl $0x0, -0x2c(%rbp)
movslq -0x2c(%rbp), %rcx
movq 0x21d33(%rip), %rax     # 0x86f60
addq $0xef98, %rax           # imm = 0xEF98
imulq $0x128, %rcx, %rcx      # imm = 0x128
addq %rcx, %rax
addq $0x110, %rax            # imm = 0x110
movq %rax, -0x28(%rbp)
xorl %eax, %eax
movq 0x21d10(%rip), %rcx     # 0x86f60
cmpl 0x1b6b4(%rcx), %eax
jge 0x6529a
callq 0x11950
movq -0x38(%rbp), %rdi
movl %eax, %ecx
movl -0x2c(%rbp), %r11d
movq -0x28(%rbp), %r10
movq -0x18(%rbp), %rax
leaq 0x18e47(%rip), %rsi     # 0x7e0bd
xorl %edx, %edx
leaq 0x18b4a(%rip), %r8      # 0x7ddc9
movl $0x730, %r9d            # imm = 0x730
movl %r11d, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0x12050
jmp 0x6529c
jmp 0x6529e
xorl %eax, %eax
movq 0x21cb9(%rip), %rcx     # 0x86f60
cmpl 0x1b6b4(%rcx), %eax
jge 0x652e1
callq 0x11950
movq -0x38(%rbp), %rdi
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
leaq 0x18e3e(%rip), %rsi     # 0x7e106
xorl %edx, %edx
leaq 0x18af8(%rip), %r8      # 0x7ddc9
movl $0x732, %r9d            # imm = 0x732
movl %eax, (%rsp)
movb $0x0, %al
callq 0x12050
jmp 0x652e3
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x6539e
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rsi
callq 0x11820
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x6538e
movsd -0x20(%rbp), %xmm0
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x30(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
xorl %eax, %eax
movq 0x21c26(%rip), %rcx     # 0x86f60
cmpl 0x1b6b4(%rcx), %eax
jge 0x65380
callq 0x11950
movq -0x38(%rbp), %rdi
movl %eax, %ecx
movl -0x2c(%rbp), %r10d
movq -0x18(%rbp), %rax
movsd -0x20(%rbp), %xmm0
leaq 0x18dec(%rip), %rsi     # 0x7e14d
xorl %edx, %edx
leaq 0x18a5f(%rip), %r8      # 0x7ddc9
movl $0x73f, %r9d            # imm = 0x73F
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x1, %al
callq 0x12050
jmp 0x65382
movl $0x0, -0x4(%rbp)
jmp 0x654c3
jmp 0x65390
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x652ea
jmp 0x653a0
xorl %eax, %eax
movq 0x21bb7(%rip), %rcx     # 0x86f60
cmpl 0x1b6b4(%rcx), %eax
jge 0x653ed
callq 0x11950
movq -0x38(%rbp), %rdi
movl %eax, %ecx
movq -0x18(%rbp), %rax
leaq 0x18dc7(%rip), %rsi     # 0x7e18e
xorl %edx, %edx
leaq 0x189f9(%rip), %r8      # 0x7ddc9
movl $0x746, %r9d            # imm = 0x746
leaq 0x18de9(%rip), %r10     # 0x7e1c6
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x12050
jmp 0x653ef
jmp 0x653f1
leaq 0x18de0(%rip), %rdi     # 0x7e1d8
callq 0x10380
movq -0x38(%rbp), %rdi
movq %rax, %rsi
movq -0x18(%rbp), %rdx
movb $0x0, %al
callq 0x10df0
movq 0x21b4a(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x21b39(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x21b2b(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x18db5(%rip), %rsi     # 0x7e1ff
movl $0x50, %edx
callq 0x10840
movq 0x21b05(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x21af7(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x21adf(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x21acf(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x21ac2(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x21ab4(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)