Mail Archives: djgpp/2001/09/09/14:03:23
Eli Zaretskii schrieb:
> There's no need to explain how these functions work: I already know
> that.
That's actually a description of the source code and citations from the
docs;
I'm sure you are familiar with it, but to make things clear I repeated
it,
so other readers can follow the text without looking at them.
> Thanks. Your code has a bug:
>
> > /* Modify function code such that first parameter on stack will be */
> > /* returned in AX (second in BX if specified): */
> > _farpokeb(conv_mem_sel,0,0x5B); /* 5B = pop bx ; return address */
> > _farpokeb(conv_mem_sel,1,0x58); /* 58 = pop ax ; first parameter */
> > _farpokeb(conv_mem_sel,2,0x50); /* 50 = push ax ; first parameter */
>
> Your real-mode code is called as a far procedure, so the return
> address takes up 2 words (32 bits) on the stack, not one word.
> Therefore, the values you pop into AX and BX are the far pointer of
> the return address. I.e. you didn't pop enough to see your 2
> parameters: they are the next 2 words on the stack.
Ok, you're right.
Modifying the code to pop the return address into cx and dx and then the
stack
parameters into bx and ax (then pushing all back in the reverse order)
brings
the expected results.
---------
/* Modify function code such that first parameter on stack will be */
/* returned in AX (second in BX if specified): */
_farpokeb(conv_mem_sel,0,0x59); /* 59 = pop cx ; return address
*/
_farpokeb(conv_mem_sel,1,0x5A); /* 5A = pop dx ; return address
*/
_farpokeb(conv_mem_sel,2,0x58); /* 58 = pop ax ; first
parameter */
_farpokeb(conv_mem_sel,3,0x5B); /* 5B = pop bx ; second
parameter */
_farpokeb(conv_mem_sel,4,0x53); /* 53 = push bx ; second
parameter */
_farpokeb(conv_mem_sel,5,0x50); /* 50 = push ax ; first
parameter */
_farpokeb(conv_mem_sel,6,0x52); /* 52 = push dx ; return
address */
_farpokeb(conv_mem_sel,7,0x51); /* 51 = push cx ; return
address */
_farpokeb(conv_mem_sel,8,0xCB); /* CB = retf */
---------
I'm sorry here, I should have seen this.
So now I can continue where I started (calling the ASPI manager), I
still don't
know what's going wrong there.
Thanks, Leif
- Raw text -