wok rev 20184

memtest, ipxe: update bootsector
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Feb 01 12:59:51 2018 +0100 (2018-02-01)
parents 06a7eacc4e80
children a300e47088cc
files ipxe/stuff/bootloader.S memtest/stuff/bootloader.S memtest/stuff/unlzma.S memtest/stuff/unpack.S
line diff
     1.1 --- a/ipxe/stuff/bootloader.S	Mon Jan 29 19:08:54 2018 +0100
     1.2 +++ b/ipxe/stuff/bootloader.S	Thu Feb 01 12:59:51 2018 +0100
     1.3 @@ -1,8 +1,6 @@
     1.4  // Image/zImage & tiny bzImage linux kernel boot sector, (C) SliTaz, GPL2.
     1.5  
     1.6  SYSSEG		= 0x1000
     1.7 -INITSEG		= 0x9000
     1.8 -SETUPSEG	= 0x9020
     1.9  setup_sects	= 497
    1.10  syssize		= 500
    1.11  cmd_line_ptr	= 0x228
    1.12 @@ -15,35 +13,77 @@
    1.13  
    1.14  #define CODESZ 512		/* patched by installer */
    1.15  
    1.16 +// Default kernel format is 386 Image/zImage
    1.17  #define BZIMAGE 0x207		/* setup version ; for bzImage < 512 Kb only */
    1.18 +//#define ELKS			/* 8086/286 linux port */
    1.19  
    1.20  /* some extra features */
    1.21 -#define EXE_SUPPORT		real mode dos .exe file support
    1.22 -#define CMDLINE			kernel cmdline support	
    1.23 -#define VCPI			VCPI 4.0 support
    1.24 -#define SHUTDOWNDOS		shutdown DOS services
    1.25 +#define EXE_SUPPORT		real mode dos .exe file support	+208/264
    1.26 +#define  CMDLINE		dos kernel cmdline support	+45
    1.27 +#define  VCPI			VCPI 4.0 support (386+)		+109
    1.28 +#define  SHUTDOWNDOS		shutdown DOS services		+29
    1.29  
    1.30  /* some contraints to reduce the code size */
    1.31 -//#define FLOPPY_1440K_ONLY	1.44M floppies support only	-33
    1.32 -//#define FLOPPY_HAS_2_SIDES	hardcoded heads count to 2	-13
    1.33 -//#define NO_CMDLINE_SHRINK	remove heading spaces ?		-6-20
    1.34 -//#define NO_CMDLINE_FILE	remove @cmdline file support ?	-20
    1.35 -#define NO_DOTS		show progression dots ?		-8
    1.36 +//#define FLOPPY_1440K_ONLY	1.44M floppies support only	-26
    1.37 +//#define FLOPPY_HAS_2_SIDES	hardcoded heads count to 2	-15
    1.38 +//#define NO_CMDLINE_SHRINK	remove heading spaces ?		-6-21
    1.39 +//#define  NO_CMDLINE_FILE	remove @cmdline file support ?	-21
    1.40 +//#define NO_DOTS		show progression dots ?		-5
    1.41  #ifndef BZIMAGE
    1.42 +//#define TINY_ZIMAGE		system < 64Kb ?			-11
    1.43  //#defime NO_MINSETUP		default setup (dos only) ?	-4
    1.44  //#define NO_CURSOR_DEFINITION					-8
    1.45  #endif
    1.46  
    1.47 +#ifdef ELKS
    1.48 +	.arch	i8086
    1.49 +INITSEG		= 0x0100
    1.50 +SETUPSEG	= 0x0120
    1.51 +#define ONLY8086
    1.52 +#undef BZIMAGE
    1.53 +#undef VCPI
    1.54 +#else
    1.55 +INITSEG		= 0x9000
    1.56 +SETUPSEG	= 0x9020
    1.57 +#endif
    1.58 +
    1.59 +.macro	shlclw cnt,obj
    1.60 +#ifdef ONLY8086
    1.61 +	movb	\cnt,%cl
    1.62 +	shlw	%cl,\obj
    1.63 +#else
    1.64 +	shlw	\cnt,\obj
    1.65 +#endif
    1.66 +.endm
    1.67 +
    1.68 +.macro	shrclw cnt,obj
    1.69 +#ifdef ONLY8086
    1.70 +	movb	\cnt,%cl
    1.71 +	shrw	%cl,\obj
    1.72 +#else
    1.73 +	shrw	\cnt,\obj
    1.74 +#endif
    1.75 +.endm
    1.76 +
    1.77  #ifdef EXE_SUPPORT
    1.78  #define EXEADRS(x)	(x+0xE0)
    1.79  #define FLAT20(x)	(x+16*INITSEG)
    1.80  
    1.81  .macro	trace_int19
    1.82 +#ifdef ONLY8086
    1.83 +	xorw	%si, %si
    1.84 +	movw	%si, %ds
    1.85 +	pushw	4+2(%si)
    1.86 +	pushw	4(%si)
    1.87 +	movw	$step19, 4(%si)
    1.88 +	movw	$INITSEG, 4+2(%si)
    1.89 +#else
    1.90  	pushl	$4
    1.91  	popw	%si
    1.92  	popw	%ds
    1.93  	pushl	(%si)
    1.94  	movl	$step19+(INITSEG<<16), (%si)
    1.95 +#endif
    1.96  	pushfw
    1.97  	popw	%ax
    1.98  	incb	%ah			# set TF
    1.99 @@ -68,17 +108,19 @@
   1.100  	.word	0xFFF0			// Initial (relative) CS value
   1.101  //	.word	0x001C			// File address of relocation table
   1.102  //	.word	0,0,0			// Overlay number
   1.103 +#else
   1.104 +#undef VCPI
   1.105  #endif
   1.106  start:
   1.107  	xorw	%ax, %ax		# %ax = 0
   1.108 -#ifdef BZIMAGE
   1.109 -zeroed		= 14			# zeroed registers
   1.110 -#else
   1.111  zeroed		= 12			# zeroed registers
   1.112 -#endif
   1.113  	movw	$zeroed/2, %cx		# clear gdt + offset, %ds, limits
   1.114  stacktop	= 0x9E00		# in 0x8000 .. 0xA000 (+zeroed+12)
   1.115 +#ifdef ONLY8086
   1.116 +	movw	$INITSEG, %bx
   1.117 +#else
   1.118  	pushw	$INITSEG
   1.119 +#endif
   1.120  end_header:
   1.121  	cld				# assume nothing
   1.122  #if defined(BZIMAGE) && BZIMAGE >= 0x202
   1.123 @@ -90,6 +132,9 @@
   1.124  					# length of bootsect + length of
   1.125  					# setup + room for stack;
   1.126  					# 12 is disk parm size.
   1.127 +# ifdef ONLY8086
   1.128 +	pushw	%bx
   1.129 +# endif
   1.130  	popw	%es			# %es contain INITSEG
   1.131  #endif
   1.132  	pushw	%es
   1.133 @@ -115,7 +160,6 @@
   1.134  	stosw				# already done above
   1.135  	popw	%bx			# offset = 0
   1.136  	popw	%ds			# %ds = 0
   1.137 -	popw	%fs			# %fs = 0
   1.138  
   1.139  	movb	setup_sects+0x7C00, %al	# read bootsector + setup (%ds = 0)
   1.140  	incw	%ax
   1.141 @@ -123,14 +167,20 @@
   1.142  	ldsw	0x78(%bx), %si		# %ds:%bx+0x78 is parameter table address
   1.143  	pushw	%es
   1.144  	pushw	%di
   1.145 +	pushw	%ds
   1.146  	movb	$6, %cl			# copy 12 bytes
   1.147  	rep				# don't worry about cld
   1.148  	movsw				# already done above
   1.149 +	popw	%ds
   1.150 +#ifdef ONLY8086
   1.151 +	popw	0x78(%bx)		# update parameter table address
   1.152 +	popw	0x78+2(%bx)
   1.153 +#else
   1.154 +	popl	0x78(%bx)		# update parameter table address
   1.155 +#endif
   1.156  	pushw	%ss
   1.157  	popw	%ds			# now %ds = %es = %ss = INITSEG
   1.158 -	popl	%fs:0x78(%bx)		# update parameter table address
   1.159  	movb	$63, 0x4-12(%di)	# patch sector count, %di = stacktop
   1.160 -	cli
   1.161  
   1.162  	xchg	%ax, %di		# sector count
   1.163  	popw	%ax			# limits = 0
   1.164 @@ -141,12 +191,9 @@
   1.165  # no 64kB boundaries are crossed. We try to load it as fast as
   1.166  # possible, loading whole tracks whenever we can.
   1.167  
   1.168 -#ifndef NO_DOTS
   1.169 -	popw	%bx			# clear %bx
   1.170 -#endif
   1.171  	movw	syssize, %di
   1.172  	decw	%di
   1.173 -	shrw	$9-4, %di
   1.174 +	shrclw	$9-4, %di
   1.175  	incw	%di
   1.176  	movw	$SYSSEG, %cx
   1.177  #ifdef BZIMAGE
   1.178 @@ -206,6 +253,7 @@
   1.179  	jne	syslp
   1.180  #endif
   1.181  jmp_setup:
   1.182 +	cli
   1.183  	ljmp	$SETUPSEG, $0
   1.184  
   1.185  #ifdef EXE_SUPPORT
   1.186 @@ -226,16 +274,44 @@
   1.187  	pushw	%cs
   1.188  	popw	%ss
   1.189  	movw	$stacktop-4-16, %sp
   1.190 +#ifdef ONLY8086
   1.191 +	popw	4(%si)
   1.192 +	popw	4+2(%si)
   1.193 +	popw	%bp
   1.194 +	popw	%di
   1.195 +	popw	%si
   1.196 +	popw	%dx
   1.197 +	popw	%cx
   1.198 +	popw	%bx
   1.199 +	popw	%ax
   1.200 +#else
   1.201  	popl	4(%si)
   1.202  	popaw
   1.203 +#endif
   1.204  #ifdef BZIMAGE
   1.205  	jmp	movesys
   1.206  #endif
   1.207  #endif
   1.208  #ifndef BZIMAGE
   1.209  movesys:				// %ax = SYSSEG, %bx = DS, %si
   1.210 -	shrw	$4, %si
   1.211 +	shrclw	$4, %si
   1.212  	addw	%si, %bx
   1.213 +#ifdef TINY_ZIMAGE
   1.214 +	movw	$0xFFFF, %cx
   1.215 +	xorw	%si, %si
   1.216 +	xorw	%di, %di
   1.217 +	cmpw	%ax, %bx
   1.218 +	jc	forward
   1.219 +	decw	%si
   1.220 +	decw	%di
   1.221 +	std
   1.222 +forward:
   1.223 +	movw	%ax, %es
   1.224 +	movw	%bx, %ds
   1.225 +	rep
   1.226 +	  movsb
   1.227 +	cld
   1.228 +#else
   1.229  	subw	%ax, %bx
   1.230  	jnc	forward
   1.231  	movb	$0x90, %ah
   1.232 @@ -255,6 +331,7 @@
   1.233  	rep
   1.234  	  movsb
   1.235  	jns	forward
   1.236 +#endif
   1.237  #ifndef NO_CURSOR_DEFINITION
   1.238  	movb	$1, %ah
   1.239  	movb	$0, %bh
   1.240 @@ -267,7 +344,12 @@
   1.241  #endif
   1.242  comstart:
   1.243  	cld				# assume nothing
   1.244 +#ifdef ONLY8086
   1.245 +	movw	$INITSEG, %ax
   1.246 +	pushw	%ax
   1.247 +#else
   1.248  	pushw	$INITSEG
   1.249 +#endif
   1.250  	popw	%es
   1.251  #ifdef CMDLINE
   1.252  	movw	%sp, %di
   1.253 @@ -345,7 +427,6 @@
   1.254  	int	$0x67
   1.255  	movl	$FLAT20(sw2pm_params),%esi
   1.256  	movb	$0x0C,%al	// DE0C switchpm(ESI)
   1.257 -	cli
   1.258  	jmp	call_vcpi
   1.259  pm_code:
   1.260  	movl	%cr0,%eax
   1.261 @@ -362,7 +443,17 @@
   1.262  # endif
   1.263  #else
   1.264  # ifdef SHUTDOWNDOS
   1.265 +#  ifdef ONLY8086
   1.266 +	pushw	%ax
   1.267 +	pushw	%bx
   1.268 +	pushw	%cx
   1.269 +	pushw	%dx
   1.270 +	pushw	%si
   1.271 +	pushw	%di
   1.272 +	pushw	%bp
   1.273 +#  else
   1.274  	pushaw
   1.275 +#  endif
   1.276  	trace_int19
   1.277  # endif
   1.278  	retf
   1.279 @@ -386,7 +477,6 @@
   1.280  return:
   1.281  #ifndef NO_DOTS
   1.282  	movw	$0xE2E,%ax
   1.283 -	movb	$7,%bl
   1.284  	int	$0x10
   1.285  #endif
   1.286  	ret
   1.287 @@ -405,21 +495,26 @@
   1.288          ja	next_cylinder		#   no -> store it
   1.289  check_cylinder:
   1.290  #endif
   1.291 -#endif
   1.292 -	pushaw
   1.293 -#ifndef FLOPPY_1440K_ONLY
   1.294 +	pushw	%ax
   1.295  	cbw				# %ah = 0
   1.296 +#else
   1.297 +	pushw	%dx
   1.298  #endif
   1.299          int     $0x13			# reset controler
   1.300 -	popaw
   1.301 +#ifndef FLOPPY_1440K_ONLY
   1.302 +	popw	%ax
   1.303  	movb	$1, %al			# sector by sector...
   1.304 +#else
   1.305 +	movw	$1, %ax
   1.306 +	jmp	more1trk
   1.307 +#endif
   1.308  read_sectorslp:
   1.309  	pushw	%dx			# some bios break dx...
   1.310  #ifndef FLOPPY_1440K_ONLY
   1.311          pushw   %ax			# limits
   1.312  	subb	%cl, %al		# sectors remaining in track
   1.313  	ja	tolastsect
   1.314 -	movb	$1, %al			# 1 sector mini
   1.315 +	movb	$1, %al			# first track sector by sector
   1.316  tolastsect:
   1.317  #else
   1.318  	movb	$FLOPPY_SECTORS+1, %al
   1.319 @@ -444,20 +539,20 @@
   1.320  #ifndef FLOPPY_1440K_ONLY
   1.321  	xchgw	%ax, %bp
   1.322  	addw	%dx,%cx			# next sector
   1.323 -	movw	%cx, %gs
   1.324 +	movw	%cx, %si
   1.325 +	pushw	%dx
   1.326 +	shlclw	$5, %dx
   1.327  	movw	%es, %cx
   1.328 -	pushw	%dx
   1.329 -	shlw	$5, %dx
   1.330  	addw	%dx, %cx
   1.331  	popw	%dx
   1.332  	subw	%dx,%di			# update sector counter
   1.333  	popw	%dx
   1.334  #else
   1.335  	addw	%ax,%cx			# next sector
   1.336 -	movw	%cx, %gs
   1.337 +	movw	%cx, %si
   1.338 +	pushw	%ax
   1.339 +	shlclw	$5, %ax
   1.340  	movw	%es, %cx
   1.341 -	pushw	%ax
   1.342 -	shlw	$5, %ax
   1.343  	addw	%ax, %cx
   1.344  	popw	%ax
   1.345  	subw	%ax,%di			# update sector counter
   1.346 @@ -466,10 +561,10 @@
   1.347  	movw	%cx, %es		# next location
   1.348  	jz	return
   1.349  read_sectors:
   1.350 -	movw	%gs, %cx
   1.351 +	movw	%si, %cx
   1.352  #ifndef FLOPPY_1440K_ONLY
   1.353  #   al is last sector+1
   1.354 -#   ah is last cylinder+1
   1.355 +#   ah is last head+1
   1.356  	xchgw	%ax, %bp
   1.357  #endif
   1.358  #ifndef FLOPPY_1440K_ONLY
   1.359 @@ -552,3 +647,8 @@
   1.360  	.word	stacktop-4-16-4,INITSEG
   1.361  # endif
   1.362  #endif
   1.363 +#ifdef ELKS
   1.364 +	.org	0x1E3
   1.365 +	.byte	13,10,7
   1.366 +	.asciz	"ELKS Boot"
   1.367 +#endif
     2.1 --- a/memtest/stuff/bootloader.S	Mon Jan 29 19:08:54 2018 +0100
     2.2 +++ b/memtest/stuff/bootloader.S	Thu Feb 01 12:59:51 2018 +0100
     2.3 @@ -1,8 +1,6 @@
     2.4  // Image/zImage & tiny bzImage linux kernel boot sector, (C) SliTaz, GPL2.
     2.5  
     2.6  SYSSEG		= 0x1000
     2.7 -INITSEG		= 0x9000
     2.8 -SETUPSEG	= 0x9020
     2.9  setup_sects	= 497
    2.10  syssize		= 500
    2.11  cmd_line_ptr	= 0x228
    2.12 @@ -15,35 +13,77 @@
    2.13  
    2.14  #define CODESZ 512		/* patched by installer */
    2.15  
    2.16 +// Default kernel format is 386 Image/zImage
    2.17  //#define BZIMAGE 0x207		/* setup version ; for bzImage < 512 Kb only */
    2.18 +//#define ELKS			/* 8086/286 linux port */
    2.19  
    2.20  /* some extra features */
    2.21 -#define EXE_SUPPORT		real mode dos .exe file support
    2.22 -#define CMDLINE			kernel cmdline support	
    2.23 -#define VCPI			VCPI 4.0 support
    2.24 -#define SHUTDOWNDOS		shutdown DOS services
    2.25 +#define EXE_SUPPORT		real mode dos .exe file support	+208/264
    2.26 +#define  CMDLINE		dos kernel cmdline support	+45
    2.27 +#define  VCPI			VCPI 4.0 support (386+)		+109
    2.28 +#define  SHUTDOWNDOS		shutdown DOS services		+29
    2.29  
    2.30  /* some contraints to reduce the code size */
    2.31 -//#define FLOPPY_1440K_ONLY	1.44M floppies support only	-33
    2.32 -//#define FLOPPY_HAS_2_SIDES	hardcoded heads count to 2	-13
    2.33 -//#define NO_CMDLINE_SHRINK	remove heading spaces ?		-6-20
    2.34 -//#define NO_CMDLINE_FILE	remove @cmdline file support ?	-20
    2.35 -//#define NO_DOTS		show progression dots ?		-8
    2.36 +//#define FLOPPY_1440K_ONLY	1.44M floppies support only	-26
    2.37 +//#define FLOPPY_HAS_2_SIDES	hardcoded heads count to 2	-15
    2.38 +//#define NO_CMDLINE_SHRINK	remove heading spaces ?		-6-21
    2.39 +//#define  NO_CMDLINE_FILE	remove @cmdline file support ?	-21
    2.40 +//#define NO_DOTS		show progression dots ?		-5
    2.41  #ifndef BZIMAGE
    2.42 +//#define TINY_ZIMAGE		system < 64Kb ?			-11
    2.43  //#defime NO_MINSETUP		default setup (dos only) ?	-4
    2.44  //#define NO_CURSOR_DEFINITION					-8
    2.45  #endif
    2.46  
    2.47 +#ifdef ELKS
    2.48 +	.arch	i8086
    2.49 +INITSEG		= 0x0100
    2.50 +SETUPSEG	= 0x0120
    2.51 +#define ONLY8086
    2.52 +#undef BZIMAGE
    2.53 +#undef VCPI
    2.54 +#else
    2.55 +INITSEG		= 0x9000
    2.56 +SETUPSEG	= 0x9020
    2.57 +#endif
    2.58 +
    2.59 +.macro	shlclw cnt,obj
    2.60 +#ifdef ONLY8086
    2.61 +	movb	\cnt,%cl
    2.62 +	shlw	%cl,\obj
    2.63 +#else
    2.64 +	shlw	\cnt,\obj
    2.65 +#endif
    2.66 +.endm
    2.67 +
    2.68 +.macro	shrclw cnt,obj
    2.69 +#ifdef ONLY8086
    2.70 +	movb	\cnt,%cl
    2.71 +	shrw	%cl,\obj
    2.72 +#else
    2.73 +	shrw	\cnt,\obj
    2.74 +#endif
    2.75 +.endm
    2.76 +
    2.77  #ifdef EXE_SUPPORT
    2.78  #define EXEADRS(x)	(x+0xE0)
    2.79  #define FLAT20(x)	(x+16*INITSEG)
    2.80  
    2.81  .macro	trace_int19
    2.82 +#ifdef ONLY8086
    2.83 +	xorw	%si, %si
    2.84 +	movw	%si, %ds
    2.85 +	pushw	4+2(%si)
    2.86 +	pushw	4(%si)
    2.87 +	movw	$step19, 4(%si)
    2.88 +	movw	$INITSEG, 4+2(%si)
    2.89 +#else
    2.90  	pushl	$4
    2.91  	popw	%si
    2.92  	popw	%ds
    2.93  	pushl	(%si)
    2.94  	movl	$step19+(INITSEG<<16), (%si)
    2.95 +#endif
    2.96  	pushfw
    2.97  	popw	%ax
    2.98  	incb	%ah			# set TF
    2.99 @@ -68,17 +108,19 @@
   2.100  	.word	0xFFF0			// Initial (relative) CS value
   2.101  //	.word	0x001C			// File address of relocation table
   2.102  //	.word	0,0,0			// Overlay number
   2.103 +#else
   2.104 +#undef VCPI
   2.105  #endif
   2.106  start:
   2.107  	xorw	%ax, %ax		# %ax = 0
   2.108 -#ifdef BZIMAGE
   2.109 -zeroed		= 14			# zeroed registers
   2.110 -#else
   2.111  zeroed		= 12			# zeroed registers
   2.112 -#endif
   2.113  	movw	$zeroed/2, %cx		# clear gdt + offset, %ds, limits
   2.114  stacktop	= 0x9E00		# in 0x8000 .. 0xA000 (+zeroed+12)
   2.115 +#ifdef ONLY8086
   2.116 +	movw	$INITSEG, %bx
   2.117 +#else
   2.118  	pushw	$INITSEG
   2.119 +#endif
   2.120  end_header:
   2.121  	cld				# assume nothing
   2.122  #if defined(BZIMAGE) && BZIMAGE >= 0x202
   2.123 @@ -90,6 +132,9 @@
   2.124  					# length of bootsect + length of
   2.125  					# setup + room for stack;
   2.126  					# 12 is disk parm size.
   2.127 +# ifdef ONLY8086
   2.128 +	pushw	%bx
   2.129 +# endif
   2.130  	popw	%es			# %es contain INITSEG
   2.131  #endif
   2.132  	pushw	%es
   2.133 @@ -115,7 +160,6 @@
   2.134  	stosw				# already done above
   2.135  	popw	%bx			# offset = 0
   2.136  	popw	%ds			# %ds = 0
   2.137 -	popw	%fs			# %fs = 0
   2.138  
   2.139  	movb	setup_sects+0x7C00, %al	# read bootsector + setup (%ds = 0)
   2.140  	incw	%ax
   2.141 @@ -123,14 +167,20 @@
   2.142  	ldsw	0x78(%bx), %si		# %ds:%bx+0x78 is parameter table address
   2.143  	pushw	%es
   2.144  	pushw	%di
   2.145 +	pushw	%ds
   2.146  	movb	$6, %cl			# copy 12 bytes
   2.147  	rep				# don't worry about cld
   2.148  	movsw				# already done above
   2.149 +	popw	%ds
   2.150 +#ifdef ONLY8086
   2.151 +	popw	0x78(%bx)		# update parameter table address
   2.152 +	popw	0x78+2(%bx)
   2.153 +#else
   2.154 +	popl	0x78(%bx)		# update parameter table address
   2.155 +#endif
   2.156  	pushw	%ss
   2.157  	popw	%ds			# now %ds = %es = %ss = INITSEG
   2.158 -	popl	%fs:0x78(%bx)		# update parameter table address
   2.159  	movb	$63, 0x4-12(%di)	# patch sector count, %di = stacktop
   2.160 -	cli
   2.161  
   2.162  	xchg	%ax, %di		# sector count
   2.163  	popw	%ax			# limits = 0
   2.164 @@ -141,12 +191,9 @@
   2.165  # no 64kB boundaries are crossed. We try to load it as fast as
   2.166  # possible, loading whole tracks whenever we can.
   2.167  
   2.168 -#ifndef NO_DOTS
   2.169 -	popw	%bx			# clear %bx
   2.170 -#endif
   2.171  	movw	syssize, %di
   2.172  	decw	%di
   2.173 -	shrw	$9-4, %di
   2.174 +	shrclw	$9-4, %di
   2.175  	incw	%di
   2.176  	movw	$SYSSEG, %cx
   2.177  #ifdef BZIMAGE
   2.178 @@ -206,6 +253,7 @@
   2.179  	jne	syslp
   2.180  #endif
   2.181  jmp_setup:
   2.182 +	cli
   2.183  	ljmp	$SETUPSEG, $0
   2.184  
   2.185  #ifdef EXE_SUPPORT
   2.186 @@ -226,16 +274,44 @@
   2.187  	pushw	%cs
   2.188  	popw	%ss
   2.189  	movw	$stacktop-4-16, %sp
   2.190 +#ifdef ONLY8086
   2.191 +	popw	4(%si)
   2.192 +	popw	4+2(%si)
   2.193 +	popw	%bp
   2.194 +	popw	%di
   2.195 +	popw	%si
   2.196 +	popw	%dx
   2.197 +	popw	%cx
   2.198 +	popw	%bx
   2.199 +	popw	%ax
   2.200 +#else
   2.201  	popl	4(%si)
   2.202  	popaw
   2.203 +#endif
   2.204  #ifdef BZIMAGE
   2.205  	jmp	movesys
   2.206  #endif
   2.207  #endif
   2.208  #ifndef BZIMAGE
   2.209  movesys:				// %ax = SYSSEG, %bx = DS, %si
   2.210 -	shrw	$4, %si
   2.211 +	shrclw	$4, %si
   2.212  	addw	%si, %bx
   2.213 +#ifdef TINY_ZIMAGE
   2.214 +	movw	$0xFFFF, %cx
   2.215 +	xorw	%si, %si
   2.216 +	xorw	%di, %di
   2.217 +	cmpw	%ax, %bx
   2.218 +	jc	forward
   2.219 +	decw	%si
   2.220 +	decw	%di
   2.221 +	std
   2.222 +forward:
   2.223 +	movw	%ax, %es
   2.224 +	movw	%bx, %ds
   2.225 +	rep
   2.226 +	  movsb
   2.227 +	cld
   2.228 +#else
   2.229  	subw	%ax, %bx
   2.230  	jnc	forward
   2.231  	movb	$0x90, %ah
   2.232 @@ -255,6 +331,7 @@
   2.233  	rep
   2.234  	  movsb
   2.235  	jns	forward
   2.236 +#endif
   2.237  #ifndef NO_CURSOR_DEFINITION
   2.238  	movb	$1, %ah
   2.239  	movb	$0, %bh
   2.240 @@ -267,7 +344,12 @@
   2.241  #endif
   2.242  comstart:
   2.243  	cld				# assume nothing
   2.244 +#ifdef ONLY8086
   2.245 +	movw	$INITSEG, %ax
   2.246 +	pushw	%ax
   2.247 +#else
   2.248  	pushw	$INITSEG
   2.249 +#endif
   2.250  	popw	%es
   2.251  #ifdef CMDLINE
   2.252  	movw	%sp, %di
   2.253 @@ -345,7 +427,6 @@
   2.254  	int	$0x67
   2.255  	movl	$FLAT20(sw2pm_params),%esi
   2.256  	movb	$0x0C,%al	// DE0C switchpm(ESI)
   2.257 -	cli
   2.258  	jmp	call_vcpi
   2.259  pm_code:
   2.260  	movl	%cr0,%eax
   2.261 @@ -362,7 +443,17 @@
   2.262  # endif
   2.263  #else
   2.264  # ifdef SHUTDOWNDOS
   2.265 +#  ifdef ONLY8086
   2.266 +	pushw	%ax
   2.267 +	pushw	%bx
   2.268 +	pushw	%cx
   2.269 +	pushw	%dx
   2.270 +	pushw	%si
   2.271 +	pushw	%di
   2.272 +	pushw	%bp
   2.273 +#  else
   2.274  	pushaw
   2.275 +#  endif
   2.276  	trace_int19
   2.277  # endif
   2.278  	retf
   2.279 @@ -386,7 +477,6 @@
   2.280  return:
   2.281  #ifndef NO_DOTS
   2.282  	movw	$0xE2E,%ax
   2.283 -	movb	$7,%bl
   2.284  	int	$0x10
   2.285  #endif
   2.286  	ret
   2.287 @@ -405,21 +495,26 @@
   2.288          ja	next_cylinder		#   no -> store it
   2.289  check_cylinder:
   2.290  #endif
   2.291 -#endif
   2.292 -	pushaw
   2.293 -#ifndef FLOPPY_1440K_ONLY
   2.294 +	pushw	%ax
   2.295  	cbw				# %ah = 0
   2.296 +#else
   2.297 +	pushw	%dx
   2.298  #endif
   2.299          int     $0x13			# reset controler
   2.300 -	popaw
   2.301 +#ifndef FLOPPY_1440K_ONLY
   2.302 +	popw	%ax
   2.303  	movb	$1, %al			# sector by sector...
   2.304 +#else
   2.305 +	movw	$1, %ax
   2.306 +	jmp	more1trk
   2.307 +#endif
   2.308  read_sectorslp:
   2.309  	pushw	%dx			# some bios break dx...
   2.310  #ifndef FLOPPY_1440K_ONLY
   2.311          pushw   %ax			# limits
   2.312  	subb	%cl, %al		# sectors remaining in track
   2.313  	ja	tolastsect
   2.314 -	movb	$1, %al			# 1 sector mini
   2.315 +	movb	$1, %al			# first track sector by sector
   2.316  tolastsect:
   2.317  #else
   2.318  	movb	$FLOPPY_SECTORS+1, %al
   2.319 @@ -444,20 +539,20 @@
   2.320  #ifndef FLOPPY_1440K_ONLY
   2.321  	xchgw	%ax, %bp
   2.322  	addw	%dx,%cx			# next sector
   2.323 -	movw	%cx, %gs
   2.324 +	movw	%cx, %si
   2.325 +	pushw	%dx
   2.326 +	shlclw	$5, %dx
   2.327  	movw	%es, %cx
   2.328 -	pushw	%dx
   2.329 -	shlw	$5, %dx
   2.330  	addw	%dx, %cx
   2.331  	popw	%dx
   2.332  	subw	%dx,%di			# update sector counter
   2.333  	popw	%dx
   2.334  #else
   2.335  	addw	%ax,%cx			# next sector
   2.336 -	movw	%cx, %gs
   2.337 +	movw	%cx, %si
   2.338 +	pushw	%ax
   2.339 +	shlclw	$5, %ax
   2.340  	movw	%es, %cx
   2.341 -	pushw	%ax
   2.342 -	shlw	$5, %ax
   2.343  	addw	%ax, %cx
   2.344  	popw	%ax
   2.345  	subw	%ax,%di			# update sector counter
   2.346 @@ -466,10 +561,10 @@
   2.347  	movw	%cx, %es		# next location
   2.348  	jz	return
   2.349  read_sectors:
   2.350 -	movw	%gs, %cx
   2.351 +	movw	%si, %cx
   2.352  #ifndef FLOPPY_1440K_ONLY
   2.353  #   al is last sector+1
   2.354 -#   ah is last cylinder+1
   2.355 +#   ah is last head+1
   2.356  	xchgw	%ax, %bp
   2.357  #endif
   2.358  #ifndef FLOPPY_1440K_ONLY
   2.359 @@ -552,3 +647,8 @@
   2.360  	.word	stacktop-4-16-4,INITSEG
   2.361  # endif
   2.362  #endif
   2.363 +#ifdef ELKS
   2.364 +	.org	0x1E3
   2.365 +	.byte	13,10,7
   2.366 +	.asciz	"ELKS Boot"
   2.367 +#endif
     3.1 --- a/memtest/stuff/unlzma.S	Mon Jan 29 19:08:54 2018 +0100
     3.2 +++ b/memtest/stuff/unlzma.S	Thu Feb 01 12:59:51 2018 +0100
     3.3 @@ -106,13 +106,27 @@
     3.4   */
     3.5   
     3.6  	mov	$ws1, CX
     3.7 +#ifdef ONLY8086
     3.8 +	movw	$2048/2, %ax
     3.9 +lzd1:
    3.10 +	pushw	%ax
    3.11 +#else
    3.12  lzd1:
    3.13  	pushw	$2048/2
    3.14 +#endif
    3.15  	loop	lzd1
    3.16  	mov	SP, BP
    3.17  	movb	$((LOCALS+3)/4)*2, %cl
    3.18 +#ifdef ONLY8086
    3.19 +	movw	$1, %ax
    3.20 +	cwd
    3.21 +initlocals:
    3.22 +	pushw	%dx
    3.23 +	pushw	%ax
    3.24 +#else
    3.25  initlocals:
    3.26  	pushl	$1
    3.27 +#endif
    3.28  	loop	initlocals
    3.29  
    3.30  #if !defined(FLAT32) && !defined(FLAT16OUT)
    3.31 @@ -175,12 +189,22 @@
    3.32  // 	((((nowPos) & literalPosMask) << lc) + (previousByte >> (8 - lc))));
    3.33  
    3.34  #if PROP_LC != 0
    3.35 +# ifdef ONLY8086
    3.36 +	movb	$8-PROP_LC, %cl
    3.37 +	shrb	%cl, %bl
    3.38 +# else
    3.39  	shrb	$8-PROP_LC, %bl
    3.40 +# endif
    3.41  #endif
    3.42  
    3.43  #if PROP_LP != 0
    3.44  	movb	posState2(BP), %dl
    3.45 +# ifdef ONLY8086
    3.46 +	movb	$PROP_LC, %cl
    3.47 +	shl	%cl, DX
    3.48 +# else
    3.49  	shl	$PROP_LC, DX
    3.50 +# endif
    3.51  	movb	$0, %bh
    3.52  	add	BX, DX
    3.53  #endif
    3.54 @@ -338,6 +362,23 @@
    3.55  //           rep1 = rep0; rep0 = distance;
    3.56  
    3.57  lzd11z:
    3.58 +# ifdef ONLY8086
    3.59 +	shl	$1, CX
    3.60 +	shl	$1, CX		// 8->32 bits
    3.61 +	sub	CX, DI		// &rep[cx]
    3.62 +	movw	(BP, DI), %ax
    3.63 +	pushw	2(BP, DI)
    3.64 +rotreplp:
    3.65 +	movb	4(BP, DI), %bl
    3.66 +	movb	%bl, (BP, DI)
    3.67 +	inc	DI
    3.68 +	loop	rotreplp
    3.69 +	popw	%bx
    3.70 +	testb	%dh, %dh
    3.71 +	jnz	lzd10
    3.72 +	movw	%ax, (BP, DI)
    3.73 +	movw	%bx, 2(BP, DI)
    3.74 +# else
    3.75  	shl	$2, CX		// 8->32 bits
    3.76  	sub	CX, DI		// &rep[cx]
    3.77  	movl	(BP, DI), %eax
    3.78 @@ -349,6 +390,7 @@
    3.79  	testb	%dh, %dh
    3.80  	jnz	lzd10
    3.81  	movl	%eax, (BP, DI)
    3.82 +# endif
    3.83  
    3.84  //         }
    3.85  lzd12:
    3.86 @@ -497,7 +539,17 @@
    3.87  //             rep0 <<= numDirectBits;
    3.88  
    3.89  	neg	AX
    3.90 +# ifdef ONLY8086
    3.91 +	pushw	%cx
    3.92 +	movb	$0, %ch
    3.93 +shllrep0:
    3.94 +	shlw	$1, (BP, DI)
    3.95 +	rclw	$1, 2(BP, DI)
    3.96 +	loop	shllrep0
    3.97 +	popw	%cx
    3.98 +# else
    3.99  	shll	%cl, (BP, DI)
   3.100 +# endif
   3.101  	add	(BP, DI), AX
   3.102  
   3.103  //             prob = p + SpecPos /*688*/ + rep0 - posSlot - 1;
   3.104 @@ -515,6 +567,26 @@
   3.105  
   3.106  lzd23z:
   3.107  	call	RC_NORMALIZE
   3.108 +# ifdef ONLY8086
   3.109 +	pushw	%dx
   3.110 +	shrw	$1, Range+2(BP)
   3.111 +	rcrw	$1, Range(BP)
   3.112 +	movw	Range(BP), %ax
   3.113 +	movw	Range+2(BP), %dx
   3.114 +	cmpw	Code+2(BP), %dx
   3.115 +	ja	lzd25
   3.116 +	jb	lzd25x
   3.117 +	cmpw	Code(BP), %ax
   3.118 +	ja	lzd25
   3.119 +lzd25x:
   3.120 +	subw	%ax, Code(BP)
   3.121 +	sbbw	%dx, Code+2(BP)
   3.122 +	stc
   3.123 +lzd25:
   3.124 +	popw	%dx
   3.125 +	rclw	$1, (BP, DI)
   3.126 +	rclw	$1, 2(BP, DI)
   3.127 +# else
   3.128  	shrl	$1, Range(BP)
   3.129  	movl	Range(BP), %eax
   3.130  	cmpl	Code(BP), %eax
   3.131 @@ -523,6 +595,7 @@
   3.132  	stc
   3.133  lzd25:
   3.134  	rcll	$1, (BP, DI)
   3.135 +# endif
   3.136  
   3.137  //             } while (--numDirectBits != 0);
   3.138  
   3.139 @@ -532,7 +605,17 @@
   3.140  //             prob = p + Align /* 802 */; numDirectBits = kNumAlignBits /*4*/;
   3.141  //             rep0 <<= numDirectBits;
   3.142  
   3.143 +# ifdef ONLY8086
   3.144 +	pushw	%cx
   3.145 +	movb	$0, %ch
   3.146 +shlrep0:
   3.147 +	shlw	$1, (BP, DI)
   3.148 +	rclw	$1, 2(BP, DI)
   3.149 +	loop	shlrep0
   3.150 +	popw	%cx
   3.151 +# else
   3.152  	shll	%cl, (BP, DI)
   3.153 +# endif
   3.154  	mov	$802, AX
   3.155  //           }
   3.156  
   3.157 @@ -554,7 +637,13 @@
   3.158  lzd22:
   3.159  //         if (++rep0 == (UInt32)(0)) break; /* EOF */
   3.160  
   3.161 +# ifdef ONLY8086
   3.162 +	incw	(BP, DI)
   3.163 +	jnz	lzd19
   3.164 +	incw	2(BP, DI)
   3.165 +# else
   3.166  	incl	(BP, DI)
   3.167 +# endif
   3.168  
   3.169  lzd19:
   3.170  	pop	CX
   3.171 @@ -610,6 +699,24 @@
   3.172   
   3.173  Dico2ESDI:
   3.174  #if !defined(FLAT32) && !defined(FLAT16OUT)
   3.175 +# ifdef ONLY8086
   3.176 +	pushw	%ax
   3.177 +	movw	nowPos(%bp), %bx
   3.178 +	movw	nowPos+2(%bp), %ax
   3.179 +	jnc	Dico2ESDIz
   3.180 +	subw	rep0(%bp), %bx
   3.181 +	sbbw	rep0+2(%bp), %ax
   3.182 +Dico2ESDIz:
   3.183 +	movw	$0xF, %di
   3.184 +	andw	%bx, %di
   3.185 +	pushw	%cx
   3.186 +	movb	$4, %cl
   3.187 +	shrw	%cl, %bx
   3.188 +	shlw	%cl, %ax
   3.189 +	popw	%cx
   3.190 +	addb	%al, %bh
   3.191 +	popw	%ax
   3.192 +# else
   3.193  	movl	nowPos(%bp), %ebx
   3.194  	jnc	Dico2ESDIz
   3.195  	subl	rep0(%bp), %ebx
   3.196 @@ -617,6 +724,7 @@
   3.197  	movw	%bx, %di
   3.198  	xorw	%bx, %bx
   3.199  	shrl	$4, %ebx
   3.200 +# endif
   3.201  	movw	%bx, %es
   3.202  #else
   3.203  	mov	nowPos(BP), DI
   3.204 @@ -673,7 +781,14 @@
   3.205  	andb	$((1 << PROP_LP) -1), posState2(BP)
   3.206  # endif
   3.207  #endif
   3.208 +#ifdef ONLY8086
   3.209 +	incw	nowPos(BP)
   3.210 +	jnz	incnowPosDone
   3.211 +	incw	nowPos+2(BP)
   3.212 +incnowPosDone:
   3.213 +#else
   3.214  	incl	nowPos(BP)
   3.215 +#endif
   3.216  	ret
   3.217  
   3.218  //  
   3.219 @@ -690,8 +805,20 @@
   3.220  	jne	RC_NORMALIZE_1
   3.221  RC_LOAD_BYTE:
   3.222  	push	AX
   3.223 +#ifdef ONLY8086
   3.224 +	movw	Range+1(BP), %ax
   3.225 +	movw	%ax, Range+2(BP)
   3.226 +	movw	Code+1(BP), %ax
   3.227 +	movw	%ax, Code+2(BP)
   3.228 +	xorw	%ax, %ax
   3.229 +	movb	Range(BP), %ah
   3.230 +	movw	%ax, Range(BP)
   3.231 +	movb	Code(BP), %ah
   3.232 +	movw	%ax, Code(BP)
   3.233 +#else
   3.234  	shll	$8, Range(BP)
   3.235  	shll	$8, Code(BP)
   3.236 +#endif
   3.237  #if !defined(FLAT16) && !defined(FLAT32)
   3.238  	testw	%si, %si
   3.239  	jns	RC_READ_BYTE
   3.240 @@ -741,7 +868,14 @@
   3.241  
   3.242  	call  RC_NORMALIZE		// kill %ax, update %si
   3.243  
   3.244 +#ifdef ONLY8086
   3.245 +	pushw	%ax
   3.246 +	pushw	%cx
   3.247 +	pushw	%dx
   3.248 +	pushw	%di
   3.249 +#else
   3.250  	pushal
   3.251 +#endif
   3.252  
   3.253  	xchg	AX, DI
   3.254  	add	DI, DI			// short *
   3.255 @@ -749,19 +883,48 @@
   3.256  
   3.257  // 	bound = (Range>>kNumBitModelTotalBits /*11*/) * *(p);
   3.258  
   3.259 +#ifdef ONLY8086
   3.260 +	movw	Range(BP), %dx
   3.261 +	movw	Range+2(BP), %ax
   3.262 +	movw	$11, %cx
   3.263 +shr11lp:
   3.264 +	shrw	$1, %ax
   3.265 +	rcrw	$1, %dx
   3.266 +	loop	shr11lp
   3.267 +	movw	%dx, %cx
   3.268 +	mulw	(BP, DI)
   3.269 +	xchgw	%ax, %cx
   3.270 +	mulw	(BP, DI)
   3.271 +	addw	%cx, %dx
   3.272 +#else
   3.273  	movl	Range(BP), %eax
   3.274  	shrl	$11, %eax
   3.275  	movzwl	(BP, DI), %edx
   3.276  	mull	%edx
   3.277 +#endif
   3.278  
   3.279  // 	if (Code < bound) {
   3.280  
   3.281 +#ifdef ONLY8086
   3.282 +	cmpw	Code+2(BP), %dx
   3.283 +	jb	Bit1_1
   3.284 +	ja	Bit1_1x
   3.285 +	cmpw	Code(BP), %ax
   3.286 +	jbe	Bit1_1
   3.287 +Bit1_1x:
   3.288 +
   3.289 +//    		Range = bound;
   3.290 +
   3.291 +	movw	%ax, Range(BP)
   3.292 +	movw	%dx, Range+2(BP)
   3.293 +#else
   3.294  	cmpl	Code(BP), %eax
   3.295  	jbe	Bit1_1
   3.296  
   3.297  //    		Range = bound;
   3.298  
   3.299  	movl	%eax, Range(BP)
   3.300 +#endif
   3.301  
   3.302  // 		*(p) += (kBitModelTotal /*2048*/ - *(p)) >> kNumMoveBits /*5*/;
   3.303  
   3.304 @@ -778,8 +941,15 @@
   3.305  
   3.306  //    		Range -= bound; Code -= bound;
   3.307  
   3.308 +#ifdef ONLY8086
   3.309 +	subw	%ax, Range(BP)
   3.310 +	sbbw	%dx, Range+2(BP)
   3.311 +	subw	%ax, Code(BP)
   3.312 +	sbbw	%dx, Code+2(BP)
   3.313 +#else
   3.314  	subl	%eax, Range(BP)
   3.315  	subl	%eax, Code(BP)
   3.316 +#endif
   3.317  
   3.318  // 		*(p) -= (*(p)) >> kNumMoveBits /*5*/;
   3.319  
   3.320 @@ -791,10 +961,22 @@
   3.321  Bit1_2:
   3.322  	pushf
   3.323  	subw	(BP, DI), %ax
   3.324 +#ifdef ONLY8086
   3.325 +	movb	$5, %cl
   3.326 +	sarw	%cl, %ax
   3.327 +#else
   3.328  	sarw	$5, %ax
   3.329 +#endif
   3.330  	addw	%ax, (BP, DI)
   3.331  	popf
   3.332 +#ifdef ONLY8086
   3.333 +	popw	%di
   3.334 +	popw	%dx
   3.335 +	popw	%cx
   3.336 +	popw	%ax
   3.337 +#else
   3.338  	popal
   3.339 +#endif
   3.340  	sbb	AX, AX
   3.341  
   3.342  // 	}
     4.1 --- a/memtest/stuff/unpack.S	Mon Jan 29 19:08:54 2018 +0100
     4.2 +++ b/memtest/stuff/unpack.S	Thu Feb 01 12:59:51 2018 +0100
     4.3 @@ -1,4 +1,3 @@
     4.4 -#define TOP		(0x90000+_start-end)
     4.5  #define SYSTEM		0x10000
     4.6  #define SETUP		14
     4.7  #define SYSSIZE		0x1F4
     4.8 @@ -11,11 +10,22 @@
     4.9  #define FLAT16			1
    4.10  //#define FLAT16OUT		0
    4.11  #define SAVEREGS		0 
    4.12 +#define ELKS			1
    4.13  
    4.14  	.text
    4.15  	.code16
    4.16  	.org	0
    4.17  
    4.18 +#if ELKS
    4.19 +	.arch	i8086
    4.20 +#define FLAT16			1
    4.21 +#define LINUX_HEADER		0
    4.22 +#define SAVEREGS		0 
    4.23 +#define TOPSEG		0x2000
    4.24 +#else
    4.25 +#define TOPSEG		0x8000
    4.26 +#endif
    4.27 +
    4.28  	.globl	_start
    4.29  _start:
    4.30  #if LINUX_HEADER
    4.31 @@ -50,20 +60,35 @@
    4.32  	pushw	$0
    4.33  # endif
    4.34  #endif
    4.35 +#if ELKS
    4.36 +	movw	$0x100, %ax
    4.37 +	pushw	%ax
    4.38 +#else
    4.39  #if UPDATE_SYSSIZE
    4.40  	pushw	%ds			// <A>
    4.41  #else
    4.42  	pushw	%cs			// <A>
    4.43  #endif
    4.44 +#endif
    4.45  #if FLAT16
    4.46 -# 1- move 9020..9020+stp -> 8000
    4.47 -	pushw	$0x8000
    4.48 +# 1- move 9020..9020+stp -> TOPSEG
    4.49 +#if ELKS
    4.50 +	movb	$TOPSEG/256, %ah
    4.51 +	movw	%ax, %es
    4.52 +#else
    4.53 +	pushw	$TOPSEG
    4.54  	popw	%es
    4.55 +#endif
    4.56  	movw	$0x200, %si
    4.57  #if SAVEREGS == 0
    4.58  	pushw	%es
    4.59 +#if ELKS
    4.60 +	movw	$cont, %ax
    4.61 +	pushw	%ax
    4.62 +#else
    4.63  	// pushw	$cont
    4.64  	.byte	0x6A, cont
    4.65 +#endif
    4.66  	jmp	jumpinto
    4.67  #else
    4.68  # if HARDCODED_SETUPSIZE
    4.69 @@ -82,28 +107,48 @@
    4.70  	lret
    4.71  #endif
    4.72  cont:
    4.73 -# 2- move 1000..1000+sys -> 8000+stp
    4.74 +# 2- move 1000..1000+sys -> TOPSEG+stp
    4.75 +#if ELKS
    4.76 +	movw	$0x1000, %ax
    4.77 +	movw	%ax, %ds
    4.78 +#else
    4.79  	pushw	$0x1000
    4.80  	popw	%ds
    4.81 +#endif
    4.82  	xorw	%si, %si
    4.83  	subw	%di, %cx
    4.84  	rep
    4.85  	  movsb
    4.86 -# 3- unlz(8000+stp:end, 1000-stp:0)
    4.87 +# 3- unlz(TOPSEG+stp:end, 1000-stp:0)
    4.88  	pushw	%es		// <C>
    4.89  # if HARDCODED_SETUPSIZE
    4.90  setup_seg:
    4.91 +#if ELKS
    4.92 +#  if UPDATE_SYSSIZE
    4.93 +	movw	$0x1000-(SETUP*32)-32, %ax
    4.94 +#  else
    4.95 +	movw	$0x1000-(SETUP*32), %ax
    4.96 +#  endif
    4.97 +	movw	%ax, %es
    4.98 +#else
    4.99  #  if UPDATE_SYSSIZE
   4.100  	pushw	$0x1000-(SETUP*32)-32
   4.101  #  else
   4.102  	pushw	$0x1000-(SETUP*32)
   4.103  #  endif
   4.104  	popw	%es
   4.105 +#endif
   4.106  # else
   4.107  #  if UPDATE_SYSSIZE
   4.108  	incb	%dh
   4.109  #  endif
   4.110 +#if ELKS
   4.111 +	shrw	$1, %dx
   4.112 +	shrw	$1, %dx
   4.113 +	shrw	$1, %dx
   4.114 +#else
   4.115  	shrw	$3, %dx
   4.116 +#endif
   4.117  	movw	%ds, %ax
   4.118  	subw	%dx, %ax
   4.119  	movw	%ax, %es
   4.120 @@ -140,7 +185,13 @@
   4.121  # else
   4.122  	movb	%ss:SETUPSIZE, %ch
   4.123  	movw	%cx, %ax
   4.124 +#if ELKS
   4.125 +	shrw	$1, %ax
   4.126 +	shrw	$1, %ax
   4.127 +	shrw	$1, %ax
   4.128 +#else
   4.129  	shrw	$3, %ax
   4.130 +#endif
   4.131  	subw	%ax, %dx
   4.132  # endif
   4.133  	pushw	%cx			// <B>
   4.134 @@ -225,6 +276,9 @@
   4.135  
   4.136  unpack:
   4.137  #define NO_LZMA_HEADER
   4.138 +#if ELKS
   4.139 +#define ONLY8086	1
   4.140 +#endif
   4.141  #include "unlzma.S"
   4.142  
   4.143  end: