Sample procedure using C language specifier

ideal
model small, C ; Code is NEAR, language is C
; Data and stack in DGROUP

CODESEG
global demo_C:proc ; Make public as "_DEMO_C"

proc demo_C
arg a:word, b:dword:2, d:byte = arglen ; arglen = 12 (2)
local x:dword, y:word:2 = localspc ; localspc = 8 (3)
uses ds si di
; Source text: ; Code generated:
; ; push bp #p (1)
; ; mov bp,sp #p (1)
; ; sub sp,localspc #p (3)
; ; push ds #p (4)
; ; push si #p (4)
; ; push di #p (4)
mov [word low x],sp ; mov [dgroup:bp-04],sp (3)
mov [y],arglen ; mov [dgroup:bp-08],12 (3)
mov ax,[a] ; mov ax,[dgroup:bp+04] (2)
les di,[b] ; les di,[dgroup:bp+06] (2)
mov dl,[d] ; mov dl,[dgroup:bp+14] (2)
mul dl ; mul dl
stosw ; stosw
; [ Useful code omitted ]
RET ; pop di #e (4)
; ; pop si #e (4)
; ; pop ds #e (4)
; ; mov sp,bp #e (3)
; ; pop bp #e (1)
; ; retn #e (5) (1)
endp
; (1) Generated by C language specifier (in MODEL statement).
; If 80186+ instructions are enabled, PUSH BP; MOV BP,SP;
; SUB SP,localspc and MOV SP,BP; POP BP, will be replaced
; by ENTER/LEAVE.
; (2) Equate generated by ARG directive
; (3) Generated by LOCAL directive
; (4) Generated by USES directive
; (5) Generated by MODEL (code is NEAR)
; #p procedure prolog code (PROC statement)
; #e procedure epilog code (RET statement, several RETs possible)


; Calling from assembler:
DATASEG
blen db 20
CODESEG
assume ds:@data
call demo_C, ax, ds si, es di, [word PTR blen]
; CALL generates:
; push [word PTR blen]
; push es di
; push ds si
; push ax
; call demo_C
; add sp,12

END


Note: Assemble this module with the /ml command line switch to
make the procedure name public as "_demo_C".