├── .gitignore ├── src ├── cwDPMI │ └── MAKE.BAT ├── cwc │ ├── cwc.asm │ ├── Makefile │ ├── decstub.inc │ └── copystub.asm ├── cwd │ ├── win.inc │ ├── cwd-ovl.asm │ ├── History.txt │ ├── print.inc │ ├── isfpu.asm │ ├── getkeys.inc │ ├── cwd.doc │ ├── cwd.cfg │ ├── Makefile │ └── macros.inc ├── cwl │ ├── cwl.asm │ └── make.bat ├── .gitignore ├── cwlib │ ├── cw.lib │ └── cw.asm │ │ ├── make.bat │ │ ├── null.asm │ │ ├── closef.asm │ │ ├── waitkey.asm │ │ ├── _waitkey.asm │ │ ├── getdrv.asm │ │ ├── _getdrv.asm │ │ ├── _beep.asm │ │ ├── _upprstr.asm │ │ ├── deletef.asm │ │ ├── setdrv.asm │ │ ├── _delay.asm │ │ ├── beep.asm │ │ ├── _free.asm │ │ ├── _prntstr.asm │ │ ├── _closef.asm │ │ ├── renfile.asm │ │ ├── free.asm │ │ ├── prntstr.asm │ │ ├── sys2hrd.asm │ │ ├── _getkey.asm │ │ ├── messw.asm │ │ ├── _setdrv.asm │ │ ├── _getpath.asm │ │ ├── dlggtw.asm │ │ ├── _setpath.asm │ │ ├── dlggtd.asm │ │ ├── arrow.gsc │ │ ├── _openf.asm │ │ ├── upchr.asm │ │ ├── _bord.asm │ │ ├── _rmsbits.asm │ │ ├── openf.asm │ │ ├── delay.asm │ │ ├── _apndstr.asm │ │ ├── _setmode.asm │ │ ├── _copystr.asm │ │ ├── _sys2hrd.asm │ │ ├── createf.asm │ │ ├── _createf.asm │ │ ├── relsbit.asm │ │ ├── _lnstr.asm │ │ ├── _upchr.asm │ │ ├── bord.asm │ │ ├── _dlggtw.asm │ │ ├── upprstr.asm │ │ ├── _dlggtd.asm │ │ ├── lnstr.asm │ │ ├── _deletef.asm │ │ ├── dlggtst.asm │ │ ├── _malloc.asm │ │ ├── _closew.asm │ │ ├── dlgstst.asm │ │ ├── _renfile.asm │ │ ├── _bin2dec.asm │ │ ├── _remsbit.asm │ │ ├── _srchrgb.asm │ │ ├── apndstr.asm │ │ ├── malloc.asm │ │ ├── setdacs.asm │ │ ├── _messw.asm │ │ ├── _msetype.asm │ │ ├── copystr.asm │ │ ├── _mgetpos.asm │ │ ├── _readf.asm │ │ ├── dlggtbw.asm │ │ ├── dlggtby.asm │ │ ├── _remallo.asm │ │ ├── dlggtbd.asm │ │ ├── setpix.asm │ │ ├── dlggtbx.asm │ │ ├── setpath.asm │ │ ├── _writef.asm │ │ ├── _dlggtst.asm │ │ ├── _srtflst.asm │ │ ├── _strlnpx.asm │ │ ├── _dlggtbw.asm │ │ ├── _dlggtby.asm │ │ ├── remallo.asm │ │ ├── _dlggtbd.asm │ │ ├── _dlggtbx.asm │ │ ├── strlnpx.asm │ │ ├── wsetpix.asm │ │ ├── bsetpix.asm │ │ ├── getkey.asm │ │ ├── _regsbit.asm │ │ ├── _setdacs.asm │ │ ├── _ldfont.asm │ │ ├── _relsbit.asm │ │ ├── _bin2hex.asm │ │ ├── getpath.asm │ │ ├── _dlgdraw.asm │ │ ├── _dlgstst.asm │ │ ├── _getdrvs.asm │ │ ├── setposf.asm │ │ ├── _crbtmp.asm │ │ ├── remsbit.asm │ │ ├── _regupw.asm │ │ ├── bin2hex.asm │ │ ├── _ldimage.asm │ │ ├── _setpal.asm │ │ ├── _ldiff.asm │ │ ├── _ldgif.asm │ │ ├── _ldtga.asm │ │ ├── _svgif.asm │ │ ├── _setpix.asm │ │ ├── _svtga.asm │ │ ├── _whichw.asm │ │ ├── _ulflist.asm │ │ ├── _sviff.asm │ │ ├── _setposf.asm │ │ ├── _dlgbtwn.asm │ │ ├── _svimage.asm │ │ ├── writef.asm │ │ ├── _dlgwhch.asm │ │ ├── bin2dec.asm │ │ ├── readf.asm │ │ ├── _flmknm.asm │ │ ├── bmyflp.asm │ │ ├── getdrvs.asm │ │ ├── flmknm.asm │ │ ├── _vesa.asm │ │ ├── _video.asm │ │ ├── _command.asm │ │ ├── ulflist.asm │ │ ├── dlgwhch.asm │ │ ├── rmsbits.asm │ │ ├── windows.asm │ │ ├── bmxflp.asm │ │ ├── srtflst.asm │ │ ├── regsbit.asm │ │ ├── regupw.asm │ │ ├── crbtmp.asm │ │ ├── whichw.asm │ │ ├── closew.asm │ │ ├── srchrgb.asm │ │ ├── openw.asm │ │ ├── _buffile.asm │ │ └── _makflst.asm ├── 3plib │ ├── 3plib.asm │ ├── 3plib.txt │ └── Make.bat ├── cwem │ ├── Debug │ │ └── I310600.3P │ ├── general.inc │ ├── print.inc │ ├── Makefile │ └── cwem.cfg ├── cwStub2 │ ├── MAKE.BAT │ └── Readme.txt └── cw32 │ └── CW32j.mak ├── doc ├── page_51.htm ├── page_6.htm ├── page_7.htm ├── page_76.htm ├── page_77.htm ├── page_78.htm ├── page_79.htm ├── page_80.htm ├── page_81.htm ├── page_122.htm ├── page_123.htm ├── page_124.htm ├── page_125.htm ├── page_126.htm ├── page_127.htm ├── page_128.htm ├── page_129.htm ├── page_100.htm ├── page_13.htm ├── page_1X2X.htm ├── page_48.htm ├── page_121.htm ├── page_74.htm ├── page_89.htm ├── page_99.htm ├── page_46.htm ├── page_91.htm ├── page_115.htm ├── page_41.htm ├── page_109.htm ├── page_69.htm ├── page_57.htm ├── page_84.htm ├── page_62.htm ├── page_70.htm ├── page_94.htm ├── page_68.htm ├── page_50.htm ├── page_75.htm ├── page_54.htm ├── page_114.htm ├── page_43.htm ├── page_49.htm ├── page_61.htm ├── page_58.htm ├── page_44.htm ├── page_72.htm └── page_59.htm ├── samples ├── dexdll.zip ├── watswap.zip ├── screen32.mak ├── DLLTESTA │ ├── Readme.txt │ ├── mdllapp2.bat │ ├── mdllapp1.bat │ ├── dll1.asm │ └── dllapp1.asm ├── DLLTEST │ ├── dll.c │ ├── makefile │ └── dlltest.c ├── tiny16.asm ├── dosshell.asm ├── flat.asm ├── croak2.c ├── croak1.c ├── small32.asm ├── tiny32.asm ├── croak3.c ├── showevar.asm ├── version.asm └── Readme.txt ├── license.txt └── Readme.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | bin 3 | obj 4 | misc 5 | Ver 6 | -------------------------------------------------------------------------------- /src/cwDPMI/MAKE.BAT: -------------------------------------------------------------------------------- 1 | @echo off 2 | jwasm -Fl CWDPMI.ASM 3 | wl32 CWDPMI 4 | -------------------------------------------------------------------------------- /doc/page_51.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/doc/page_51.htm -------------------------------------------------------------------------------- /doc/page_6.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/doc/page_6.htm -------------------------------------------------------------------------------- /doc/page_7.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/doc/page_7.htm -------------------------------------------------------------------------------- /doc/page_76.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/doc/page_76.htm -------------------------------------------------------------------------------- /doc/page_77.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/doc/page_77.htm -------------------------------------------------------------------------------- /doc/page_78.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/doc/page_78.htm -------------------------------------------------------------------------------- /doc/page_79.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/doc/page_79.htm -------------------------------------------------------------------------------- /doc/page_80.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/doc/page_80.htm -------------------------------------------------------------------------------- /doc/page_81.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/doc/page_81.htm -------------------------------------------------------------------------------- /src/cwc/cwc.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/src/cwc/cwc.asm -------------------------------------------------------------------------------- /src/cwd/win.inc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/src/cwd/win.inc -------------------------------------------------------------------------------- /src/cwl/cwl.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/src/cwl/cwl.asm -------------------------------------------------------------------------------- /doc/page_122.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/doc/page_122.htm -------------------------------------------------------------------------------- /doc/page_123.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/doc/page_123.htm -------------------------------------------------------------------------------- /doc/page_124.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/doc/page_124.htm -------------------------------------------------------------------------------- /doc/page_125.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/doc/page_125.htm -------------------------------------------------------------------------------- /doc/page_126.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/doc/page_126.htm -------------------------------------------------------------------------------- /doc/page_127.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/doc/page_127.htm -------------------------------------------------------------------------------- /doc/page_128.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/doc/page_128.htm -------------------------------------------------------------------------------- /doc/page_129.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/doc/page_129.htm -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | *.obj 2 | *.EXE 3 | *.MAP 4 | cw_ow 5 | le23p 6 | loadle 7 | Test 8 | watcom 9 | -------------------------------------------------------------------------------- /src/cwlib/cw.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/src/cwlib/cw.lib -------------------------------------------------------------------------------- /samples/dexdll.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/samples/dexdll.zip -------------------------------------------------------------------------------- /samples/watswap.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/samples/watswap.zip -------------------------------------------------------------------------------- /src/3plib/3plib.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/src/3plib/3plib.asm -------------------------------------------------------------------------------- /src/3plib/3plib.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/src/3plib/3plib.txt -------------------------------------------------------------------------------- /src/cwd/cwd-ovl.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/src/cwd/cwd-ovl.asm -------------------------------------------------------------------------------- /src/cwem/Debug/I310600.3P: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Baron-von-Riedesel/CauseWay/HEAD/src/cwem/Debug/I310600.3P -------------------------------------------------------------------------------- /src/cwlib/cw.asm/make.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | if not exist Build\NUL mkdir Build 3 | jwasm -nologo -c -Cx -FoBuild\ *.asm 4 | -------------------------------------------------------------------------------- /src/3plib/Make.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem ml -c -nologo -I.. 3plib.asm 3 | jwasm -c -nologo -Fl -I.. 3plib.asm 4 | wl32 /q/m/cs/f 3plib.obj 5 | -------------------------------------------------------------------------------- /src/cwStub2/MAKE.BAT: -------------------------------------------------------------------------------- 1 | @echo off 2 | jwasm -nologo -mz -Fl cwStub2.asm 3 | rem jwasm -nologo -Fl cwStub2.asm 4 | rem jwlink format dos f cwStub2.obj op m 5 | -------------------------------------------------------------------------------- /samples/screen32.mak: -------------------------------------------------------------------------------- 1 | # 2 | all: screen32.exe 3 | 4 | screen32.exe : screen32.obj 5 | @wl32 /f/m screen32.obj 6 | 7 | screen32.obj: screen32.asm 8 | @jwasm -nologo screen32.asm 9 | 10 | 11 | -------------------------------------------------------------------------------- /samples/DLLTESTA/Readme.txt: -------------------------------------------------------------------------------- 1 | 2 | samples to show how dlls may be used in assembly. 3 | 4 | dllapp1: uses the C wrapper functions LoadModule, GetProcAddress, FreeModule. 5 | dllapp2: uses the CauseWay int 31h API directly. 6 | -------------------------------------------------------------------------------- /src/cwl/make.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | if not exist Build\NUL mkdir Build 3 | rem ml -c -nologo /Cx /Zf /Zd /FlBuild\ /FoBuild\ -I.. cwl.asm 4 | jwasm -c -nologo /Cx /Zf /Zd /FlBuild\ /FoBuild\ -I.. cwl.asm 5 | wl32 /f /m /cs Build\cwl.obj, Build\cwl.exe, Build\cwl.map 6 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/null.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------- 5 | ; 6 | ;Dummy routine for variables that need a call value that does nothing. 7 | ; 8 | NearNull proc near 9 | ret 10 | NearNull endp 11 | 12 | 13 | efile 14 | end 15 | 16 | -------------------------------------------------------------------------------- /doc/page_100.htm: -------------------------------------------------------------------------------- 1 | 2 |
3 |Chapter 2-5: WL32 LINKER
11 |These chapters have been removed; WL32 is now in a separate repository with its very own documentation.
12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/cwd/isfpu.asm: -------------------------------------------------------------------------------- 1 | .386 2 | .model flat 3 | .stack 400h 4 | 5 | .data 6 | FoundText DB 'FPU detected.',13,10 7 | MissingText DB 'No FPU detected.',13,10 8 | 9 | .code 10 | 11 | start: 12 | mov ax,ss 13 | mov ds,ax 14 | finit 15 | push eax 16 | fstcw [esp] 17 | pop eax 18 | cmp ah,3 19 | jne nofpu 20 | 21 | isfpu: 22 | mov edx,OFFSET FoundText 23 | mov ecx,SIZEOF FoundText 24 | jmp output 25 | 26 | nofpu: 27 | mov edx,OFFSET MissingText 28 | mov ecx,SIZEOF MissingText 29 | 30 | output: 31 | mov bx,1 32 | mov ah,40h 33 | int 21h 34 | mov ax,4c00h 35 | int 21h 36 | end start 37 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/delay.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------- 5 | ; 6 | ;Wait for a while. 7 | ; 8 | ;On Entry: 9 | ; 10 | ;ECX - time to wait for. 11 | ; 12 | Delay proc near 13 | pushm eax,ebx,ecx,edx,esi 14 | mov esi,ecx 15 | mov ah,0 16 | int 1ah 17 | shl ecx,16 18 | mov cx,dx 19 | mov ebx,ecx 20 | l0: mov ah,0 21 | int 1ah 22 | shl ecx,16 23 | mov cx,dx 24 | sub ecx,ebx 25 | cmp ecx,esi 26 | jc l0 27 | popm eax,ebx,ecx,edx,esi 28 | ret 29 | Delay endp 30 | 31 | 32 | efile 33 | end 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/cwd/getkeys.inc: -------------------------------------------------------------------------------- 1 | 2 | .data 3 | 4 | Keys dw 0 5 | 6 | .code 7 | 8 | ;==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-== 9 | ; 10 | ;Ask DOS for any pending key press information. 11 | ; 12 | ;No entry conditions. 13 | ; 14 | ;On Exit:- 15 | ; 16 | ;If flags none zero,AL - main byte AH - Auxiluary byte 17 | ;otherwise, no keypress available. 18 | ; 19 | ;KEYS - copy of AX 20 | ; 21 | GetKeys proc near 22 | mov ah,1 23 | int 16h 24 | mov ax,0 25 | jz @@0 26 | mov ah,0 27 | int 16h 28 | mov Keys,ax 29 | cmp ax,0 30 | @@0: ret 31 | ; 32 | GetKeys endp 33 | 34 | 35 | -------------------------------------------------------------------------------- /samples/DLLTESTA/mdllapp1.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem 3 | rem A simple CauseWay dll sample in assembly. 4 | rem For CW v5.0, kernel imports (in cwapi.obj) are no longer needed, since the API 5 | rem directly supports FindModule, UnFindModule and FindFunction. 6 | rem 7 | jwasm -nologo dllapp1.asm 8 | rem wlink format os2 le f dllapp1.obj libfile ..\..\obj\dllfunc.obj,..\..\obj\cwapi.obj op q,m,stub=cwstub.exe 9 | wlink format os2 le f dllapp1.obj libfile ..\..\obj\dllfunc.obj op q,m,stub=cwstub.exe 10 | rem 11 | jwasm -nologo dll1.asm 12 | wlink format os2 le dll f dll1.obj op q,m export _SayHello 13 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/_apndstr.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------- 5 | ; 6 | ;Append a string to another string. 7 | ; 8 | ;On Entry: 9 | ; 10 | ;source - pointer to source string. 11 | ;dest - pointer to destination string to append to. 12 | ; 13 | _AppendString proc syscall source:dword, dest:dword 14 | public _AppendString 15 | pushm esi,edi 16 | mov esi,source 17 | mov edi,dest 18 | call AppendString ;Call ASM version. 19 | popm esi,edi 20 | ret 21 | _AppendString endp 22 | 23 | efile 24 | 25 | end 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/_setmode.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------- 5 | ; 6 | ;Attempt to set specified video mode. 7 | ; 8 | ;Calling: 9 | ; 10 | ;VideoSetMode(mode); 11 | ; 12 | ;On Entry: 13 | ; 14 | ;mode - Mode to set. 15 | ; 16 | ;On Exit: 17 | ; 18 | ;EAX - zero on error else mode number. 19 | ; 20 | ;ALL other registers preserved. 21 | ; 22 | _VideoSetMode proc syscall mode:dword 23 | public _VideoSetMode 24 | mov eax,mode 25 | call VideoSetMode 26 | ret 27 | _VideoSetMode endp 28 | 29 | 30 | efile 31 | end 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/_copystr.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------- 5 | ; 6 | ;Copy a string from one place to another. 7 | ; 8 | ;On Entry: 9 | ; 10 | ;source - Source string. 11 | ;destination - Destination string. 12 | ; 13 | ;On Exit: 14 | ; 15 | ;ALL registers preserved. 16 | ; 17 | _CopyString proc syscall source:dword, dest:dword 18 | public _CopyString 19 | pushm esi,edi 20 | mov esi,source 21 | mov edi,dest 22 | call CopyString 23 | popm esi,edi 24 | ret 25 | _CopyString endp 26 | 27 | 28 | efile 29 | end 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/_sys2hrd.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------- 5 | ; 6 | ;Convert system pen number into hardware pen number. 7 | ; 8 | ;Calling: 9 | ; 10 | ;VideoSys2Hard(pen); 11 | ; 12 | ;On Entry: 13 | ; 14 | ;pen - pen number to convert. 15 | ; 16 | ;On Exit: 17 | ; 18 | ;AL - new pen number. 19 | ; 20 | ;ALL other registers preserved. 21 | ; 22 | _VideoSys2Hard proc syscall pen:dword 23 | public _VideoSys2Hard 24 | mov eax,pen 25 | call VideoSys2Hard 26 | ret 27 | _VideoSys2Hard endp 28 | 29 | 30 | efile 31 | end 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/createf.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------- 5 | ; 6 | ;Create a file. 7 | ; 8 | ;On Entry: 9 | ; 10 | ;EDX - File name. 11 | ; 12 | ;On Exit: 13 | ; 14 | ;Carry set on error and EBX=0 else, 15 | ; 16 | ;EBX - File handle. 17 | ; 18 | CreateFile proc near 19 | pushm eax,ecx 20 | mov ah,3ch ;Create function. 21 | xor cx,cx ;normal attributes. 22 | int 21h 23 | mov bx,ax 24 | jnc l0 25 | xor bx,bx 26 | stc 27 | l0: movzx ebx,bx 28 | popm eax,ecx 29 | ret 30 | CreateFile endp 31 | 32 | 33 | efile 34 | end 35 | 36 | -------------------------------------------------------------------------------- /samples/DLLTEST/dll.c: -------------------------------------------------------------------------------- 1 | 2 | #include|
12 | FarCallReal Simulate real mode far call. |
13 |
Inputs: AX = 0ff02h
17 |ES:[E]DI = Real mode register list.
18 |Outputs: Register list updated.
19 |Errors: None.
20 | 21 | 22 | 23 |Notes: This function works much the same as IntXX but provides a 16 bit FAR stack frame and the CS:IP values are used to pass control to the real mode code.
24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/_ulflist.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------------- 5 | ; 6 | ;Convert normal names to lower case and directory names to upper case. 7 | ; 8 | ;Calling: 9 | ; 10 | ;ULFileList(filelist); 11 | ; 12 | ;On Entry: 13 | ; 14 | ;filelist - pointer to file list. 15 | ; 16 | ;On Exit: 17 | ; 18 | ;ALL registers preserved. 19 | ; 20 | ;Most routines that need to display a file list want directory names in upper 21 | ;case and the remaining names in lower case. This routine formats a file list 22 | ;to that specification. Doing things this way means that if the file list is 23 | ;then sorted, directory names will appear at the top. 24 | ; 25 | _ULFileList proc syscall filelist:dword 26 | public _ULFileList 27 | pushm esi 28 | mov esi,filelist 29 | call ULFileList 30 | popm esi 31 | ret 32 | _ULFileList endp 33 | 34 | 35 | efile 36 | end 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/_sviff.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------------ 5 | ; 6 | ;Encodes and writes a bitmap in IFF format. 7 | ; 8 | ;Calling: 9 | ; 10 | ;SaveIFF(flags,filename,bitmap); 11 | ; 12 | ;On Entry: 13 | ; 14 | ;flags - flags, bit significant if set. 15 | ; 0 - compress output. 16 | ; 1 - old format. 17 | ;filename - pointer to name of file to load. 18 | ;bitmap - pointer to bitmap. 19 | ; 20 | ;On Exit: 21 | ; 22 | ;EAX - Status, 23 | ; 0 - no error. 24 | ; 1 - file error. 25 | ; 2 - not enough memory (for buffers). 26 | ; 3 - format error. 27 | ; 28 | ;ALL other registers preserved. 29 | ; 30 | _SaveIFF proc syscall flags:dword, filename:dword, bitmap:dword 31 | public _SaveIFF 32 | pushm edx,esi 33 | mov eax,flags 34 | mov edx,filename 35 | mov esi,bitmap 36 | call SaveIFF 37 | popm edx,esi 38 | ret 39 | _SaveIFF endp 40 | 41 | 42 | efile 43 | end 44 | 45 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/_setposf.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------- 5 | ; 6 | ;Set the file pointer position for a file. 7 | ; 8 | ;Calling: 9 | ; 10 | ;SetFilePointer(handle,method,position); 11 | ; 12 | ;On Entry: 13 | ; 14 | ;handle - file handle. 15 | ;method - method to use. 16 | ;position - position to set. 17 | ; 18 | ;Methods are: 19 | ; 20 | ;0 - Absolute offset from start. 21 | ;1 - signed offset from current position. 22 | ;2 - signed offset from end of file. 23 | ; 24 | ;On Exit: 25 | ; 26 | ;EAX - new absolute offset from start of file. 27 | ; 28 | _SetFilePointer proc syscall handle:dword, method:dword, position:dword 29 | public _SetFilePointer 30 | pushm ebx,ecx 31 | mov eax,method 32 | mov ebx,handle 33 | mov ecx,position 34 | call SetFilePointer 35 | mov eax,ecx 36 | popm ebx,ecx 37 | ret 38 | _SetFilePointer endp 39 | 40 | 41 | efile 42 | end 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/_dlgbtwn.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------- 5 | ; 6 | ;Make a piece of window look like a button. 7 | ; 8 | ;Calling: 9 | ; 10 | ;ButtonWindow(btype,xcoord,ycoord,wide,depth,window); 11 | ; 12 | ;On Entry: 13 | ; 14 | ;btype - Type of button to draw. 15 | ;xcoord - X coord to draw at. 16 | ;ycoord - Y coord to draw at. 17 | ;wide - width of button. 18 | ;depth - depth of button. 19 | ;window - Pointer to window structure. 20 | ; 21 | ;On Exit: 22 | ; 23 | ;nothing. 24 | ; 25 | ;ALL registers preserved. 26 | ; 27 | _ButtonWindow proc syscall btype:dword, xcoord:dword, ycoord:dword, \ 28 | wide:dword, depth:dword, window:dword 29 | public _ButtonWindow 30 | pushad 31 | mov eax,btype 32 | mov ecx,xcoord 33 | mov ebx,ycoord 34 | mov edx,wide 35 | mov edi,depth 36 | mov esi,window 37 | call ButtonWindow 38 | popad 39 | ret 40 | _ButtonWindow endp 41 | 42 | 43 | efile 44 | end 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/_svimage.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------------ 5 | ; 6 | ;Encodes and writes a bitmap in chosen format. 7 | ; 8 | ;Calling: 9 | ; 10 | ;SaveImageFile(flags,filename,bitmap); 11 | ; 12 | ;On Entry: 13 | ; 14 | ;flags - flags, bit significant if set. 15 | ; 0 - compress output. 16 | ; 1 - alternate format. 17 | ;filename - pointer to name of file to create. 18 | ;bitmap - pointer to bitmap. 19 | ; 20 | ;On Exit: 21 | ; 22 | ;EAX - Status, 23 | ; 0 - no error. 24 | ; 1 - file error. 25 | ; 2 - not enough memory (for buffers). 26 | ; 3 - format error. 27 | ; 28 | ;ALL other registers preserved. 29 | ; 30 | _SaveImageFile proc syscall flags:dword, filename:dword, bitmap:dword 31 | public _SaveImageFile 32 | pushm edx,esi 33 | mov eax,flags 34 | mov edx,filename 35 | mov esi,bitmap 36 | call SaveImageFile 37 | popm edx,esi 38 | ret 39 | _SaveImageFile endp 40 | 41 | 42 | efile 43 | end 44 | 45 | -------------------------------------------------------------------------------- /src/cwd/cwd.cfg: -------------------------------------------------------------------------------- 1 | 2 | ; 3 | ;Tell CWD where to look for source files. CWD will look in the current DIR first 4 | ;and then in any paths specified here. Seperate paths with a ; same as a normal 5 | ;PATH statement. This command can be used more than once to append extra paths. 6 | ; 7 | SourcePath= 8 | 9 | ; 10 | ;Tell CWD what TAB positions to use for source display. 11 | ; 12 | SourceTABs=16,22,35,48,61 13 | 14 | ; 15 | ;Tell CWD which keys to use for breaking into the program. Codes are raw 16 | ;keyboard scan codes in decimal, upto 4 of them seperated by commas. Don't use 17 | ;extended codes (0e0h etc). 18 | ; 19 | ;Some useful codes: 20 | ; 21 | ;CTRL - 29 22 | ;ALT - 56 23 | ; 24 | ;Built in default is 29,56 (CTRL-ALT). 25 | ; 26 | BreakKeys=29,56 27 | 28 | ; 29 | ;Games tend to re-program the timer interrupt with a different value and 30 | ;dropping out of a debug session half way through might leave the timer running 31 | ;fast so we can tell CWD to reset the timer to its normal value. 32 | ; 33 | ResetTimer=YES 34 | -------------------------------------------------------------------------------- /doc/page_121.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |VMM
11 | 12 |Virtual Memory Manager. CauseWay's virtual memory manager consists of the routines which handle swapping memory containing code and data, to and from the disk, from and to physical memory.
13 | 14 |Wildsmith, John
15 | 16 |One of the CauseWay developers. John Wildsmith wrote the original versions of the CauseWay DOS extender and the CWC compression and CWD debugger utilities.
17 | 18 |WL32
19 | 20 |The linker contained within the CauseWay software program.
21 | 22 |XMS
23 | 24 |XMS stand for extended memory specification, a standard software interface for extended memory access.
25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/cwd/Makefile: -------------------------------------------------------------------------------- 1 | 2 | # make CWD.EXE & CWD.OVL, now using WL32 instead of CWL. 3 | 4 | ALL : Build Build\cwd.exe Build\cwd.ovl 5 | 6 | Build: 7 | @mkdir Build 8 | 9 | Build\cwd.exe: Build\cwd.obj 10 | @wl32 /q/ex/m/non/cs Build\cwd.obj,Build\cwd.exe,Build\cwd.map 11 | 12 | Build\cwd.obj: cwd.asm cmacros.inc equates.inc ..\strucs.inc 13 | @ml -c -nologo -FlBuild\ -FoBuild\ -I.. cwd.asm 14 | 15 | Build\cwd.ovl: Build\cwd-ovl.obj 16 | # @..\cwl\build\cwl.exe /MAP Build\cwd-ovl.obj,Build\cwd.ovl,Build\cwd-ovl.map 17 | @wl32 /q/m/cs/non Build\cwd-ovl.obj,Build\cwd.ovl,Build\cwd-ovl.map 18 | # @..\..\bin\cwc Build\cwd.ovl 19 | 20 | Build\cwd-ovl.obj: cwd-ovl.asm disas.inc generr.inc fpu.inc disaseq.inc win.inc evaluate.inc macros.inc \ 21 | getkeys.inc print.inc fileacc.inc ..\cw.inc ..\strucs.inc 22 | @ml -c -nologo -FlBuild\ -Sg -FoBuild\ /I.. cwd-ovl.asm 23 | # @jwasm -c -nologo -FlBuild\ -Sg -FoBuild\ /I.. cwd-ovl.asm 24 | 25 | clean: 26 | @del Build\cwd.exe 27 | @del Build\cwd.ovl 28 | @del Build\cwd.obj 29 | @del Build\cwd-ovl.obj 30 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/writef.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------- 5 | ; 6 | ;Write some data to a file. 7 | ; 8 | ;On Entry: 9 | ; 10 | ;EDX - Address to write from. 11 | ;ECX - Length to write. 12 | ;EBX - file handle. 13 | ; 14 | ;On Exit: 15 | ; 16 | ;EAX - Bytes written. 17 | ; 18 | WriteFile proc near 19 | pushm ecx,edx,esi 20 | xor esi,esi 21 | @@0: pushm ebx,ecx,edx,esi 22 | cmp ecx,65535 ;size of chunks to load. 23 | jc @@1 24 | mov ecx,65535 ;as close to 64k as can get. 25 | @@1: mov ah,40h 26 | int 21h ;read from the file. 27 | popm ebx,ecx,edx,esi 28 | jc @@2 29 | movzx eax,ax ;get length read. 30 | add esi,eax ;update length read counter. 31 | add edx,eax ;move memory pointer. 32 | sub ecx,eax ;update length counter. 33 | jz @@2 ;read as much as was wanted. 34 | or eax,eax ;did we write anything? 35 | jz @@2 36 | jmp @@0 37 | @@2: mov eax,esi 38 | popm ecx,edx,esi 39 | ret 40 | WriteFile endp 41 | 42 | 43 | efile 44 | end 45 | 46 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/_dlgwhch.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | 5 | ;------------------------------------------------------------------------- 6 | ; 7 | ;Work out which section of a dialog the specified co-ords relate to. 8 | ; 9 | ;Calling: 10 | ; 11 | ;DialogWhich(xcoord,ycoord,dialog,result); 12 | ; 13 | ;On Entry: 14 | ; 15 | ;xcoord - X coord. 16 | ;ycoord - Y coord. 17 | ;dialog - pointer to dialog. 18 | ;result - 3 int buffer for result. 19 | ; 20 | ;On Exit: 21 | ; 22 | ;EAX - Entry number, -1 for none. 23 | ;result+0 - EAX 24 | ;result+4 - relative x co-ord. 25 | ;result+8 - relative y co-ord. 26 | ; 27 | ;ALL other registers preserved. 28 | ; 29 | _DialogWhich proc syscall xcoord:dword, ycoord:dword, dialog:dword, result:dword 30 | public _DialogWhich 31 | pushm ecx,edx,esi 32 | mov ecx,xcoord 33 | mov edx,ycoord 34 | mov esi,dialog 35 | call _DialogWhich 36 | mov esi,result 37 | mov [esi],eax 38 | mov [esi+4],ecx 39 | mov [esi+8],edx 40 | popm ecx,edx,esi 41 | ret 42 | _DialogWhich endp 43 | 44 | 45 | efile 46 | end 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/bin2dec.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------- 5 | ; 6 | ;Convert number into decimal ASCII. 7 | ; 8 | ;On Entry: 9 | ; 10 | ;EAX - Number to convert. 11 | ;EDI - Buffer to put it in. 12 | ; 13 | ;On Exit: 14 | ; 15 | ;EDI - Next available byte in buffer. 16 | ; 17 | Bin2Dec proc near 18 | pushm eax,ebx,ecx,edx 19 | xor bl,bl ;Clear output flag. 20 | mov ecx,1000000000 ;Set initial divisor. 21 | l0: xor edx,edx 22 | div ecx 23 | cmp ecx,1 ;Last digit? 24 | jz l1 25 | or al,al ;a zero? 26 | jnz l1 27 | or bl,bl ;done any others yet? 28 | jz l2 29 | l1: mov [edi],al ;Store character. 30 | add b[edi],'0' ;make it ASCII. 31 | inc edi 32 | inc bl 33 | l2: push edx ;store remainder. 34 | mov eax,ecx 35 | xor edx,edx 36 | mov ecx,10 ;work out new divisor. 37 | div ecx 38 | mov ecx,eax 39 | pop eax ;get remaindor back. 40 | or ecx,ecx 41 | jnz l0 42 | popm eax,ebx,ecx,edx 43 | ret 44 | Bin2Dec endp 45 | 46 | 47 | efile 48 | end 49 | 50 | 51 | -------------------------------------------------------------------------------- /samples/croak3.c: -------------------------------------------------------------------------------- 1 | // croak3.c 2 | // C source example #3 on using UserDump API function 3 | #includeCauseWay runs applications at privilege level 3. Privilege level 0 reserved instructions will cause a general protection 11 | fault (GPF). CauseWay emulates the four instructions MOV EAX,CR0; MOV CR0,EAX; MOV EAX,CR3; and MOV CR3,EAX in the GPF 12 | handler so that they may be used by an application.
13 |CauseWay will match a DPMI 0A00h function call with target string RATIONAL/4G. 14 | This in conjunction with CR0 emulation allows support of floating point emulation by an exception handler. 15 | Watcom uses this approach under DOS/4GW operation if the floating point emulation library is not linked in. 16 | Note that this routine does not work for either CauseWay or DOS/4GW under a DPMI host such as Windows or OS/2.
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /samples/showevar.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | STDOUT EQU 1 3 | .stack 100h 4 | .data 5 | crlf DB 13,10 6 | DW 4000 DUP (0) ; bulk up size by 8K to make large enough for modifications 7 | .code 8 | start: 9 | mov ds,es:[2ch] ; ds -> e-var block (es -> PSP on entry) 10 | xor si,si ; init offset in block 11 | mov bx,STDOUT 12 | 13 | loop2: 14 | mov al,ds:[si] ; get first char of string 15 | or al,al ; see if null (no more strings) 16 | je done 17 | 18 | loop1: 19 | mov dx,si ; ds:dx -> string to print 20 | mov cx,1 21 | mov ah,40h ; write to device 22 | int 21h 23 | inc si ; move to next char in string 24 | mov al,ds:[si] ; print remaining chars in string one at a time 25 | or al,al ; see if null (end of string) 26 | jne loop1 ; nope 27 | 28 | push ds ; save ds -> e-var block 29 | mov ax,DGROUP 30 | mov ds,ax 31 | mov dx,OFFSET DGROUP:crlf ; write CR/LF pair after string end 32 | mov cl,2 33 | mov ah,40h ; write to device 34 | int 21h 35 | pop ds ; restore ds -> e-var block 36 | inc si 37 | jmp SHORT loop2 38 | 39 | done: 40 | mov ax,4c00h ; terminate with zero return code 41 | int 21h 42 | end start 43 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2021 Andreas Grech (japheth) 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/bmyflp.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | 5 | ;------------------------------------------------------------------------------ 6 | ; 7 | ;Flip a bitmap from top to bottom, eg, around X axis, but affecting it in the Y 8 | ; 9 | ;On Entry: 10 | ; 11 | ;ESI - bitmap 12 | ; 13 | ;On Exit: 14 | ; 15 | ;nothing. 16 | ; 17 | ;All registers preserved. 18 | ; 19 | BitmapYFlip proc near 20 | public BitmapYFlip 21 | pushad 22 | mov eax,BM_PWide[esi] 23 | mul BM_Wide[esi] 24 | mov ecx,eax ;Get line length. 25 | mul BM_Depth[esi] 26 | add eax,esi 27 | add eax,size BM 28 | sub eax,ecx 29 | mov edi,eax ;Point to last line. 30 | mov edx,BM_Depth[esi] 31 | shr edx,1 ;get depth to do. 32 | or edx,edx 33 | jz @@2 34 | add esi,size BM ;point to first line. 35 | @@0: pushm ecx,esi,edi 36 | @@1: mov al,[esi] ;swap the data round. 37 | xchg al,[edi] 38 | mov [esi],al 39 | inc esi 40 | inc edi 41 | loop @@1 ;do whole line. 42 | popm ecx,esi,edi 43 | add esi,ecx ;next line down. 44 | sub edi,ecx ;next line up. 45 | dec edx 46 | jnz @@0 ;do all lines. 47 | @@2: popad 48 | ret 49 | BitmapYFlip endp 50 | 51 | efile 52 | end 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/getdrvs.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------- 5 | ; 6 | ;Build a list of all valid drives on the system. 7 | ; 8 | ;On Entry: 9 | ; 10 | ;EDX - Address to build list of drives. 11 | ; 12 | ;On Exit: 13 | ; 14 | ;ECX - number of drives. 15 | ; 16 | ;ALL other registers preserved. 17 | ; 18 | ;The drive list uses real drive codes (not ASCII). Each entry uses 1 byte 19 | ;and the list is terminated with -1. 20 | ; 21 | GetDrives proc near 22 | pushm eax,edx,edi 23 | mov edi,edx 24 | mov ah,19h ; use get drive function 25 | int 21h 26 | push eax ; save current drive. 27 | mov dl,-1 28 | xor cl,cl 29 | ; 30 | l0: inc dl 31 | cmp dl,26 32 | jz l1 33 | push edx 34 | mov ah,0eh ; use set drive function 35 | int 21h 36 | mov ah,19h ; now get it again. 37 | int 21h 38 | pop edx 39 | cmp al,dl ; right drive? 40 | jnz l0 41 | inc cl 42 | stosb 43 | xor al,al 44 | stosb 45 | jmp l0 46 | ; 47 | l1: xor al,al 48 | stosb 49 | pop edx 50 | mov ah,0eh ; use set drive function 51 | int 21h 52 | movzx ecx,cl 53 | popm eax,edx,edi 54 | ret 55 | GetDrives endp 56 | 57 | 58 | efile 59 | end 60 | 61 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/flmknm.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------------- 5 | ; 6 | ;Make a full drive:path\file name from a file list path string and specified 7 | ;file name. 8 | ; 9 | ;On Entry: 10 | ; 11 | ;ECX - entry number to make name from. 12 | ;ESI - pointer to file list. 13 | ;EDI - pointer to destination buffer. 14 | ; 15 | ;On Exit: 16 | ; 17 | ;ALL registers preserved. 18 | ; 19 | ;Name in a file list are just the 8.3 portion. A more useful name can be made 20 | ;by combineing the path string from the start of the list buffer with the file 21 | ;name which this routine does. 22 | ; 23 | FileListMakeName proc near 24 | pushm eax,edx,esi,edi 25 | add esi,4 26 | call CopyString ;Copy path string into place. 27 | pushm ecx,edi 28 | or ecx,-1 29 | xor al,al 30 | repnz scasb ;find end of string. 31 | dec edi 32 | cmp b[edi-1],"\" 33 | jz @@0 34 | mov b[edi],"\" 35 | mov b[edi+1],0 36 | @@0: popm ecx,edi 37 | mov eax,14 38 | mul ecx 39 | add esi,eax 40 | add esi,256 41 | call AppendString ;Append file name. 42 | popm eax,edx,esi,edi 43 | ret 44 | FileListMakeName endp 45 | 46 | 47 | efile 48 | end 49 | 50 | -------------------------------------------------------------------------------- /samples/DLLTESTA/dll1.asm: -------------------------------------------------------------------------------- 1 | 2 | ;--- CauseWay dll in assembly 3 | 4 | .386 5 | .model flat 6 | option casemap:none 7 | 8 | CStr macro text:vararg 9 | local sym 10 | .const 11 | sym db text,0 12 | .code 13 | exitmGENERAL NOTES ON WINDOWING
11 |To select any window other than the current foreground window, click the mouse once with the cursor inside the desired window. Release the mouse button before making further selections.
12 |To move a window, click on the title bar of the foreground window and move the mouse while holding the mouse button down.
13 |To adjust a window size, click on the bottom right corner of the current window and move the mouse while holding the mouse button down.
14 |To cycle through available windows, press TAB.
15 |To cycle through windows in reverse order, press SHIFT-TAB.
16 |For those working with graphics, mode 13h is directly supported. However, the proliferation of numerous SVGA modes prohibits supporting of all of them. Therefore, using a monochrome monitor helps you to debug applications that use graphics modes.
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/ulflist.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------------- 5 | ; 6 | ;Convert normal names to lower case and directory names to upper case. 7 | ; 8 | ;On Entry: 9 | ; 10 | ;ESI - pointer to file list. 11 | ; 12 | ;On Exit: 13 | ; 14 | ;ALL registers preserved. 15 | ; 16 | ;Most routines that need to display a file list want directory names in upper 17 | ;case and the remaining names in lower case. This routine formats a file list 18 | ;to that specification. Doing things this way means that if the file list is 19 | ;then sorted, directory names will appear at the top. 20 | ; 21 | ULFileList proc near 22 | pushm eax,ecx,esi,edi 23 | mov ecx,[esi] ;Get number of entries. 24 | jecxz l9 25 | add esi,4+256 26 | l0: test b[esi+13],16 ;Directory? 27 | jnz l4 28 | push esi 29 | mov edi,esi 30 | l1: lodsb 31 | or al,al 32 | jz l3 33 | cmp al,61h ; 'a' 34 | jb l2 35 | cmp al,7Ah ; 'z' 36 | ja l2 37 | and al,5Fh ;convert to upper case. 38 | l2: cmp al,"A" 39 | jc l5 40 | cmp al,"Z"+1 41 | jnc l5 42 | sub al,"A" 43 | add al,"a" 44 | l5: stosb 45 | jmp l1 46 | l3: pop esi 47 | l4: add esi,14 48 | loop l0 49 | l9: popm eax,ecx,esi,edi 50 | ret 51 | ULFileList endp 52 | 53 | 54 | efile 55 | end 56 | 57 | -------------------------------------------------------------------------------- /doc/page_99.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |14 - Memory structures destroyed. Program terminated.
11 | 12 |Generated if internal memory management structures become corrupted. This is caused by the CauseWay application 13 | writing to memory regions that have not been allocated to it and is a bug in the application. 14 | Obtain a corrected version of the application to fix this error.
15 | 16 |15 - DOS reported an error while accessing swap file. Program terminated.
17 | 18 |Generated if any level of error is detected while accessing the swap file. 19 | The swap file has probably been deleted inadvertently by the application or perhaps marked as read-only.
20 | 21 |16 - Unsupported DOS function call. Program terminated.
22 | 23 |The CauseWay application attempted to use an obsolete DOS function which used file control blocks (FCBs). 24 | Use the file handle DOS functions in the application instead.
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/dlgwhch.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | 5 | ;------------------------------------------------------------------------- 6 | ; 7 | ;Work out which section of a dialog the specified co-ords relate to. 8 | ; 9 | ;On Entry: 10 | ; 11 | ;ECX - X coord. 12 | ;EDX - Y coord. 13 | ;ESI - Dialog. 14 | ; 15 | ;On Exit: 16 | ; 17 | ;EAX - Entry number, -1 for none. 18 | ;ECX - Relative X coord. 19 | ;EDX - Relative Y coord. 20 | ; 21 | ;ALL other registers preserved. 22 | ; 23 | DialogWhich proc near 24 | pushm ebx,esi,edi,ebp 25 | mov ebx,ecx 26 | mov edi,esi 27 | add edi,size DlgMain 28 | xor ecx,ecx 29 | ; 30 | @@0: cmp Dlg_State[edi],-1 31 | jz @@9 32 | call DialogGetButtonX 33 | cmp ebx,eax 34 | jl @@1 35 | mov ebp,eax 36 | call DialogGetButtonW 37 | add eax,ebp 38 | cmp ebx,eax 39 | jge @@1 40 | call DialogGetButtonY 41 | cmp edx,eax 42 | jl @@1 43 | mov ebp,eax 44 | call DialogGetButtonD 45 | add eax,ebp 46 | cmp edx,eax 47 | jge @@1 48 | call DialogGetButtonX 49 | sub ebx,eax 50 | call DialogGetButtonY 51 | sub edx,eax 52 | mov eax,ecx 53 | mov ecx,ebx 54 | jmp @@10 55 | ; 56 | @@1: add edi,size Dlg 57 | inc ecx 58 | jmp @@0 59 | ; 60 | @@9: mov eax,-1 61 | @@10: popm ebx,esi,edi,ebp 62 | ret 63 | DialogWhich endp 64 | 65 | 66 | efile 67 | end 68 | 69 | -------------------------------------------------------------------------------- /doc/page_46.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 ||
12 | CWErrName Change error file name, with optional drive/pathspec |
13 |
Inputs: AX = 0ff32h
21 | 22 |CX:[E]DX = selector:offset of ASCIIZ error file name
23 | 24 |Outputs: None
25 |Errors: None
26 | 27 |Notes: If the error file name is invalid when a fault occurs, CauseWay defaults to using the standard CW.ERR file name in the current directory. The file name including any path and drive must not exceed 80 characters or it will be truncated. CX:EDX are not checked for validity and passing invalid values may cause a fault within the DOS extender. The ASCIIZ name pointed to by CX:EDX is copied to an internal DOS extender location and may be safely modified after calling the CWErrName function.
28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /doc/page_91.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |A second way of using WARPWRAP replaces multiple environment variables, as well as performs other tasks. You may specify a script definition file to list the environment variable and memory setting manipulations desired. Precede the script definition file with the at-sign (@). A default extension of .DEF is assigned if none is specified.
11 |For example:
12 |WW @STUFF MYPROG
13 |uses the contents of the definition file STUFF.DEF to modify the environment variables passed to MYPROG.EXE.
14 |If no environment setting or definition file name is listed (i.e. ! or @ does not precede an EXE file name), WARPWRAP defaults to using a definitions file called WARPWRAP.DEF. If WARPWRAP.DEF does not exist, WARPWRAP aborts processing.
15 |For example:
16 |WW MYPROG
17 |uses the contents of the definition file WARPWRAP.DEF to modify the environment variables passed to MYPROG.EXE.
18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/rmsbits.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------------ 5 | ; 6 | ;Re-map all bitmaps registered as useing "system" palette. 7 | ; 8 | ;On Entry: 9 | ; 10 | ;nothing. 11 | ; 12 | ;On Exit: 13 | ; 14 | ;nothing. 15 | ; 16 | ;ALL registers preserved. 17 | ; 18 | RemapSystemBitmaps proc near 19 | pushad 20 | ; 21 | ;Work out new translation table. 22 | ; 23 | mov esi,offset SystemPalette+3 24 | mov edi,offset HardwarePalette+3 25 | mov ebx,offset SystemXLat+1 26 | mov edx,1 27 | mov ecx,255 28 | l2: push ebx 29 | mov eax,d[esi] 30 | mov ebx,d[edi] 31 | shl eax,2 32 | and eax,0FFFFFFh 33 | shl ebx,2 34 | and ebx,0FFFFFFh 35 | cmp eax,ebx 36 | jz l3 37 | mov bl,al 38 | shr eax,8 39 | xchg ah,bl 40 | shl eax,8 41 | mov al,bl 42 | call SearchRGB 43 | jmp l4 44 | l3: mov eax,edx 45 | l4: pop ebx 46 | mov [ebx],al 47 | add esi,3 48 | add edi,3 49 | inc ebx 50 | inc edx 51 | dec ecx 52 | jnz l2 53 | ; 54 | ;Now re-map them. 55 | ; 56 | mov edi,BMTable 57 | mov ecx,MaxBMEntries 58 | l0: test BMT_Flags[edi],BMT_InUse ;This entry in use? 59 | jz l1 60 | call RemapSystemBitmap 61 | l1: add edi,size BMT 62 | dec ecx 63 | jnz l0 64 | ; 65 | popad 66 | ret 67 | RemapSystemBitmaps endp 68 | 69 | 70 | efile 71 | end 72 | 73 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/windows.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------- 5 | ; 6 | ;Initialise Window's stuff so base handler gets a lookin. 7 | ; 8 | WinInitialise proc near 9 | call CalculateSplits 10 | ret 11 | WinInitialise endp 12 | 13 | 14 | ;------------------------------------------------------------------------- 15 | ; 16 | ;Provides region clearing for the background when windows are closed. 17 | ; 18 | BaseHandler proc near 19 | cmp eax,WinMess_Draw 20 | jnz @@9 21 | push 32767 22 | push 32767 23 | push 0 24 | push 0 25 | xor eax,eax 26 | test VideoModeFlags,8 27 | jz @@0 28 | mov ax,0720h 29 | @@0: push eax 30 | push 0 31 | push esi 32 | call WinFillRectangle 33 | add esp,4*7 34 | @@9: ret 35 | BaseHandler endp 36 | 37 | 38 | sdata 39 | 40 | ;------------------------------------------------------------------------- 41 | ; 42 | ;Some variables common to several routines. 43 | ; 44 | BaseWindow Win <0,0,0,32767,32767,BaseHandler> 45 | ; 46 | WinWindowList label dword 47 | dd offset BaseWindow, MaxWinWindows dup (-1) 48 | ; 49 | WindowRegionFlag dd 0 ;Forced region clipping? 50 | WindowRegionX dd ? 51 | WindowRegionY dd ? 52 | WindowRegionW dd ? 53 | WindowRegionD dd ? 54 | ; 55 | FontBuffer label byte 56 | db 1024 dup (?) 57 | 58 | 59 | efile 60 | end 61 | 62 | -------------------------------------------------------------------------------- /src/cwd/macros.inc: -------------------------------------------------------------------------------- 1 | b equNext, protected mode interrupt vectors are listed with the following headings:
11 |No sel offset
12 |Where:
13 |No Vector number.
14 |sel Selector value for handler.
15 |offset Offset value for handler.
16 |This information allows a cross-reference with the other lists to ensure CauseWay application installed handlers have been properly made.
17 |Next, protected mode exception vectors are listed using the same format as protected mode interrupts.
18 |After the protected mode exception vector list, real mode interrupt vectors are listed. They are shown in the same format as protected mode interrupts although the selector values are real mode segment values.
19 |Only those interrupt and exception vectors altered by the program will be listed.
20 |Lastly, Call-Backs are listed in the CW.ERR file. They list all active Call-Backs for the active application at the time of its termination.
21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/bmxflp.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | 5 | ;------------------------------------------------------------------------------ 6 | ; 7 | ;Flip a bitmap from left to right, eg, around Y axis, but affecting it in the X 8 | ; 9 | ;On Entry: 10 | ; 11 | ;ESI - bitmap 12 | ; 13 | ;On Exit: 14 | ; 15 | ;nothing. 16 | ; 17 | ;All registers preserved. 18 | ; 19 | BitmapXFlip proc near 20 | public BitmapXFlip 21 | pushad 22 | mov eax,BM_Wide[esi] 23 | dec eax 24 | mul BM_PWide[esi] 25 | mov ebp,eax 26 | add ebp,BM_PWide[esi] ;line width. 27 | add eax,size BM 28 | add eax,esi 29 | mov edi,eax ;point to end of first line. 30 | mov ecx,BM_Wide[esi] 31 | shr ecx,1 ;width to process. 32 | mov edx,BM_Depth[esi] 33 | mov ebx,BM_PWide[esi] 34 | add esi,size BM ;point to start of first line. 35 | @@0: pushm ecx,esi,edi 36 | @@1: cmp ebx,3 37 | jz @@24bit 38 | cmp ebx,2 39 | jz @@16bit 40 | @@8bit: mov al,[esi] 41 | xchg al,[edi] 42 | mov [esi],al 43 | jmp @@2 44 | @@16bit: mov ax,[esi] 45 | xchg ax,[edi] 46 | mov [esi],ax 47 | jmp @@2 48 | @@24bit: mov ax,[esi+0] 49 | xchg ax,[edi+0] 50 | mov [esi+0],ax 51 | mov al,[esi+2] 52 | xchg al,[edi+2] 53 | mov [esi+2],al 54 | @@2: add esi,ebx 55 | sub edi,ebx 56 | dec ecx 57 | jnz @@1 58 | popm ecx,esi,edi 59 | add esi,ebp 60 | add edi,ebp 61 | dec edx 62 | jnz @@0 63 | popad 64 | ret 65 | BitmapXFlip endp 66 | 67 | 68 | efile 69 | end 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /doc/page_41.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |Note that the internal 8K buffer is optimized for file transfers. Average file transfers of greater than 8K will not necessarily improve performance with an increase in the buffer size. Generally speaking, the average file transfer must be 32K or larger to gain any efficiency with an increased buffer size. Also, if you are using virtual memory, increasing the buffer size may actually slow down performance due to the decreased available physical memory. Test your application with both the default buffer and the desired new buffer size before permanently increasing the buffer size beyond the default.
11 |API MEMORY ALLOCATION
12 |Inveterate tweakers may try out the SetMCBMax and GetMCBSize functions in the CauseWay API. These functions allow fine-tuning of the threshold used by CauseWay to allocate memory via a memory pool using memory control blocks (MCBs) rather than via normal DPMI functions. Since DPMI allocates memory in multiples of 4K, setting the MCB threshold too low may result in a good deal of wasted memory and subsequent performance degradation.
13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /doc/page_109.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |d.Do not attempt to write to or read from the NULL (zero value) segment. Attempts to do so results in a fault. In addition to valid selector values, segment registers can be safely loaded with a value of 0 but this selector value cannot be used to access memory or execute code.
11 | 12 |2.Do not execute code in a data segment and do not write to data in the code segment. Use the CauseWay AliasSel function to map a data selector to the same physical memory area shared by a code selector when necessary. Even in this case, however, never write to memory using a CS: code segment override because it always causes a processor fault.
13 |3.CauseWay handles most of the standard DOS interrupts transparently. When passing pointers to buffers for software interrupt calls not handled by CauseWay, create the buffers in low (conventional) DOS memory using the GetMemDOS function of the CauseWay API. In addition, convert the pointers from protected mode selector:offset pairs to real mode segment:offset pairs prior to the interrupt, and back upon your return from the interrupt.
14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /samples/version.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ;Example to detect if running under CauseWay and to get version if so. 3 | ; 4 | 5 | .model small 6 | .386 7 | .stack 1024 8 | 9 | .code 10 | 11 | start proc near 12 | mov ax,DGROUP 13 | mov ds,ax 14 | 15 | ; 16 | ;Get CauseWay API interrupt vector address. 17 | ; 18 | mov ax,3531h 19 | int 21h 20 | ; 21 | ;Check segment/selector isn't zero. 22 | ; 23 | mov ax,es 24 | or ax,ax 25 | jz @@NotCauseway 26 | ; 27 | ;Move back to where the CauseWay ID should be and check for it. 28 | ; 29 | ;CauseWay API handler is preceded by: 30 | ; 31 | ; DB "CAUSEWAY" 32 | ; DB MajorVersion 33 | ; DB MinorVersion 34 | ; 35 | ;MajorVersion is in the range 0-255 36 | ;MinorVersion is in the range 0-99 37 | ; 38 | ;Both version numbers are binary, ie, NOT ASCII or BCD. 39 | ; 40 | sub bx,10 41 | cmp es:dword ptr[bx],"SUAC" 42 | jnz @@NotCauseway 43 | cmp es:dword ptr[bx+4],"YAWE" 44 | jnz @@NotCauseway 45 | ; 46 | ;Running under CauseWay so let the user know. 47 | ; 48 | mov dx,offset IsCauseWayText 49 | mov ah,9 50 | int 21h 51 | jmp @@Done 52 | ; 53 | ;Not running under CauseWay so let the user know. 54 | ; 55 | @@NotCauseway: mov dx,offset NotCauseWayText 56 | mov ah,9 57 | int 21h 58 | ; 59 | ;Exit to DOS/CauseWay 60 | ; 61 | @@Done: mov ax,4c00h 62 | int 21h 63 | start endp 64 | 65 | .data 66 | 67 | IsCauseWayText db "Running under CauseWay.",13,10,"$" 68 | NotCauseWayText db "Not running under CauseWay.",13,10,"$" 69 | 70 | end start 71 | -------------------------------------------------------------------------------- /samples/DLLTESTA/dllapp1.asm: -------------------------------------------------------------------------------- 1 | 2 | ;--- dll sample in assembly, using C wrapper functions in dllfunc.obj. 3 | ;--- run mdllapp1.bat to create the binaries. 4 | 5 | .386 6 | .model flat 7 | ; .dosseg 8 | .const ;ensures that wlink puts CONST before STACK 9 | .stack 10 | 11 | LoadModule proto c :ptr 12 | GetProcAddress proto c :dword, :ptr 13 | FreeModule proto c :dword 14 | 15 | CStr macro text:vararg 16 | local sym 17 | .const 18 | sym db text,0 19 | .code 20 | exitm|
12 | SetVect Set Protected mode interrupt handler address. |
13 |
Inputs: AX = 0205h
17 |BL= Interrupt vector number.
18 |CX:[E]DX = selector:offset of new handler.
19 |Outputs: None.
20 |Errors: None.
21 | 22 ||
24 | UnLockMem Unlock a region of memory. |
25 |
Inputs: AX = 0ff1dh
29 |BX:CX = Starting linear address of memory to unlock
30 |SI:DI = Size of region to unlock in bytes
31 |Outputs: Carry set on error.
32 | 33 | 34 | 35 |Errors: If any of the memory region specified is invalid this function returns carry set.
36 |Notes: This function allows the unlocked memory to be swapped to disk by the VMM if necessary. Areas below and above the specified memory to the nearest 4K boundary are unlocked if the specified region is not aligned to a 4K boundary.
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/cwem/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # there are 2 variants: 3 | # CWEM.EXE is a CauseWay app. Needs text macro CWAPP to be defined in Masm 4 | # and WL32 linker ( with options /f and /ds ) 5 | # 6 | # CWEMJ.EXE: is a HX binary, using jwlink. 7 | 8 | !ifndef DEBUG 9 | DEBUG=0 10 | !endif 11 | 12 | NAME=CWEM 13 | NAME2=CWMAKE 14 | 15 | ASM=ml.exe 16 | 17 | !if $(DEBUG) 18 | AOPTD = /D_DEBUG 19 | ODIR=Debug 20 | !else 21 | AOPTD = 22 | ODIR=Build 23 | !endif 24 | 25 | #all: Build\cw.exe Build\cwmake.exe 26 | all: $(ODIR) $(ODIR)\$(NAME).exe $(ODIR)\$(NAME)j.exe $(ODIR)\$(NAME2).exe 27 | 28 | $(ODIR): 29 | mkdir $(ODIR) 30 | 31 | $(ODIR)\$(NAME).exe: $(ODIR)\$(NAME).obj 32 | @wl32 /q/m/ds $(ODIR)\$(NAME).obj; 33 | 34 | $(ODIR)\$(NAME).obj: $(NAME).asm general.inc 35 | @$(ASM) /c /DCWAPP /nologo $(AOPTD) /Fl$(ODIR)\ /Fo$(ODIR)\ $(NAME).asm 36 | 37 | $(ODIR)\$(NAME2).exe: $(ODIR)\$(NAME2).obj 38 | @wl32 /q/ex/m/cs/non $(ODIR)\cwmake.obj,,$(ODIR)\cwmake.map 39 | 40 | $(ODIR)\$(NAME2).obj: $(NAME2).asm general.inc 41 | @$(ASM) /c /nologo $(AOPTD) /Fl$(ODIR)\ /Fo$(ODIR)\ $(NAME2).asm 42 | 43 | $(ODIR)\$(NAME)j.exe: $(ODIR)\$(NAME)j.obj 44 | @jwlink format win pe hx f $(ODIR)\$(NAME)j.obj n $(ODIR)\$(NAME)j.exe op q,m=$(ODIR)\$(NAME)j.map,stub=loadpero.bin 45 | 46 | $(ODIR)\$(NAME)j.obj: $(NAME).asm 47 | @jwasm /c /nologo $(AOPTD) /Fl$(ODIR)\$(NAME)j.lst /Fo$(ODIR)\$(NAME)j.obj $(NAME).asm 48 | 49 | clean: 50 | @del $(ODIR)\*.obj 51 | @del $(ODIR)\*.exe 52 | @del $(ODIR)\*.map 53 | @del $(ODIR)\*.lst 54 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/regsbit.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------- 5 | ; 6 | ;Register a bitmap that needs to be re-mapped whenever the hardware palette 7 | ;changes so it stays in the system palette scheme. 8 | ; 9 | ;On Entry: 10 | ; 11 | ;ESI - bitmap. 12 | ; 13 | ;On Exit: 14 | ; 15 | ;EAX - handle. 16 | ; 17 | ;ALL other registers preserved. 18 | ; 19 | RegisterSystemBitmap proc near 20 | pushm ebx,ecx,edx,esi,edi,ebp 21 | ; 22 | ;Find a free table entry. 23 | ; 24 | mov edi,BMTable 25 | mov ecx,MaxBMEntries 26 | l0: test BMT_Flags[edi],BMT_InUse ;This entry in use? 27 | jz l1 28 | add edi,(size BMT) 29 | dec ecx 30 | jnz l0 31 | jmp l9_2 32 | ; 33 | l1: mov BMT_Pointer[edi],esi 34 | mov BMT_Flags[edi],BMT_InUse ;Mark this entry as used. 35 | ; 36 | ;Need to claim memory block to duplicate this bitmap 37 | ;for future remaps. 38 | ; 39 | pushm esi,edi 40 | mov eax,BM_Wide[esi] ;get bitmap dimensions. 41 | mul BM_Depth[esi] 42 | mov ecx,eax 43 | call Malloc 44 | mov eax,esi 45 | popm esi,edi 46 | jc l9_1 47 | mov BMT_Duplicate[edi],eax 48 | push edi 49 | mov edi,eax 50 | add esi,size BM ;skip its header. 51 | rep_movsb ;make a copy of it. 52 | pop edi 53 | mov eax,edi 54 | ; 55 | call RemapSystemBitmap ;now re-map it. 56 | jmp exit 57 | ; 58 | l9_1: mov BMT_Flags[edi],0 ;Clear flags again. 59 | l9_2: xor eax,eax 60 | ; 61 | exit: popm ebx,ecx,edx,esi,edi,ebp 62 | ret 63 | RegisterSystemBitmap endp 64 | 65 | 66 | efile 67 | end 68 | 69 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/regupw.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------------- 5 | ; 6 | ;Update a particular rectangle of the display. 7 | ; 8 | ;On Entry: 9 | ; 10 | ;ECX - X coord. 11 | ;EDX - Y coord. 12 | ;ESI - width. 13 | ;EDI - depth. 14 | ; 15 | ;On Exit: 16 | ; 17 | ;nothing. 18 | ; 19 | ;ALL registers preserved. 20 | ; 21 | WindowRegionUpdate: 22 | public WindowRegionUpdate 23 | _WindowRegionUpdate_ proc syscall 24 | local @@Count:dword, @@Handle:dword 25 | pushad 26 | push WindowRegionFlag 27 | push WindowRegionX 28 | push WindowRegionY 29 | push WindowRegionW 30 | push WindowRegionD 31 | ; 32 | mov WindowRegionFlag,-1 33 | mov WindowRegionX,ecx 34 | mov WindowRegionW,ecx 35 | mov WindowRegionY,edx 36 | mov WindowRegionD,edx 37 | add WindowRegionW,esi 38 | add WindowRegionD,edi 39 | ; 40 | mov @@Count,MaxWinWindows 41 | mov @@Handle,offset WinWindowList 42 | ; 43 | @@0: mov ebx,@@Handle 44 | mov ebx,[ebx] 45 | cmp ebx,-1 46 | jz @@1 47 | mov ecx,Win_XCoord[ebx] 48 | mov edx,Win_YCoord[ebx] 49 | mov esi,Win_Wide[ebx] 50 | mov edi,Win_Depth[ebx] 51 | call WindowRegionClip 52 | jnz @@1 53 | ; 54 | mov esi,ebx 55 | mov eax,WinMess_Draw 56 | call WinMessageWindow 57 | ; 58 | @@1: add @@Handle,4 59 | dec @@Count 60 | jnz @@0 61 | ; 62 | pop WindowRegionD 63 | pop WindowRegionW 64 | pop WindowRegionY 65 | pop WindowRegionX 66 | pop WindowRegionFlag 67 | popad 68 | ret 69 | _WindowRegionUpdate_ endp 70 | 71 | 72 | efile 73 | end 74 | 75 | -------------------------------------------------------------------------------- /samples/Readme.txt: -------------------------------------------------------------------------------- 1 | 2 | various CauseWay samples 3 | 4 | - AliasSel.asm: shows how to create a code alias. 5 | - CallBack.asm: allocating and using a real-mode callback. 6 | - DllTest: causeway dll support for C (Open Watcom). 7 | - DllTestA: causeway dll support for assembly (Masm style). 8 | - DosShell.asm: show how to launch a DOS shell from a CauseWay app. 9 | - flat.asm: a minimal sample for FLAT memory model (Masm syntax). 10 | - IntAsm.asm: demonstration how to use int 31h, ax=300h (simulate real-mode interrupt) 11 | - MultFlat.asm: not functional 12 | - MultNear.asm: sample how to mix 16- and 32-bit segments 13 | - Screen.asm: showing usage of the peculiar NEAR model of WL32. 14 | - ShowEVar.asm: display environment variables. 15 | - Small32.asm: minimal sample for 32-bit SMALL model (Masm syntax). 16 | - Timer.asm: demonstrates installing an interrupt handler. 17 | - Tiny16.asm: minimal sample for 16-bit TINY model (Masm syntax). 18 | - Tiny32.asm: minimal sample for 32-bit TINY model (Masm syntax). 19 | - Version.asm: shows how to get the CauseWay version. 20 | - Vesa.asm: VESA support to be used by OW apps. 21 | 22 | - Croak1.c: force an exception - show how to use CauseWay's "user dump" feature. 23 | - Croak2.c: force an exception - show how to use CauseWay's "user dump" feature. 24 | - Croak3.c: force an exception - show how to use CauseWay's "user dump" feature. 25 | - Intc.c: demonstrates how to call int 31h, ax=300h in C. 26 | - TestTerm.c: shows CauseWay's UserErrTerm and SetDump features. 27 | -------------------------------------------------------------------------------- /doc/page_57.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 ||
12 | IntXX Simulate real mode interrupt. |
13 |
Inputs: AX = 0ff01h
17 |BL= Interrupt number.
18 |ES:[E]DI = Real mode register list.
19 |Outputs: Register list updated.
20 |Errors: None.
21 | 22 | 23 | 24 |Notes: The real mode register list referenced by ES:[E]DI should contain the register values you want passed to the real mode interrupt handler. CauseWay fills in the SS:SP and Flags values to ensure that legal values are used and the CS:IP entries are ignored. This function bypasses protected mode interrupt handlers and provides access to INT APIs that require segment pointers.
25 | 26 | 27 | 28 ||
30 | Linear2Near Convert linear address to application relative address. |
31 |
Inputs: AX = 0ff19h
35 |ESI = Linear address to convert.
36 |Outputs: ESI = Application relative linear address.
37 |Errors: None
38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/crbtmp.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | 5 | ;------------------------------------------------------------------------------ 6 | ; 7 | ;Create a new bitmap. 8 | ; 9 | ;On Entry: 10 | ; 11 | ;EBX - bitmap flags entry. 12 | ;ECX - bitmap width. 13 | ;EDX - bitmap depth. 14 | ; 15 | ;On Exit: 16 | ; 17 | ;Carry set on error and EAX=0 else, 18 | ; 19 | ;EAX - pointer to bitmap. 20 | ; 21 | ;ALL other registers preserved. 22 | ; 23 | CreateBitmap proc near 24 | pushm ebx,ecx,edx,esi,edi 25 | pushm ebx,ecx,edx 26 | xor eax,eax ;Work out bytes per pixel 27 | inc eax ;needed and how much memory 28 | and ebx,15 ;we need to allocate. 29 | jz @@0 ;8-bit? 30 | inc eax 31 | cmp ebx,2+1 ;15- or 16-bit? 32 | jc @@0 33 | inc eax ;must be 24-bit then. 34 | @@0: mov edi,eax 35 | mul edx 36 | mul ecx 37 | add eax,size BM ;allow for header. 38 | add eax,256*3 ;leave space for 256 colour palette. 39 | add eax,256 ;leave space for path. 40 | mov ecx,eax 41 | call Malloc ;try and allocate the memory. 42 | popm ebx,ecx,edx 43 | jc @@9 44 | mov BM_Flags[esi],ebx 45 | mov BM_PWide[esi],edi 46 | mov BM_Wide[esi],ecx 47 | mov BM_Depth[esi],edx 48 | mov BM_XOffset[esi],0 49 | mov BM_YOffset[esi],0 50 | ; 51 | mov eax,BM_PWide[esi] 52 | mul BM_Wide[esi] 53 | mul BM_Depth[esi] 54 | add eax,esi 55 | add eax,size BM 56 | mov edi,eax 57 | push esi 58 | mov esi,offset HardwarePalette 59 | mov ecx,256*3 60 | rep movsb 61 | pop esi 62 | ; 63 | clc 64 | @@9: mov eax,esi 65 | popm ebx,ecx,edx,esi,edi 66 | ret 67 | CreateBitmap endp 68 | 69 | 70 | efile 71 | end 72 | 73 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/whichw.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------- 5 | ; 6 | ;See which (if any) window co-ords fall inside and return relative values 7 | ; 8 | ;On Entry: 9 | ; 10 | ;ECX - Xcoord 11 | ;EDX - Ycoord 12 | ; 13 | ;On Exit: 14 | ; 15 | ;EAX - Window structure pointer (handle), -1 for none. 16 | ;ECX - relative X coord. 17 | ;EDX - relative Y coord. 18 | ; 19 | ;ALL other registers preserved. 20 | ; 21 | WinWhichWindow: 22 | public WinWhichWindow 23 | _WinWhichWindow_ proc syscall 24 | local @@window:dword, @@X:dword, @@Y:dword 25 | pushad 26 | ; 27 | mov @@X,ecx 28 | mov @@Y,edx 29 | mov esi,offset WinWindowList 30 | mov ecx,MaxWinWindows 31 | @@0: cmp d[esi],-1 32 | jz @@8 33 | ; 34 | push esi 35 | mov esi,[esi] 36 | mov edx,esi 37 | lea esi,Win_Splits[esi] 38 | @@1: cmp Split_Wide[esi],0 39 | jz @@7 40 | mov eax,Split_XCoord[esi] 41 | cmp eax,@@X 42 | jg @@6 43 | add eax,Split_Wide[esi] 44 | cmp eax,@@X 45 | jl @@6 46 | mov eax,Split_YCoord[esi] 47 | cmp eax,@@Y 48 | jg @@6 49 | add eax,Split_Depth[esi] 50 | cmp eax,@@Y 51 | jl @@6 52 | mov eax,@@X 53 | sub eax,Win_XCoord[edx] 54 | mov @@X,eax 55 | mov eax,@@Y 56 | sub eax,Win_YCoord[edx] 57 | mov @@Y,eax 58 | mov @@window,edx 59 | pop esi 60 | jmp @@9 61 | ; 62 | @@6: add esi,size Split 63 | jmp @@1 64 | ; 65 | @@7: pop esi 66 | @@8: add esi,4 67 | loop @@0 68 | mov @@window,-1 69 | @@9: popad 70 | mov eax,@@window 71 | mov ecx,@@X 72 | mov edx,@@Y 73 | ret 74 | _WinWhichWindow_ endp 75 | 76 | 77 | efile 78 | end 79 | 80 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/closew.asm: -------------------------------------------------------------------------------- 1 | 2 | include ..\cwlib.inc 3 | scode 4 | 5 | ;------------------------------------------------------------------------- 6 | ; 7 | ;Close a window and update the area underneath it if possible. 8 | ; 9 | ;On Entry: 10 | ; 11 | ;EAX - Pointer to window structure (handle). 12 | ; 13 | ;On Exit: 14 | ; 15 | ;nothing. 16 | ; 17 | ;ALL registers preserved. 18 | ; 19 | WinCloseWindow: 20 | public WinCloseWindow 21 | _WinCloseWindow_ proc syscall 22 | local @@XCoord:dword, @@YCoord:dword, @@Wide:dword, @@Depth:dword 23 | pushad 24 | mov esi,eax 25 | ; 26 | ;Let the windows handler know its being closed incase it wants to do something. 27 | ; 28 | mov eax,WinMess_Close 29 | call WinMessageWindow 30 | ; 31 | ;Find the window in the main list. 32 | ; 33 | @@2: mov edi,offset WinWindowList 34 | mov ecx,MaxWinWindows 35 | @@0: cmp [edi],esi 36 | jz @@1 37 | add edi,4 38 | loop @@0 39 | jmp @@9 40 | ; 41 | ;Delete list entry and retrieve coords. 42 | ; 43 | @@1: mov d[edi],-1 ;Remove it from the list. 44 | mov eax,Win_XCoord[esi] 45 | mov @@XCoord,eax 46 | mov eax,Win_YCoord[esi] 47 | mov @@YCoord,eax 48 | mov eax,Win_Wide[esi] 49 | mov @@Wide,eax 50 | mov eax,Win_Depth[esi] 51 | mov @@Depth,eax 52 | call Free ;Release window's memory. 53 | ; 54 | ;Now we try and re-build what was under this window. 55 | ; 56 | call CalculateSplits ;calculate splits again. 57 | mov ecx,@@XCoord 58 | mov edx,@@YCoord 59 | mov esi,@@Wide 60 | mov edi,@@Depth 61 | call WindowRegionUpdate ;Update this area of the display. 62 | ; 63 | @@9: popad 64 | ret 65 | _WinCloseWindow_ endp 66 | 67 | 68 | efile 69 | end 70 | 71 | -------------------------------------------------------------------------------- /doc/page_84.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |CWD OPTIONS
|
13 | /dm Use a monochrome monitor for output from CWD. |
14 |
|
16 | /eSYMBOL Run the program until SYMBOL is reached. |
17 |
CS:EIP WINDOW
22 |The quick help bar shows most of the available keypresses across the bottom of the screen. To move within the current view, use the cursor keys but remember that this doesn't alter the code in the CS:EIP window.
23 |The current CS:EIP position is marked by a greater than (>) symbol as well as a green bar.
24 |The current display position is marked by a blue bar.
25 |Breakpoints are marked with an asterisk (*) symbol and a red bar with a countdown value in brackets to the right of the asterisk. Note that a countdown value of 0 means the breakpoint will trigger next time the code at the breakpoint address is executed. A value of 1 means the count will be decremented next time the breakpoint address is encountered but another pass will be needed to trigger a break.
26 |Register values are highlighted when changed by the application or operator.
27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/srchrgb.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------- 5 | ; 6 | ;Find closest match in HardwarePalette to RGB value specified. Must be more 7 | ;accurate ways of doing it than this but I don't know about them! 8 | ; 9 | ;On Entry: 10 | ; 11 | ;EAX - RGB value. 12 | ; 13 | ;On Exit: 14 | ; 15 | ;EAX - Nearest pen value in HardwarePalette 16 | ; 17 | SearchRGB: 18 | public SearchRGB 19 | _SearchRGB_ proc syscall 20 | local @@Pen:byte, @@Chosen:byte, @@Count:dword, @@Data:dword 21 | pushad 22 | mov @@Pen,0 23 | mov @@Chosen,0 24 | mov @@Count,256 25 | ; 26 | ;Put bytes into right order for memory variable. 27 | ; 28 | mov bl,al 29 | shr eax,8 30 | xchg ah,bl 31 | shl eax,8 32 | mov al,bl 33 | mov @@Data,eax 34 | lea edi,@@Data 35 | ; 36 | ;Scale 0-255 values to suit VGA DAC 0-63 values. 37 | ; 38 | shr b[edi+0],2 39 | shr b[edi+1],2 40 | shr b[edi+2],2 41 | ; 42 | ;Now find the nearest match. 43 | ; 44 | mov esi,offset HardwarePalette 45 | mov ecx,0FFFFFFh 46 | l0: xor edx,edx 47 | movzx eax,b[0+esi] 48 | movzx ebx,b[0+edi] 49 | sub eax,ebx 50 | jns l1 51 | neg eax 52 | l1: add eax,eax 53 | add edx,eax 54 | ; 55 | movzx eax,b[1+esi] 56 | movzx ebx,b[1+edi] 57 | sub eax,ebx 58 | jns l2 59 | neg eax 60 | l2: add eax,eax 61 | add edx,eax 62 | ; 63 | movzx eax,b[2+esi] 64 | movzx ebx,b[2+edi] 65 | sub eax,ebx 66 | jns l3 67 | neg eax 68 | l3: add eax,eax 69 | add edx,eax 70 | ; 71 | cmp edx,ecx 72 | jnc l4 73 | mov ecx,edx 74 | mov al,@@Pen 75 | mov @@Chosen,al 76 | l4: add esi,3 77 | inc @@pen 78 | dec @@Count 79 | jnz l0 80 | ; 81 | popad 82 | movzx eax,@@Chosen 83 | ret 84 | _SearchRGB_ endp 85 | 86 | 87 | efile 88 | end 89 | 90 | 91 | -------------------------------------------------------------------------------- /doc/page_62.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 ||
12 | RelSel Release a selector. |
13 |
Inputs: AX = 0ff04h
17 |BX = Selector.
18 |Outputs: Carry set on error.
19 | 20 | 21 | 22 |Errors: If an invalid selector is passed in BX, this function returns with carry set.
23 |Notes: Use this function to release selectors allocated by GetSel or AliasSel.
24 | 25 | 26 | 27 ||
29 | ResMem Resize a previously allocated block of memory. |
30 |
Inputs: AX = 0ff0dh
34 |BX = Selector for block.
35 |CX:DX = New size of block required in bytes.
36 |Outputs: Carry set on error.
37 | 38 | 39 | 40 |Errors: If an invalid selector is passed in BX or not enough memory is available when increasing the block size, then this function returns carry set.
41 |Notes: If the memory block cannot be resized in its current location, but a free block of memory of the new size exists, the memory is copied to a new block and the old one is released. The application is not affected as long as only the selector originally allocated with GetMem accesses the memory.
42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /doc/page_70.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 ||
12 | UnLockMem32 Unlock a region of memory. |
13 |
Inputs: AX = 0ff1eh
17 |ESI = Starting linear address of memory to unlock
18 |ECX = Size of region to unlock in bytes
19 |Outputs: Carry set on error.
20 |Errors: See UnLockMem
21 | 22 | 23 |Notes: This function allows the memory to be swapped to disk by the VMM if necessary. Areas below and above the specified memory to the nearest 4K boundary are unlocked if the specified region is not aligned to a 4K boundary.
24 | 25 | 26 ||
28 | UnLockMemNear Unlock a region of memory using application relative address. |
29 |
Inputs: AX = 0ff20h
33 |ESI = Starting linear address of memory to unlock
34 |EBX = Size of region to unlock in bytes
35 |Outputs: Carry set on error.
36 |Errors: See UnLockMem
37 | 38 | 39 | 40 |Notes: This function allows the memory to be swapped to disk by the VMM if necessary. Areas below and above the specified memory to the nearest 4K boundary are unlocked if the specified region is not aligned to a 4K boundary.
41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/cwem/cwem.cfg: -------------------------------------------------------------------------------- 1 | ; 2 | ;Define the text that marks the start of segment definitions. This is searched 3 | ;for to make sure we start in the right place. Single space will do in place of 4 | ;multiple space/tab, only the words and the fact that they have a space 5 | ;is significant. 6 | ; 7 | SegmentHeader=start stop length name class 8 | 9 | 10 | ; 11 | ;Define the layout of segment definitions. The names used are 386Prep variables. 12 | ;There is no relationship between this and SegmentHeader. Only Null, Start, 13 | ;Length & Class are currently defined. This tells 386Prep which column to find 14 | ;each piece of information. 15 | ; 16 | SegmentFormat=Start Null Length Null Class 17 | 18 | 19 | 20 | ; 21 | ;Define CODE type class's. List of CLASS names that need to be defined as code 22 | ;execute/read segments. Multiple entries should be seperated by space. 23 | ; 24 | CodeClass=*code* 25 | 26 | 27 | 28 | ; 29 | ;Define DATA type class's. List of CLASS names that need to be defined as data 30 | ;read/write segments. Multiple entries should be seperated by space. 31 | ; 32 | DataClass=*bss* 33 | DataClass=*data* 34 | 35 | 36 | 37 | 38 | ; 39 | ;Define STACK type class's. List of CLASS names that need to be defined as stack 40 | ;segments. Multiple entries should be seperated by space. 41 | ; 42 | StackClass=*stack* 43 | 44 | 45 | 46 | ; 47 | ;Define CONST type class's. List of CLASS names that need to be defined as data 48 | ;read only segments. Multiple entries should be seperated by space. 49 | ; 50 | ConstClass=*const* 51 | 52 | 53 | ; 54 | ;Define NEAR type class's. List of CLASS names that need to be defined as both 55 | ;code & data. Multiple entries should be seperated by space. 56 | ; 57 | NearClass=*near* 58 | -------------------------------------------------------------------------------- /doc/page_94.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |WARPWRAP EXAMPLES
11 |Two files that are included on the CauseWay distribution disk, SHOWEVAR.ASM and SHOWEVAR.OBJ, demonstrate WARPWRAP's operations. SHOWEVAR.ASM is the source code to a small assembly language program that displays the current environment variables passed to it. SHOWEVAR.ASM was included for reference purposes to illustrate what the SHOWEVAR program does. It is not needed for testing WARPWRAP.
12 |Link SHOWEVAR.OBJ to the executable file SHOWEVAR.EXE for use with WARPWRAP. You must relink SHOWEVAR.OBJ to try a new WARPWRAP setting because you cannot restore a WARPWRAP- modified EXE file to its former state.
13 |Another file included on the CauseWay distribution disk, WARPWRAP.DEF, demonstrates many of the features one might find in a WARPWRAP script definition file. Since this is the default script definition file name, it can be used by WARPWRAP two ways. Use the following format on the command line:
14 |WW <EXE program>
15 |Within a program, use the following format to explicitly call WARPWRAP:
16 |WW @WARPWRAP <EXE program>
17 |<EXE program> is the name of the EXE file to modify.
18 |Refer to the WARPWRAP.DEF file included with CauseWay for a few tips about using script definition files.
19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/openw.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------- 5 | ; 6 | ;Initialise a window structure and add it to the list of windows in service. 7 | ; 8 | ;On Entry: 9 | ; 10 | ;C style stack parameters as follows: 11 | ; 12 | ;flags - undefined at the moment, set to zero. 13 | ;priority - priority to assign. 14 | ;xcoord - x co-ord for window. 15 | ;ycoord - y co-ord for window. 16 | ;wide - width of window in pixels. 17 | ;depth - depth of window in pixels. 18 | ;handler - address of handler (0 for none). 19 | ; 20 | ;On Exit: 21 | ; 22 | ;EAX - pointer to window structure (handle). 23 | ; 24 | ;ALL other registers presereved. 25 | ; 26 | WinOpenWindow: 27 | _WinOpenWindow proc syscall flags:dword, priority:dword, xcoord:dword, \ 28 | ycoord:dword, wide:dword, depth:dword, handler:dword 29 | local @@Window:dword 30 | pushad 31 | mov ecx,size Win 32 | call Malloc 33 | mov @@Window,esi 34 | jc @@9 35 | mov eax,XCoord 36 | mov Win_XCoord[esi],eax 37 | mov eax,YCoord 38 | mov Win_YCoord[esi],eax 39 | mov eax,Wide 40 | mov Win_Wide[esi],eax 41 | mov eax,Depth 42 | mov Win_Depth[esi],eax 43 | mov eax,Priority 44 | mov Win_Priority[esi],eax 45 | mov eax,Handler 46 | mov Win_Handler[esi],eax 47 | lea edi,Win_Splits[esi] 48 | mov Split_Wide[edi],0 49 | ; 50 | mov edi,offset WinWindowList 51 | mov ecx,MaxWinWindows 52 | @@0: cmp d[edi],-1 53 | jz @@1 54 | add edi,4 55 | loop @@0 56 | ; 57 | mov esi,@@Window 58 | call Free 59 | mov @@Window,0 60 | jmp @@9 61 | ; 62 | @@1: mov [edi],esi 63 | call CalculateSplits 64 | ; 65 | mov eax,WinMess_Draw 66 | call WinMessageWindow 67 | ; 68 | @@9: popad 69 | mov eax,@@Window 70 | ret 71 | _WinOpenWindow endp 72 | 73 | 74 | efile 75 | end 76 | 77 | -------------------------------------------------------------------------------- /doc/page_68.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 ||
12 | SetRVect Set real mode interrupt handler address. |
13 |
Inputs: AX = 0201h
17 |BL= Interrupt vector number.
18 |CX:DX = selector:offset of new handler.
19 |Outputs: None.
20 |Errors: None.
21 | 22 ||
24 | SetSelDet Set selector linear base and limit. |
25 |
Inputs: AX = 0ff09h
29 |BX = Selector.
30 |CX:DX = Linear base.
31 |SI:DI = Byte granular limit.
32 |Outputs: Carry set on error.
33 | 34 | 35 | 36 |Errors: If an invalid selector is passed in BX, this function returns with carry set.
37 | 38 | 39 ||
41 | SetSelDet32 Set selector linear base and limit. |
42 |
Inputs: AX = 0ff0ah
46 |BX = Selector.
47 |EDX = Linear base.
48 |ECX = Byte granular limit.
49 |Outputs: Carry set on error.
50 | 51 | 52 | 53 |Errors: If an invalid selector is passed in BX, this function returns with carry set.
54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /doc/page_50.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 ||
12 | GetDOSTrans Get current address and size of the buffer used for DOS memory transfers. |
13 |
Inputs: AX = 0ff25h
17 |Outputs: BX = Real mode segment of buffer.
18 |DX = Protected mode selector for buffer.
19 |ECX = Buffer size
20 |Errors: None
21 | 22 | 23 | 24 |Notes: This buffer is used by the INT API translation services, e.g., INT 21h, AH=40h (write to file). The default buffer is 8K and uses memory that would otherwise be wasted. This default is sufficient for most file I/O but if you are writing a program that reads/writes large amounts of data you should consider allocating your own larger buffer and pass the buffer's address to CauseWay to speed file I/O.
25 | 26 | 27 | 28 ||
30 | GetEVect Get Protected mode exception handler address. |
31 |
Inputs: AX = 0202h
35 |BL= Exception vector number.
36 |Outputs: Carry set on error else,
37 |CX:[E]DX = selector:offset of handler.
38 | 39 | 40 | 41 |Errors: The number in BL must be in the range 0-1Fh. Anything outside this range returns carry set.
42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/_buffile.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------- 5 | ; 6 | ;Initialise file buffer. 7 | ; 8 | ;Calling: 9 | ; 10 | ;InitFileBuffer(handle); 11 | ; 12 | ;On Entry: 13 | ; 14 | ;handle - File handle. 15 | ; 16 | ;On Exit: 17 | ; 18 | ;ALL registers preserved. 19 | ; 20 | _InitFileBuffer proc syscall handle:dword 21 | public _InitFileBuffer 22 | push ebx 23 | mov ebx,handle 24 | call InitFileBuffer 25 | pop ebx 26 | ret 27 | _InitFileBuffer endp 28 | 29 | 30 | ;------------------------------------------------------------------------- 31 | ; 32 | ;Read a byte from the file buffer. 33 | ; 34 | ;Calling: 35 | ; 36 | ;ReadBufferByte(); 37 | ; 38 | ;On Entry: 39 | ; 40 | ;None 41 | ; 42 | ;On Exit: 43 | ; 44 | ;AH - Bytes read, ie, AH=0 indicates EOF or an error. 45 | ;AL - Byte read. 46 | ; 47 | ;High word of EAX is zero'd. 48 | ; 49 | ;eg, if AX=0 then EOF reached. 50 | ; 51 | ;Don't mix normal ReadFile call's with this call, they don't take account of 52 | ;each other. 53 | ; 54 | _ReadBufferByte proc syscall 55 | public _ReadBufferByte 56 | call ReadBufferByte 57 | movzx eax,ax 58 | ret 59 | _ReadBufferByte endp 60 | 61 | 62 | ;------------------------------------------------------------------------- 63 | ; 64 | ;Read a line of text from input file specified. 65 | ; 66 | ;Calling: 67 | ; 68 | ;ReadBufferLine(buffer); 69 | ; 70 | ;On Entry: 71 | ; 72 | ;buffer - Buffer to put line into. 73 | ; 74 | ;On Exit: 75 | ; 76 | ;EAX - Bytes read, 0 = EOF or error. 77 | ; 78 | _ReadBufferLine proc syscall buffer:dword 79 | public _ReadBufferLine 80 | pushm ecx,edi 81 | mov edi,buffer 82 | call ReadBufferLine 83 | mov eax,ecx 84 | popm ecx,edi 85 | ret 86 | _ReadBufferLine endp 87 | 88 | 89 | efile 90 | end 91 | 92 | 93 | -------------------------------------------------------------------------------- /doc/page_75.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |Chapter 10: INTERRUPT SERVICES
11 |EXTENDED OR ALTERED INTERRUPT SERVICES
12 |The size of register used by CauseWay's extended or modified interrupt services depends on the limit of the selector. 13 | Extended 32-bit registers are used for 32-bit sized selectors and 16-bit registers are used for selectors within 16-bits. 14 | To reflect this, the convention of an [E] in brackets is used before a listed register when it must be a 32-bit value with 15 | a 32-bit selector and a 16-bit value with a 16-bit selector.
16 |Required registers that are not specified in this list should be set up in the same way as required for normal DOS real 17 | mode operation. For INT APIs that are not listed and require segment pointers, either handle them using the CauseWay IntXX 18 | function or create your own interrupt translation code.
19 ||
21 | INT 10h |
22 |
10h sub function 02h, [E]DX instead of DX.
26 |10h sub function 09h, [E]DX instead of DX.
27 |10h sub function 12h, [E]DX instead of DX.
28 |10h sub function 17h, [E]DX instead of DX.
29 |13h [E]BP instead of BP.
30 |1Ch sub function 01h, [E]BX instead of BX.
31 |1Ch sub function 02h, [E]BX instead of BX.
32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/cwc/decstub.inc: -------------------------------------------------------------------------------- 1 | db 252,87,6,232,137,0,7,95,54,161,248,3,54,139,30,250 2 | db 3,209,235,209,216,209,235,209,216,209,235,209,216,209,235,209 3 | db 216,140,194,3,208,142,218,54,139,54,248,3,131,230,15,30 4 | db 86,139,76,6,131,198,27,11,201,116,35,86,30,6,139,68 5 | db 2,139,52,140,195,3,195,142,192,38,1,28,7,31,94,73 6 | db 131,198,4,117,226,140,216,5,0,16,142,216,235,217,94,31 7 | db 140,195,139,68,14,3,195,139,208,139,108,16,139,68,22,3 8 | db 195,46,163,203,1,139,68,20,46,163,201,1,54,142,6,252 9 | db 3,54,142,30,252,3,142,210,139,229,46,255,46,201,1,50 10 | db 237,138,76,3,184,1,0,211,224,72,46,163,80,1,128,233 11 | db 8,46,136,14,70,1,131,198,12,139,44,131,198,2,178,16 12 | db 138,242,19,237,254,202,117,6,139,44,70,70,138,214,115,9 13 | db 138,4,38,136,5,70,71,235,233,19,237,254,202,117,6,139 14 | db 44,70,70,138,214,115,65,51,201,19,237,254,202,117,6,139 15 | db 44,70,70,138,214,18,201,19,237,254,202,117,6,139,44,70 16 | db 70,138,214,18,201,128,193,2,51,192,138,4,70,72,120,16 17 | db 3,193,86,30,6,31,139,247,43,240,243,164,31,94,235,162 18 | db 138,4,70,65,243,170,235,154,19,237,254,202,117,6,139,44 19 | db 70,70,138,214,115,26,51,192,139,4,131,198,2,138,232,177 20 | db 4,211,232,138,205,131,225,15,128,193,2,72,121,194,235,208 21 | db 139,68,1,138,232,177,4,211,232,138,12,131,198,3,129,225 22 | db 255,15,131,193,2,72,121,168,131,249,18,115,179,128,249,4 23 | db 116,60,128,249,3,116,22,128,249,5,116,7,128,249,2,116 24 | db 87,235,85,50,237,138,12,70,243,164,233,53,255,129,254,0 25 | db 192,115,3,233,44,255,139,198,209,232,209,232,209,232,209,232 26 | db 83,140,219,3,195,142,216,131,230,15,91,233,20,255,129,255 27 | db 0,192,115,3,233,11,255,139,199,45,0,192,80,83,209,232 28 | db 209,232,209,232,209,232,140,195,3,195,142,192,91,88,43,248 29 | db 131,224,15,3,248,233,234,254,195,0,0,0,0 30 | -------------------------------------------------------------------------------- /doc/page_54.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 ||
12 | GetMemSO Allocate a block of memory with selector:offset |
13 |
Inputs: AX = 0ff2ch
17 |CX:DX = Size of block required in bytes
18 | 19 | 20 | 21 | 22 |Outputs: Carry set on error else,
23 | 24 |SI:DI = selector:offset of allocated memory
25 |Errors: See GetMem
26 | 27 |Notes: This function allocates a block of memory with an associated selector:offset. The allocation does not consume a selector on each call as does GetMem because a non-zero offset from an existing selector for this allocation type is returned. GetMemSO is useful for applications which make a large number of allocations where running out of selectors with GetMem could be a problem. A potential drawback is that memory accesses beyond the allocation boundary may go undetected since the selector is shared among several allocations. Also, resizing the block can change the selector:offset of the block.
28 | 29 | 30 | 31 ||
33 | GetRVect Get real mode interrupt handler address. |
34 |
Inputs: AX = 0200h
38 |BL= Interrupt vector number.
39 |Outputs: CX:DX = selector:offset of handler.
40 |Errors: None.
41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /doc/page_114.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |handle base length
12 |Where:
13 | 14 | 15 | 16 |handle Linear memory [de]allocation uses handles to control the blocks. This field is the block's handle.
17 |base Linear base address of the memory block.
18 | 19 |length Length of the block in bytes.
20 | 21 | 22 | 23 | 24 |The linear memory list ends with a display of the total linear memory allocated to the program, the real (rounded to 4K pages) memory allocated in parentheses, and finally the total number of memory blocks. For example:
25 |Total Linear memory: 000FEAC9 (001AA000) in 00000103 blocks
26 |Entries in the selector list that have Y under "mem" should have a corresponding entry in the linear memory list.
27 |Linear memory locks are listed after the linear memory block list and contain the following headings:
28 |base length
29 |Where:
30 |base Linear base of the locked region.
31 |limit Length of the locked region.
32 | 33 | 34 | 35 |NOTE:These values are passed by the program but the actual values have the base rounded down a page and the length rounded up a page to match 4K boundary restrictions on locking. The values are reported in CW.ERR without using a rounded format to make it easier to cross reference this list to the other lists in CW.ERR.
36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /doc/page_43.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |CAUSEWAY API
11 |CauseWay provides an API for C and assembly language programmers as an extension of the DPMI API via INT 31h. Including the file CW.INC allows easy access to this API through appropriately named functions. You may also call the CauseWay API directly with appropriate register setup.
12 |CauseWay also provides all of the DPMI 0.9 API services on systems without a true DPMI server.
13 |Some of the API services require pointers to a real mode register list. It's the standard 14 | DPMI format for real-mode code execution, as follows:
15 || dword | EDI |
| dword | ESI |
| dword | EBP |
| dword | Reserved |
| dword | EBX |
| dword | EDX |
| dword | ECX |
| dword | EAX |
| word | Flags |
| word | ES |
| word | DS |
| word | FS |
| word | GS |
| word | IP |
| word | CS |
| word | SP |
| word | SS |
The values are passed to the target routine without any interpretation of their contents. There is no need to set the high words of the extended register entries unless the target routine requires them.
35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/cwlib/cw.asm/_makflst.asm: -------------------------------------------------------------------------------- 1 | include ..\cwlib.inc 2 | scode 3 | 4 | ;------------------------------------------------------------------------------- 5 | ; 6 | ;Generate list of files that match a given file mask. Wild cards permitted. 7 | ; 8 | ;Calling: 9 | ; 10 | ;MakeFileList(filemask,attribs); 11 | ; 12 | ;On Entry: 13 | ; 14 | ;filemask - File name mask (can include a path). 15 | ;attribs - search attributes. 16 | ; 17 | ;On Exit: 18 | ; 19 | ;EAX - buffer with file names etc, EAX=0 if not enough memory. 20 | ; 21 | ;Each entry in the buffer will have the following format. 22 | ; 23 | ;13 bytes zero terminated ASCII file name (may be less) 24 | ; 1 byte file attribute (directory,vulume,hidden,system etc.) 25 | ; 26 | ; If you specify directories in the attribute search mask the names . & .. will 27 | ; be removed from the list to avoid making special checks for them. Anything 28 | ; that might have found these useful will have to have knowledge of its 29 | ; current path anyway. 30 | ; 31 | ; 32 | ;Attributes are as follows:- 33 | ; 34 | ; 5 4 3 2 1 0 35 | ; | | | | | | 36 | ; | | | | | \_ Read only. (1) 37 | ; | | | | \____ Hidden. (2) 38 | ; | | | \_______ System. (4) 39 | ; | | \__________ Label. (8) 40 | ; | \_____________ Directory. (16) 41 | ; \________________ Archive. (32) 42 | ; 43 | ; Bits 6-15 are reserved and may be used in the search mask, but bits 8-15 won't 44 | ; appear in the attributes for listed files. 45 | ; 46 | ; The first dword in the buffer is the number of entries. 47 | ; Next 256 bytes is the path to append the names to. 48 | ; 49 | _MakeFileList proc syscall filemask:dword, attribs:dword 50 | public _MakeFileList 51 | pushm ecx,edx 52 | mov edx,filemask 53 | mov ecx,attribs 54 | call MakeFileList 55 | popm ecx,edx 56 | ret 57 | _MakeFileList endp 58 | 59 | 60 | efile 61 | end 62 | 63 | 64 | -------------------------------------------------------------------------------- /doc/page_49.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 ||
12 | GetCallBack Allocate real mode call back address. |
13 |
Inputs: AX = 0303h
17 |DS:[E]SI = Call address.
18 |ES:[E]DI = Real mode register structure.
19 |Outputs: Carry set on error, else,
20 |CX:DX = Real mode address to trigger mode switch.
21 | 22 | 23 | 24 |Errors: Call-backs are a limited resource. Normally only 16 are available per virtual machine. Use them carefully and release them as soon as they are no longer required.
25 | 26 | 27 | 28 |Call-Back:Interrupts disabled.
29 |DS:[E]SI = Selector:Offset of real mode SS:SP.
30 |ES:[E]DI = Selector:Offset of real mode call structure.
31 |SS:[E]SP = Locked protected mode stack.
32 |All other registers undefined
33 | 34 | 35 | 36 |To return from call-back procedure, execute an IRET to return.
37 |ES:[E]DI = Selector:Offset of real mode call structure to restore.
38 |Notes: Real mode call-backs provide a means of switching from real mode to protected mode. This function returns a unique real mode address that when given control in real mode, switches to protected mode and passes control to the protected mode routine supplied at entry to this function. On entry to the protected mode code the real mode register structure contains all the real mode register values.
39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /doc/page_61.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 ||
12 | RelMemLinear32 Release previously allocated block of memory (linear address). |
13 |
Inputs: AX = 0ff15h
17 |ESI = Linear address of block to release.
18 |Outputs: Carry set on error.
19 |Errors: See RelMemLinear
20 | 21 ||
23 | RelMemNear Release previously allocated application relative block 24 |of memory. |
25 |
Inputs: AX = 0ff18h
29 |ESI = Application relative linear address of block to release.
30 |Outputs: Carry set on error.
31 | 32 | 33 | 34 |Errors: If the address passed in ESI is not a valid memory block this function returns carry set.
35 | 36 | 37 | 38 ||
40 | RelMemSO Release a block of memory allocated via GetMemSO. |
41 |
Inputs: AX = 0ff2eh
45 |SI:DI = Selector:offset of block to release
46 |Outputs: Carry set on error.
47 | 48 | 49 | 50 |Errors: If an invalid selector:offset is passed in SI:DI or the memory was not allocated via GetMemSO, then this function returns carry set.
51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /doc/page_58.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 ||
12 | LockMem Lock a region of memory. |
13 |
Inputs: AX = 0ff1bh
17 |BX:CX = Starting linear address of memory to lock.
18 |SI:DI = Size of region to lock in bytes.
19 |Outputs: Carry set on error.
20 | 21 |Errors: If any of the region specified is invalid or if not enough physical memory is available to fill the region specified, then none of the memory is locked and this function returns carry set.
22 |Notes: Memory that is locked cannot be swapped to disk by the VMM. Locking applies to memory on 4K boundaries. Therefore, areas of memory below and above the memory being locked are locked if the specified region is not aligned to a 4K boundary.
23 | 24 | 25 | 26 ||
28 | LockMem32 Lock a region of memory. |
29 |
Inputs: AX = 0ff1ch
33 |ESI = Starting linear address of memory to lock.
34 |ECX = Size of region to lock in bytes.
35 |Outputs: Carry set on error.
36 |Errors: See LockMem.
37 | 38 |Notes: Memory that is locked cannot be swapped to disk by the VMM. Locking applies to memory on 4K boundaries. Therefore, areas of memory below and above the memory being locked are locked if the specified region is not aligned to a 4K boundary.
39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /doc/page_44.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |STACK FRAMES
11 |Stack frames for 16-bit interrupts are the same as for real mode.
12 |The stack frame for 16-bit exceptions follows:
13 |word SS
14 |word SP - Original stack address
15 |word Flags
16 |word CS
17 |word IP - Original Flags:CS:IP values that caused the exception
18 |word Err Code - Processor supplied exception error code
19 |word CS
20 | 21 | 22 | 23 | 24 | 25 | 26 |word IP - Return address, returns to interrupt/exception
27 | 28 | 29 | 30 | 31 | 32 | 33 |dispatch code
34 |DEFAULT API
35 |The default CauseWay API follows. Functions that end in the text near are intended only for backwards compatibility with CauseWay's NEAR memory model. This model is now obsolete. The assembly language program include file CW.INC also contains the following list.
36 ||
38 | AliasSel Create a read/write data selector from source selector. |
39 |
40 |
Inputs: AX = 0ff06h
44 |BX = Source selector
45 |Outputs: Carry set on error else,
46 |AX = New data selector
47 | 48 | 49 | 50 |Errors: If an invalid selector is passed in BX, this function returns with carry set.
51 |Notes: This function always creates a read/write data selector regardless of the source selector type. It can be used to provide write access to variables in a code segment.
52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /doc/page_72.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 |Notes: The user termination routine is responsible for returning to the CauseWay termination routines to allow proper 11 | shutdown of the application. The instruction must be the proper 16- or 32-bit return to match the CL register setting. 12 | For ease of use with high-level languages (specifically Watcom C and setting SS back to DGROUP), [E]SI equals the internal 13 | DOS extender stack ESP immediately prior to the 32- or 16-bit call to the termination routine. If an information dump buffer 14 | address is provided, register and other termination values are placed into it using the following format:
15 |dword EBP;
16 |dword EDI;
17 |dword ESI;
18 |dword EDX;
19 |dword ECX;
20 |dword EBX;
21 |dword EAX;
22 |dword GS;
23 |dword FS;
24 |dword ES;
25 |dword DS;
26 |dword EIP;
27 |dword CS;
28 |dword EFLAGS;
29 |dword ESP;
30 |dword SS;
31 |word TR;
32 |dword CR0;
33 |dword CR2;
34 |dword CR3;
35 |dword csAddress;
36 |dword dsAddress;
37 |dword esAddress;
38 |dword fsAddress;
39 |dword gsAddress;
40 |dword ssAddress;
41 |word ExceptionNumber;
42 |dword ErrorCode;
43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /doc/page_59.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 ||
12 | LockMemNear Lock a region of memory using application relative address. |
13 |
Inputs: AX = 0ff1fh
17 |ESI = Starting linear address of memory to lock.
18 |EBX = Size of region to lock in bytes.
19 |Outputs: Carry set on error.
20 |Errors: See LockMem
21 | 22 |Notes: Memory that is locked cannot be swapped to disk by the VMM. Locking applies to memory on 4K boundaries. Therefore, areas of memory below and above the memory being locked are locked if the specified region is not aligned to a 4K boundary.
23 | 24 | 25 | 26 ||
28 | Near2Linear Convert application relative address to linear address. |
29 |
Inputs: AX = 0ff1ah
33 |ESI = Application relative linear address.
34 |Outputs: ESI = Linear address.
35 |Errors: None
36 | 37 ||
39 | RelCallBack Release a real mode call back entry. |
40 |
Inputs: AX = 0304h
44 |CX:DX = Real mode address returned by GetCallBack
45 |Errors: None.
46 |Outputs: None.
47 | 48 | 49 | 50 |Notes: Use this function to release call-back addresses once they are no longer needed.
51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/cwc/copystub.asm: -------------------------------------------------------------------------------- 1 | 2 | ;--- this file is included into CWC.EXE as copystub.inc 3 | 4 | .model tiny 5 | option oldstructs 6 | option proc:private 7 | 8 | CWCStackSize equ 1024 ; cannot exceed EXECopyStubLen size (1135 bytes) 9 | 10 | .code 11 | 12 | var_struc struc 13 | ; db 100h-10h dup (0) 14 | db CWCStackSize-10h dup (0) 15 | 16 | var_SourceSeg dw ? 17 | var_CopyLen dw ? 18 | var_EntryIP dw 0 19 | var_EntryCS dw ? 20 | var_ImageLen dw ?,? 21 | var_EntryES dw ? 22 | var_struc ends 23 | 24 | b equ byte ptr 25 | w equ word ptr 26 | d equ dword ptr 27 | f equ fword ptr 28 | 29 | start: cli 30 | push ss ;make data addressable. 31 | pop ds 32 | mov ax,es:[2] ;Get highest address. 33 | 34 | ; sub ax,10h 35 | sub ax,(CWCStackSize/10h) 36 | 37 | mov ss,ax 38 | sti 39 | push es 40 | push ss 41 | pop es 42 | ; mov si,100h-10h 43 | mov si,CWCStackSize-10h 44 | 45 | mov di,si 46 | mov cx,10h 47 | rep movsb 48 | pop es 49 | mov ss:w[var_EntryES],es ;need this for program entry. 50 | ; 51 | ;Setup destination copy address. 52 | ; 53 | mov bx,ax 54 | mov dx,cs 55 | add dx,ss:w[var_SourceSeg] 56 | mov bp,ss:w[var_CopyLen] 57 | ; 58 | ;Do the copy. 59 | ; 60 | std 61 | @@0: mov ax,bp 62 | cmp ax,1000h 63 | jbe @@1 64 | mov ax,1000h 65 | @@1: sub bp,ax 66 | sub dx,ax 67 | sub bx,ax 68 | mov ds,dx 69 | mov es,bx 70 | mov cl,3 71 | shl ax,cl 72 | mov cx,ax 73 | shl ax,1 74 | dec ax 75 | dec ax 76 | mov si,ax 77 | mov di,ax 78 | rep movsw 79 | or bp,bp 80 | jnz @@0 81 | ; 82 | ;Point to the data to decompress. 83 | ; 84 | mov si,es 85 | mov ds,si 86 | xor si,si 87 | mov di,cs 88 | mov es,di 89 | xor di,di 90 | ; 91 | ;Setup the decompressor entry address. 92 | ; 93 | mov ax,ds 94 | add ss:w[var_EntryCS],ax 95 | ; 96 | ;Jump into the decompressor code. 97 | ; 98 | jmp ss:dword ptr[var_EntryIP] 99 | 100 | db 1056 dup (0) 101 | 102 | end start 103 | 104 | --------------------------------------------------------------------------------