在pic代码中使用库函数

时间:2014-06-19 12:15:30

标签: assembly

是这个代码PIC(位置独立)? 只要我知道PIC代码中一定没有库函数,但我不确定printf在这里被认为是库函数。

同样,在执行此代码后,edx寄存器中的值是多少? 它是to_printf或printf的绝对地址,还是to_printf和next_i的地址差异?

to_printf: dd printf
get_my_loc:
call next_i
next_i: 
pop edx
ret
call get_my_loc
push edx
add edx, (to_print - next_i)

1 个答案:

答案 0 :(得分:0)

绝对地址,与第一次遇到子程序next_i时标签next_i的地址相同。之后, "推edx"执行时,edx仍然包含指令地址" pop edx"

sequence of execution   effect
---------------------------------------------------------------------------------------------------------------------
call get_my_loc                addr of next instruction (push edx) stacked. call it "addr1"     
call next_i                          addr of next instruction (pop edx) stacked.  "addr2"
pop edx                             addr2 -> edx
ret                                      continues at addr1. addr2 was popped already.
; next operations work on edx, containing addr2, pointing to "pop edx"             
push edx    
add edx, ...