Appendix DD.1 EXAMPLE ASSEMBLER SHELL PROGRAM FOR MS-DOS INTERFACINGThe Microsoft MACRO-86 assembler follows closely the Intel ASM-86 specifications. The operating system interfacing technique is via a straightforward interrupt (INT 21Hex), with the required operational parameter in the AH register. MS-DOS does not corrupt any registers other than the ones used for the sending or receiving of data. An example of the running and exiting program technique, plus the required assembler directives, follows. The program example is for the small memory model; but it will apply equally well to the compact or large memory model. The 8080 memory model is not recommended as it results in poor usage of the potential of the 8086/8088 processor. At link time, this programming example will generate an .EXE file - the header information on this file type will be found in E.1. Example of MS-DOS/MACRO-86 Assembly Programming dgroup group data
cgroup group code
msdos equ 00021h ;interrupt to operating system
data segment public 'data'
;###### insert your data here ######
data ends
code segment public 'code'
assume CS: cgroup, DS: dgroup
example proc near ;origin of code
begin:
push ES ;save return segment address
call run_module ;run the program
;
; run ends - select close down
;
exit proc far ;close down code
xor ax,ax ;zero for PSP:0
push ax ;save for far return
ret ;and close down
exit endp ;close down code ends
run_module:
mov ax,DATA ;get the data segment origin
mov DS,ax ; and initialise the segment
;##### insert your code at this point ######
ret ;return to exit module
example endp
code ends
end
D.2 Example Assembler Shell Program for CP/M-86 Interfacing
The Digital Research ASM-86 assembler does not follow the
standard Intel ASM-86 structure - this makes for a more complex
task when transferring assembler programs between the CP/M-86 and
the MS-DOS operating systems. The operating system interfacing
technique is via a straightforward interrupt (INT E0Hex), with
the required operational parameter in the CL register. CP/M-86
corrupts all registers, excepting the CS and IP - it is,
therefore, recommended that all registers be pushed prior to the
INT E0Hex being issued. An example of the running and exiting
program technique, plus the required assembly directives,
follows. The program example follows that of the MS-DOS MACRO-86
example. At GENCMD time, this programming example will generate
a .CMD file - the header information on this file type is shown
in the System Guide for CP/M-86.
Example of CP/M-86/ASM-86 Programming
reset equ 00000h ;system reset function
cpm equ 000e0h ;interrupt to operating system
cseg
begin:
call run_module ;run the program
;
; run ends - select close down
;
mov cl,reset ;select system reset
mov dl,00h ;select memory recovery
int cpm ;return to operating system
;
run_module:
;##### insert your code at this point ######
ret ;return to exit module
dseg
;##### insert your data here #####
end
|