nasm - Addressing an array of pointers in asm -
i have routine can call this:
mov rdi, struc_point mov rsi, struc_color call put_pixel
now, create array of pointers have color table. have this, , it's not working:
color_table: dq 0 ; null color dq struc_color1 dq struc_color2 dq struc_color3 ; etc..., colors defined somewhere else
now, in end:
mov rbx, 2 ; index color table mov rdi, struc_point mov rsi, qword [color_table+8*rbx] call put_pixel
what going wrong? there no compiler errors, when run this, animations stop. rsi
should contain address of struc_color
, see first snippet. program works if hardcode color (mov rsi, struc_color
).
this in x86_64 asm, booted directly without os.
i found problem. code wrote above in fact correct , worked well.
the problem located inside of put_pixel
did not save rax
. , using rax
couple of lines earlier , storing data displayed in it. lead put_pixel
throwing program off course on first run.
Comments
Post a Comment