alan@io.UUCP (03/23/87)
I have just purchased Turbo Pascal for my pc compatible. I have written an assembly language piece of code, assembled it, linked it, and converted it to a .com file. It runs standalone, however when I declare it an external in Turbo it does not run properly. I am trying to access the character font rom in BIOS using es. What does one have to save in the way of registers to use a data segment within the assembly language function? If you have a working example I would greatly appreciate it. Thanks in advance.
m596008@sdsu.UUCP (04/02/87)
In article <245@io.UUCP> alan@io.UUCP writes: >I have just purchased Turbo Pascal for my pc compatible. I have written >an assembly language piece of code, assembled it, linked it, and >converted it to a .com file. It runs standalone, however when I >declare it an external in Turbo it does not run properly. I had the same problems. Even though I followed the Borland manuals exactly when it came to the passed parameters and return address on the stack. After fiddling around I got it to work by stacking these things differently. I am running Turbo Pascal 3.03a on an XT. I will dig up this code and post the relevant sections. John Falkenthal Lowly student until May 23!
m596008@sdsu.UUCP (04/06/87)
What follows is an example of a procedure call, and a function call.
-------------------------------------------------------
For a procedure:
procedure SET_CLOCK; external 'S_CLOCK.COM';
In the file 'S_CLOCK.COM' is the fully assembled code:
code segment
assume cs:code
setclk proc near
push ax
push bx
;
; various code goes in here
;
pop bx
pop ax
ret
setclk endp
code ends
end
------------------------------------------------------
For a function:
function TIME : integer; external 'SP_TIME.COM';
In the file 'SP_TIME.COM' is the assembled code:
name sp_time
include sm8086.mac
pseg
time1 dw ?
public time
time proc near
push ss
push ds
push bp
;
; various code in here
;
pop bp
pop ds
pop ss
ret 2
time endp
endps
end
Comments:
The Turbo Tutor manual talks about this process on pages
22-3 to 22-6. When you pass parameters back to the caller
from assembly, make sure your stack pointer is pointing to the
return address when you execute the 'ret' instruction, and the
parameters come after.
John Falkenthal