// File: sundale[P]gcode/rs274ngc/interp_convert.cc
// Function: Interp::convert_feed_mode(int, setup_struct*)
int Interp::convert_feed_mode(int g_code,        //!< g_code being executed (must be G_93, G_94 or G_95)
                             setup_pointer settings)    //!< pointer to machine settings                 
{
  if (g_code == G_93) {
#ifdef DEBUG_EMC
    enqueue_COMMENT("interpreter: feed mode set to inverse time");
#endif
    settings->feed_mode = INVERSE_TIME;
    enqueue_SET_FEED_MODE(0);
  } else if (g_code == G_94) {
#ifdef DEBUG_EMC
    enqueue_COMMENT("interpreter: feed mode set to units per minute");
#endif
    settings->feed_mode = UNITS_PER_MINUTE;
    enqueue_SET_FEED_MODE(0);
    settings->feed_rate = 0.0;
    enqueue_SET_FEED_RATE(0);
  } else if(g_code == G_95) {
#ifdef DEBUG_EMC
    enqueue_COMMENT("interpreter: feed mode set to units per revolution");
#endif
    settings->feed_mode = UNITS_PER_REVOLUTION;
    enqueue_SET_FEED_MODE(1);
    settings->feed_rate = 0.0;
    enqueue_SET_FEED_RATE(0);
  } else
    ERS("BUG: Code not G93, G94, or G95");
  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpl $0x3a2, -0x14(%rbp)     # imm = 0x3A2
jne 0x2168a
leaq 0x58c22(%rip), %rdi     # 0x7a28d
callq 0x11f00
movq -0x20(%rbp), %rax
movl $0x1, 0x670(%rax)
xorl %edi, %edi
callq 0x10db0
jmp 0x217e7
cmpl $0x3ac, -0x14(%rbp)     # imm = 0x3AC
jne 0x216d0
leaq 0x58c1e(%rip), %rdi     # 0x7a2b8
callq 0x11f00
movq -0x20(%rbp), %rax
movl $0x0, 0x670(%rax)
xorl %edi, %edi
callq 0x10db0
movq -0x20(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x678(%rax)
xorps %xmm0, %xmm0
callq 0x10ce0
jmp 0x217e5
cmpl $0x3b6, -0x14(%rbp)     # imm = 0x3B6
jne 0x21719
leaq 0x58c07(%rip), %rdi     # 0x7a2e7
callq 0x11f00
movq -0x20(%rbp), %rax
movl $0x2, 0x670(%rax)
movl $0x1, %edi
callq 0x10db0
movq -0x20(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x678(%rax)
xorps %xmm0, %xmm0
callq 0x10ce0
jmp 0x217e3
jmp 0x2171b
movq -0x28(%rbp), %rdi
leaq 0x58bf4(%rip), %rsi     # 0x7a31a
movb $0x0, %al
callq 0x10df0
movq 0x6582c(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x6581b(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x6580d(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x58bd1(%rip), %rsi     # 0x7a339
movl $0x50, %edx
callq 0x10840
movq 0x657e7(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x657d9(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x657c1(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x657b1(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x657a4(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x65796(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x217ee
jmp 0x217e5
jmp 0x217e7
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)