STAGE1 of my bootloader loads at 0x0070:0x0000.
STAGE2 of my bootloader loads at 0x0090:0x0000.
There is a function in there (cputs) that I want to use in the STAGE2 bootloader.
cputs does use short jumps, but does that make a difference?
STAGE1 puts the pointer to cputs (Linear address) into a location in memory with some other variables.
STAGE2 reads the value into ax, (the value ends up being 0x7b0(the value is correct)).
How can I use CALL to run the function from STAGE2? ???
How can I use CALL?
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:How can I use CALL?
mov bx,[where_is_pointer_to_cputs_stored]
call [bx]
call [bx]
Re:How can I use CALL?
That doesn't work, it's in a different segment.Pype.Clicker wrote: mov bx,[where_is_pointer_to_cputs_stored]
call [bx]
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:How can I use CALL?
then you should make your variable hold a far pointer (check intel manuals to know whether it starts with segment or offset, but i think it is offset first), and use
if you know that your pointer is, say, located at 0x1234:0x5678, then
Code: Select all
fputs_pointer:
dw fputs
dw segment_of_fputs
mov bx,fputs_pointer
call WORD FAR [bx]
Code: Select all
mov bx,0x5678
mov es,0x1234 ;; i assume you don't want to touch ds.
call WORD FAR [es:bx]
Re:How can I use CALL?
Well, I got it to work.
I used:
I also changed the ret at the end of cputs to a retf.
I used:
Code: Select all
push cs ; push return cs
push word $+0xb ; push return ip
push word [CPUTS_SEG_POINTER] ; push function cs
push word 0x0000 ; push function ip
retf