Вопрос по c, x86, assembly – Сборка X86 - Обработка инструкции IDIV

22

Error: User Rate Limit Exceeded

int mymain(int x){
  int d;
  int e;
  d = 3;
  e = 6 / d;
  return e;
}

Error: User Rate Limit Exceeded

mymain:
.LFB1:
    .cfi_startproc
    pushq   %rbp
    .cfi_def_cfa_offset 16
    movq    %rsp, %rbp
    .cfi_offset 6, -16
    .cfi_def_cfa_register 6
    movq    %rdi, -40(%rbp)
    movq    $3, -8(%rbp)
    movq    $6, %rax
    movq    -8(%rbp), %rdx
    movq    %rdx, %rbx
    idivq   %rbx
    movq    %rax, -16(%rbp)
    movq    -16(%rbp), %rax
    leave
    .cfi_def_cfa 7, 8
    ret
    .cfi_endproc
.LFE1:
    .size mymain, .-mymain

Error: User Rate Limit ExceededError: User Rate Limit Exceeded, idivq %rbxError: User Rate Limit Exceeded%raxError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceededmovq %rdi, -40(%rbp)Error: User Rate Limit ExceededespError: User Rate Limit Exceeded Michael Burr

Ваш Ответ

2   ответа
23

idivrdx

signedsignraxrdx:raxcqto (convert quad to octcqo

movq    %rdx, %rbx
cqto                  # sign extend rax to rdx:rax
idivq   %rbx
Error: User Rate Limit Exceeded elyas-bhy
11

idivqrdx:rax

rax holds the lower 64-bits of the dividend. rdx holds the upper 64-bits of the dividend.

rdx:

movq    %rdx, %rbx
xorq    %rdx, %rdx    # zero "rdx"
idivq   %rbx

raxrdx:raxraxrdx

movq    %rdx, %rbx
cqo
idivq   %rbx
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededxor %rdx,%rdx / divError: User Rate Limit Exceededcqo / idivError: User Rate Limit Exceededuint64_tError: User Rate Limit Exceeded__int128_tError: User Rate Limit ExceededdivError: User Rate Limit ExceededidivError: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit ExceededxorqError: User Rate Limit ExceededcqoError: User Rate Limit ExceededraxError: User Rate Limit Exceededrdx:rax?

Похожие вопросы