I need to write a pixelization
assembly code ONLY using %rax, %rbx, %rcx, %rdx, %rsi, and %rdi (also %rsp and
%rbp)
So I've first wrote code in C and changed
any other registers into 64 bit registers, but at the point below when I change the
register it gives Segmentation default
C
code:
*temp =
b;
*(temp + 1) = g;
*(temp + 2) =
r;
Assembly code By
gcc:
movq -48(%rbp), %rax
movl %eax, %edx
movq -16(%rbp), %rax
movb %dl, (%rax)
movq -16(%rbp), %rax
addq $1, %rax
movq
-56(%rbp), %rdx
movb %dl, (%rax)
movq -16(%rbp),
%rax
addq $2, %rax
movq -64(%rbp), %rdx
movb %dl,
(%rax)
Changed
%dl to %rdx:
movq -16(%rbp),
%rax
movq -48(%rbp), %rdx
movzbq (%rdx), %rbx
movq %rbx,
(%rax)
movq -16(%rbp), %rax
addq $1, %rax
movq -56(%rbp),
%rdx
movzbq (%rdx), %rbx
movq %rbx, (%rax)
movq
-16(%rbp), %rax
addq $2, %rax
movq -64(%rbp), %rdx
movzbq
(%rdx), %rbx
movq %rbx, (%rax)
No comments:
Post a Comment