// File: sundale[P]gcode/rs274ngc/interp_read.cc
// Function: Interp::read_name(char*, int*, char*)
int Interp::read_name(
    char *line,   //!< string: line of RS274/NGC code being processed
    int *counter, //!< pointer to a counter for position on the line 
    char *nameBuf)   //!< pointer to name to be read
{

  int done = 0;
  int i;

  CHKS(((line[*counter] != '<') && !isalpha(line[*(counter)])),
      NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED);

  // skip over the '<'
  *counter = (*counter + 1);

  for(i=0; (i<LINELEN) && (line[*counter]); i++)
  {
      if(line[*counter] == '>')
      {
          nameBuf[i] = 0; // terminate the name
          *counter = (*counter + 1);
          done = 1;
          break;
      }
      nameBuf[i] = line[*counter];
      *counter = (*counter + 1);
  }

  // !!!KL need to rename the error message and change text
  CHKS((!done), NCE_NAMED_PARAMETER_NOT_TERMINATED);

  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3c, %eax
je 0x64c01
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movsbl (%rax,%rcx), %edi
callq 0x11c30
cmpl $0x0, %eax
jne 0x64c01
jmp 0x64b2e
leaq 0x178b0(%rip), %rdi     # 0x7c3e5
callq 0x10380
movq -0x38(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x22411(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x22400(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x223f2(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x1950d(%rip), %rsi     # 0x7e090
movl $0x50, %edx
callq 0x10840
movq 0x223cc(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x223be(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x223a6(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x22396(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x22389(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2237b(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x64d9a
jmp 0x64c03
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x30(%rbp)
xorl %eax, %eax
cmpl $0xff, -0x30(%rbp)
movb %al, -0x39(%rbp)
jge 0x64c3c
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
cmpb $0x0, (%rax,%rcx)
setne %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0x64c45
jmp 0x64cb3
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3e, %eax
jne 0x64c7d
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x2c(%rbp)
jmp 0x64cb3
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movb (%rax,%rcx), %dl
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x64c19
jmp 0x64cb5
cmpl $0x0, -0x2c(%rbp)
jne 0x64d91
jmp 0x64cc1
leaq 0x14e40(%rip), %rdi     # 0x79b08
callq 0x10380
movq -0x38(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x2227e(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x2226d(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x2225f(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x1937a(%rip), %rsi     # 0x7e090
movl $0x50, %edx
callq 0x10840
movq 0x22239(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2222b(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x22213(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x22203(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x221f6(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x221e8(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x64d9a
jmp 0x64d93
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)