diff --git a/rtl/win16/prt0comn.asm b/rtl/win16/prt0comn.asm index 59a6666be1..d823af1ea3 100644 --- a/rtl/win16/prt0comn.asm +++ b/rtl/win16/prt0comn.asm @@ -31,6 +31,7 @@ extern __fpc_CmdShow extern __fpc_HInstance extern __fpc_HPrevInst + extern __fpc_SelectorInc extern InitTask import InitTask KERNEL @@ -38,6 +39,8 @@ import WaitEvent KERNEL extern InitApp import InitApp USER + extern __AHIncr + import __AHIncr KERNEL ..start: ; Win16 applications start with the following ; values in registers: @@ -77,6 +80,13 @@ mov [__fpc_HInstance], di mov [__fpc_HPrevInst], si + ; the offset of the Win16 kernel function __AHIncr (by definition) + ; gives us the value of SelectorInc. The function __AHIncr is + ; otherwise useless (when called, it increments AH by one :) ) + ; The value of SelectorInc is usually 8 in most (all?) win16 + ; implementations, but it's good practice not to hardcode it. + mov word [__fpc_SelectorInc], __AHIncr + ; call WaitEvent(0) to clear the event that started this task ; Windows expects this call immediately after InitTask xor ax, ax diff --git a/rtl/win16/system.pp b/rtl/win16/system.pp index 7aaf73bebf..b31f674704 100644 --- a/rtl/win16/system.pp +++ b/rtl/win16/system.pp @@ -50,9 +50,6 @@ const segA000: Word = $A000; segB000: Word = $B000; segB800: Word = $B800;} -{ The value that needs to be added to the segment to move the pointer by - 64K bytes (BP7 compatibility) } - SelectorInc: Word = $1000; type LPSTR = ^Char;far; @@ -77,6 +74,9 @@ var CmdShow: SmallInt;public name '__fpc_CmdShow'; HInstance: Word{HINST};public name '__fpc_HInstance'; HPrevInst: Word{HINST};public name '__fpc_HPrevInst'; +{ The value that needs to be added to the segment to move the pointer by + 64K bytes (BP7 compatibility) } + SelectorInc: Word;public name '__fpc_SelectorInc'; { SaveInt00: FarPointer;public name '__SaveInt00';}