Category : Files from Magazines
Archive   : CL-JAN88.ZIP
Filename : INVOKE.ASM

 
Output of file : INVOKE.ASM contained in archive : CL-JAN88.ZIP

; include the segment defs. used by Eco-Soft's C compiler

DGROUP group $c$strtseg,$d$dataseg,$e$usdseg,$f$udseg,$g$uedseg,$h$stkseg,$i$endseg
PGROUP group $a$chain,$b$prog
$a$chain segment public 'code'
$a$chain ends
$b$prog segment word public 'code'
$b$prog ends
$c$strtseg segment public 'data1'
$c$strtseg ends
$d$dataseg segment word public 'data2'
$d$dataseg ends
$e$usdseg segment word public 'data3'
$e$usdseg ends
$f$udseg segment word public 'data4'
$f$udseg ends
$g$uedseg segment word public 'data5'
$g$uedseg ends
$h$stkseg segment word STACK 'data6'
$h$stkseg ends
$i$endseg segment word public 'data7'
$i$endseg ends
assume cs:PGROUP,ds:DGROUP,es:DGROUP,ss:DGROUP

; these are the actual double math routines

extrn $addd:near
extrn $mud:near
extrn $subd:near
extrn $dvd:near
extrn $negd:near

$d$dataseg segment 'data2'
rs label word
dw 0
csg label word
dw 0
$d$dataseg ends

retfar equ 203

COMMENT ~
The EcoSoft library is for the 808X near model of linkage.
The code that is generated in the spreadsheet resides in
the data segment. Therefore, without any knowledge of the
relative locations of the data and code segments, we have
to use FAR calls and returns to communicate between the
two. The bulk of this file, then, are routines that can
be called FAR (with a segment and offset value), and will
then NEAR call the required math library routine.

The following macro shows the skeleton for these calls.
~

mk_proc MACRO name, subr

public name
name proc far
pop rs
pop csg

call subr

push csg
push rs
db retfar

name endp

ENDM



$b$prog segment 'code'

mk_proc _neg, $negd ; negate a double

mk_proc _add, $addd ; add two doubles

mk_proc _sub, $subd ; sub " "

mk_proc _mud, $mud ; mult. " "

mk_proc _dvd, $dvd ; divd " "


; the assign routine expects BX to point to the destination. The stack
; contains the 8 byte value to assign (underneath the segment and PC info).
; This routine is used for expressions of the form a1 <- 1234.123
public _assign
_assign label far
push bp
mov bp,sp


mov ax,word ptr [bp][12]
mov word ptr [bx][6], ax

mov ax, word ptr [bp][10]
mov word ptr [bx][4], ax

mov ax, word ptr [bp][8]
mov word ptr[bx][2], ax

mov ax, word ptr [bp][6]
mov word ptr[bx], ax

pop bp
db retfar



extrn _instrs:far
public _invoke

_invoke proc near
call _instrs
ret
_invoke endp


$b$prog ends


end