BASIC programs are stored in memory as lists with following format
(c64 as example):
0801:lo-addr
0802;hi-addr
0803:lineno
0804:basic-stuff
..
<lo-addr,hi-addr+0>:next lo-addr
<lo-addr,hi-addr+1>:next hi-addr
<lo-addr,hi-addr+1>:next lineno
..
<next lo-addr,next hi-addr+0>:3. lo-addr
..
<end-lo-addr,end-hi-addr+0>: 0
<end-lo-addr,end-hi-addr+1>: 0
For realocation, you have to step through the list and modify the
lo/ho-addrs appropriate (add new addr and sub. old addr).
Should be simple in ASM.