Category : Files from Magazines
Archive   : PCTJ8805.ZIP
Filename : FUNC.ASM

 
Output of file : FUNC.ASM contained in archive : PCTJ8805.ZIP
;** Example of model-independent stack frame structure
; for ASM function called from C.
;
; For purposes of illustration only; NOT EXECUTABLE
;
; C function declaration:
; func(int a, *int b, *char c, double d, *double e)
;**

.MODEL small ;change as appropriate
include PTRLEN.INC ;defines @cplen, @dplen

onstack STRUC ;layout of stack frame
oldbp dw ? ;BP value pushed on entry
retaddr db @cplen dup(?) ;return address, 2 or 4 bytes
avalu dw ? ;word: value of int a
bptr db @dplen dup(?) ;2 or 4 bytes: address of int b
cptr db @cplen dup(?) ;2 or 4 bytes: address of char c
dvalu dd ? ;double-word: value of d
eptr db @dplen dup(?) ;2 or 4 bytes: address of double e
onstack ENDS

.CODE ;MASM inserts proper segment name
PUBLIC func
func PROC
push BP
mov BP,SP ;BP-> oldbp on stack
push SI ;save regs after setting BP
push DI
:
:
mov AX,[BP].avalu ;load value of parameter a
if @datasize ;if far data pointers...
les SI,dword ptr [BP].bptr ;get 4-byte ptr into ES:SI
mov BX,ES:[SI] ;load value of b
else ;if near data pointers...
mov SI,word ptr [BP].bptr ;get 2-byte ptr into SI
mov BX,[SI] ;load value of b
endif
:
:
pop DI
pop SI
pop BP
func ENDP
END ;automatically closes segment


  3 Responses to “Category : Files from Magazines
Archive   : PCTJ8805.ZIP
Filename : FUNC.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/