# HG changeset patch # User Pascal Bellard # Date 1517486391 -3600 # Node ID 1421f93cc28aae4358bc38a7454f2078a706b475 # Parent 06a7eacc4e80eb4ba717331d7ca04d30580b301d memtest, ipxe: update bootsector diff -r 06a7eacc4e80 -r 1421f93cc28a ipxe/stuff/bootloader.S --- a/ipxe/stuff/bootloader.S Mon Jan 29 19:08:54 2018 +0100 +++ b/ipxe/stuff/bootloader.S Thu Feb 01 12:59:51 2018 +0100 @@ -1,8 +1,6 @@ // Image/zImage & tiny bzImage linux kernel boot sector, (C) SliTaz, GPL2. SYSSEG = 0x1000 -INITSEG = 0x9000 -SETUPSEG = 0x9020 setup_sects = 497 syssize = 500 cmd_line_ptr = 0x228 @@ -15,35 +13,77 @@ #define CODESZ 512 /* patched by installer */ +// Default kernel format is 386 Image/zImage #define BZIMAGE 0x207 /* setup version ; for bzImage < 512 Kb only */ +//#define ELKS /* 8086/286 linux port */ /* some extra features */ -#define EXE_SUPPORT real mode dos .exe file support -#define CMDLINE kernel cmdline support -#define VCPI VCPI 4.0 support -#define SHUTDOWNDOS shutdown DOS services +#define EXE_SUPPORT real mode dos .exe file support +208/264 +#define CMDLINE dos kernel cmdline support +45 +#define VCPI VCPI 4.0 support (386+) +109 +#define SHUTDOWNDOS shutdown DOS services +29 /* some contraints to reduce the code size */ -//#define FLOPPY_1440K_ONLY 1.44M floppies support only -33 -//#define FLOPPY_HAS_2_SIDES hardcoded heads count to 2 -13 -//#define NO_CMDLINE_SHRINK remove heading spaces ? -6-20 -//#define NO_CMDLINE_FILE remove @cmdline file support ? -20 -#define NO_DOTS show progression dots ? -8 +//#define FLOPPY_1440K_ONLY 1.44M floppies support only -26 +//#define FLOPPY_HAS_2_SIDES hardcoded heads count to 2 -15 +//#define NO_CMDLINE_SHRINK remove heading spaces ? -6-21 +//#define NO_CMDLINE_FILE remove @cmdline file support ? -21 +//#define NO_DOTS show progression dots ? -5 #ifndef BZIMAGE +//#define TINY_ZIMAGE system < 64Kb ? -11 //#defime NO_MINSETUP default setup (dos only) ? -4 //#define NO_CURSOR_DEFINITION -8 #endif +#ifdef ELKS + .arch i8086 +INITSEG = 0x0100 +SETUPSEG = 0x0120 +#define ONLY8086 +#undef BZIMAGE +#undef VCPI +#else +INITSEG = 0x9000 +SETUPSEG = 0x9020 +#endif + +.macro shlclw cnt,obj +#ifdef ONLY8086 + movb \cnt,%cl + shlw %cl,\obj +#else + shlw \cnt,\obj +#endif +.endm + +.macro shrclw cnt,obj +#ifdef ONLY8086 + movb \cnt,%cl + shrw %cl,\obj +#else + shrw \cnt,\obj +#endif +.endm + #ifdef EXE_SUPPORT #define EXEADRS(x) (x+0xE0) #define FLAT20(x) (x+16*INITSEG) .macro trace_int19 +#ifdef ONLY8086 + xorw %si, %si + movw %si, %ds + pushw 4+2(%si) + pushw 4(%si) + movw $step19, 4(%si) + movw $INITSEG, 4+2(%si) +#else pushl $4 popw %si popw %ds pushl (%si) movl $step19+(INITSEG<<16), (%si) +#endif pushfw popw %ax incb %ah # set TF @@ -68,17 +108,19 @@ .word 0xFFF0 // Initial (relative) CS value // .word 0x001C // File address of relocation table // .word 0,0,0 // Overlay number +#else +#undef VCPI #endif start: xorw %ax, %ax # %ax = 0 -#ifdef BZIMAGE -zeroed = 14 # zeroed registers -#else zeroed = 12 # zeroed registers -#endif movw $zeroed/2, %cx # clear gdt + offset, %ds, limits stacktop = 0x9E00 # in 0x8000 .. 0xA000 (+zeroed+12) +#ifdef ONLY8086 + movw $INITSEG, %bx +#else pushw $INITSEG +#endif end_header: cld # assume nothing #if defined(BZIMAGE) && BZIMAGE >= 0x202 @@ -90,6 +132,9 @@ # length of bootsect + length of # setup + room for stack; # 12 is disk parm size. +# ifdef ONLY8086 + pushw %bx +# endif popw %es # %es contain INITSEG #endif pushw %es @@ -115,7 +160,6 @@ stosw # already done above popw %bx # offset = 0 popw %ds # %ds = 0 - popw %fs # %fs = 0 movb setup_sects+0x7C00, %al # read bootsector + setup (%ds = 0) incw %ax @@ -123,14 +167,20 @@ ldsw 0x78(%bx), %si # %ds:%bx+0x78 is parameter table address pushw %es pushw %di + pushw %ds movb $6, %cl # copy 12 bytes rep # don't worry about cld movsw # already done above + popw %ds +#ifdef ONLY8086 + popw 0x78(%bx) # update parameter table address + popw 0x78+2(%bx) +#else + popl 0x78(%bx) # update parameter table address +#endif pushw %ss popw %ds # now %ds = %es = %ss = INITSEG - popl %fs:0x78(%bx) # update parameter table address movb $63, 0x4-12(%di) # patch sector count, %di = stacktop - cli xchg %ax, %di # sector count popw %ax # limits = 0 @@ -141,12 +191,9 @@ # no 64kB boundaries are crossed. We try to load it as fast as # possible, loading whole tracks whenever we can. -#ifndef NO_DOTS - popw %bx # clear %bx -#endif movw syssize, %di decw %di - shrw $9-4, %di + shrclw $9-4, %di incw %di movw $SYSSEG, %cx #ifdef BZIMAGE @@ -206,6 +253,7 @@ jne syslp #endif jmp_setup: + cli ljmp $SETUPSEG, $0 #ifdef EXE_SUPPORT @@ -226,16 +274,44 @@ pushw %cs popw %ss movw $stacktop-4-16, %sp +#ifdef ONLY8086 + popw 4(%si) + popw 4+2(%si) + popw %bp + popw %di + popw %si + popw %dx + popw %cx + popw %bx + popw %ax +#else popl 4(%si) popaw +#endif #ifdef BZIMAGE jmp movesys #endif #endif #ifndef BZIMAGE movesys: // %ax = SYSSEG, %bx = DS, %si - shrw $4, %si + shrclw $4, %si addw %si, %bx +#ifdef TINY_ZIMAGE + movw $0xFFFF, %cx + xorw %si, %si + xorw %di, %di + cmpw %ax, %bx + jc forward + decw %si + decw %di + std +forward: + movw %ax, %es + movw %bx, %ds + rep + movsb + cld +#else subw %ax, %bx jnc forward movb $0x90, %ah @@ -255,6 +331,7 @@ rep movsb jns forward +#endif #ifndef NO_CURSOR_DEFINITION movb $1, %ah movb $0, %bh @@ -267,7 +344,12 @@ #endif comstart: cld # assume nothing +#ifdef ONLY8086 + movw $INITSEG, %ax + pushw %ax +#else pushw $INITSEG +#endif popw %es #ifdef CMDLINE movw %sp, %di @@ -345,7 +427,6 @@ int $0x67 movl $FLAT20(sw2pm_params),%esi movb $0x0C,%al // DE0C switchpm(ESI) - cli jmp call_vcpi pm_code: movl %cr0,%eax @@ -362,7 +443,17 @@ # endif #else # ifdef SHUTDOWNDOS +# ifdef ONLY8086 + pushw %ax + pushw %bx + pushw %cx + pushw %dx + pushw %si + pushw %di + pushw %bp +# else pushaw +# endif trace_int19 # endif retf @@ -386,7 +477,6 @@ return: #ifndef NO_DOTS movw $0xE2E,%ax - movb $7,%bl int $0x10 #endif ret @@ -405,21 +495,26 @@ ja next_cylinder # no -> store it check_cylinder: #endif -#endif - pushaw -#ifndef FLOPPY_1440K_ONLY + pushw %ax cbw # %ah = 0 +#else + pushw %dx #endif int $0x13 # reset controler - popaw +#ifndef FLOPPY_1440K_ONLY + popw %ax movb $1, %al # sector by sector... +#else + movw $1, %ax + jmp more1trk +#endif read_sectorslp: pushw %dx # some bios break dx... #ifndef FLOPPY_1440K_ONLY pushw %ax # limits subb %cl, %al # sectors remaining in track ja tolastsect - movb $1, %al # 1 sector mini + movb $1, %al # first track sector by sector tolastsect: #else movb $FLOPPY_SECTORS+1, %al @@ -444,20 +539,20 @@ #ifndef FLOPPY_1440K_ONLY xchgw %ax, %bp addw %dx,%cx # next sector - movw %cx, %gs + movw %cx, %si + pushw %dx + shlclw $5, %dx movw %es, %cx - pushw %dx - shlw $5, %dx addw %dx, %cx popw %dx subw %dx,%di # update sector counter popw %dx #else addw %ax,%cx # next sector - movw %cx, %gs + movw %cx, %si + pushw %ax + shlclw $5, %ax movw %es, %cx - pushw %ax - shlw $5, %ax addw %ax, %cx popw %ax subw %ax,%di # update sector counter @@ -466,10 +561,10 @@ movw %cx, %es # next location jz return read_sectors: - movw %gs, %cx + movw %si, %cx #ifndef FLOPPY_1440K_ONLY # al is last sector+1 -# ah is last cylinder+1 +# ah is last head+1 xchgw %ax, %bp #endif #ifndef FLOPPY_1440K_ONLY @@ -552,3 +647,8 @@ .word stacktop-4-16-4,INITSEG # endif #endif +#ifdef ELKS + .org 0x1E3 + .byte 13,10,7 + .asciz "ELKS Boot" +#endif diff -r 06a7eacc4e80 -r 1421f93cc28a memtest/stuff/bootloader.S --- a/memtest/stuff/bootloader.S Mon Jan 29 19:08:54 2018 +0100 +++ b/memtest/stuff/bootloader.S Thu Feb 01 12:59:51 2018 +0100 @@ -1,8 +1,6 @@ // Image/zImage & tiny bzImage linux kernel boot sector, (C) SliTaz, GPL2. SYSSEG = 0x1000 -INITSEG = 0x9000 -SETUPSEG = 0x9020 setup_sects = 497 syssize = 500 cmd_line_ptr = 0x228 @@ -15,35 +13,77 @@ #define CODESZ 512 /* patched by installer */ +// Default kernel format is 386 Image/zImage //#define BZIMAGE 0x207 /* setup version ; for bzImage < 512 Kb only */ +//#define ELKS /* 8086/286 linux port */ /* some extra features */ -#define EXE_SUPPORT real mode dos .exe file support -#define CMDLINE kernel cmdline support -#define VCPI VCPI 4.0 support -#define SHUTDOWNDOS shutdown DOS services +#define EXE_SUPPORT real mode dos .exe file support +208/264 +#define CMDLINE dos kernel cmdline support +45 +#define VCPI VCPI 4.0 support (386+) +109 +#define SHUTDOWNDOS shutdown DOS services +29 /* some contraints to reduce the code size */ -//#define FLOPPY_1440K_ONLY 1.44M floppies support only -33 -//#define FLOPPY_HAS_2_SIDES hardcoded heads count to 2 -13 -//#define NO_CMDLINE_SHRINK remove heading spaces ? -6-20 -//#define NO_CMDLINE_FILE remove @cmdline file support ? -20 -//#define NO_DOTS show progression dots ? -8 +//#define FLOPPY_1440K_ONLY 1.44M floppies support only -26 +//#define FLOPPY_HAS_2_SIDES hardcoded heads count to 2 -15 +//#define NO_CMDLINE_SHRINK remove heading spaces ? -6-21 +//#define NO_CMDLINE_FILE remove @cmdline file support ? -21 +//#define NO_DOTS show progression dots ? -5 #ifndef BZIMAGE +//#define TINY_ZIMAGE system < 64Kb ? -11 //#defime NO_MINSETUP default setup (dos only) ? -4 //#define NO_CURSOR_DEFINITION -8 #endif +#ifdef ELKS + .arch i8086 +INITSEG = 0x0100 +SETUPSEG = 0x0120 +#define ONLY8086 +#undef BZIMAGE +#undef VCPI +#else +INITSEG = 0x9000 +SETUPSEG = 0x9020 +#endif + +.macro shlclw cnt,obj +#ifdef ONLY8086 + movb \cnt,%cl + shlw %cl,\obj +#else + shlw \cnt,\obj +#endif +.endm + +.macro shrclw cnt,obj +#ifdef ONLY8086 + movb \cnt,%cl + shrw %cl,\obj +#else + shrw \cnt,\obj +#endif +.endm + #ifdef EXE_SUPPORT #define EXEADRS(x) (x+0xE0) #define FLAT20(x) (x+16*INITSEG) .macro trace_int19 +#ifdef ONLY8086 + xorw %si, %si + movw %si, %ds + pushw 4+2(%si) + pushw 4(%si) + movw $step19, 4(%si) + movw $INITSEG, 4+2(%si) +#else pushl $4 popw %si popw %ds pushl (%si) movl $step19+(INITSEG<<16), (%si) +#endif pushfw popw %ax incb %ah # set TF @@ -68,17 +108,19 @@ .word 0xFFF0 // Initial (relative) CS value // .word 0x001C // File address of relocation table // .word 0,0,0 // Overlay number +#else +#undef VCPI #endif start: xorw %ax, %ax # %ax = 0 -#ifdef BZIMAGE -zeroed = 14 # zeroed registers -#else zeroed = 12 # zeroed registers -#endif movw $zeroed/2, %cx # clear gdt + offset, %ds, limits stacktop = 0x9E00 # in 0x8000 .. 0xA000 (+zeroed+12) +#ifdef ONLY8086 + movw $INITSEG, %bx +#else pushw $INITSEG +#endif end_header: cld # assume nothing #if defined(BZIMAGE) && BZIMAGE >= 0x202 @@ -90,6 +132,9 @@ # length of bootsect + length of # setup + room for stack; # 12 is disk parm size. +# ifdef ONLY8086 + pushw %bx +# endif popw %es # %es contain INITSEG #endif pushw %es @@ -115,7 +160,6 @@ stosw # already done above popw %bx # offset = 0 popw %ds # %ds = 0 - popw %fs # %fs = 0 movb setup_sects+0x7C00, %al # read bootsector + setup (%ds = 0) incw %ax @@ -123,14 +167,20 @@ ldsw 0x78(%bx), %si # %ds:%bx+0x78 is parameter table address pushw %es pushw %di + pushw %ds movb $6, %cl # copy 12 bytes rep # don't worry about cld movsw # already done above + popw %ds +#ifdef ONLY8086 + popw 0x78(%bx) # update parameter table address + popw 0x78+2(%bx) +#else + popl 0x78(%bx) # update parameter table address +#endif pushw %ss popw %ds # now %ds = %es = %ss = INITSEG - popl %fs:0x78(%bx) # update parameter table address movb $63, 0x4-12(%di) # patch sector count, %di = stacktop - cli xchg %ax, %di # sector count popw %ax # limits = 0 @@ -141,12 +191,9 @@ # no 64kB boundaries are crossed. We try to load it as fast as # possible, loading whole tracks whenever we can. -#ifndef NO_DOTS - popw %bx # clear %bx -#endif movw syssize, %di decw %di - shrw $9-4, %di + shrclw $9-4, %di incw %di movw $SYSSEG, %cx #ifdef BZIMAGE @@ -206,6 +253,7 @@ jne syslp #endif jmp_setup: + cli ljmp $SETUPSEG, $0 #ifdef EXE_SUPPORT @@ -226,16 +274,44 @@ pushw %cs popw %ss movw $stacktop-4-16, %sp +#ifdef ONLY8086 + popw 4(%si) + popw 4+2(%si) + popw %bp + popw %di + popw %si + popw %dx + popw %cx + popw %bx + popw %ax +#else popl 4(%si) popaw +#endif #ifdef BZIMAGE jmp movesys #endif #endif #ifndef BZIMAGE movesys: // %ax = SYSSEG, %bx = DS, %si - shrw $4, %si + shrclw $4, %si addw %si, %bx +#ifdef TINY_ZIMAGE + movw $0xFFFF, %cx + xorw %si, %si + xorw %di, %di + cmpw %ax, %bx + jc forward + decw %si + decw %di + std +forward: + movw %ax, %es + movw %bx, %ds + rep + movsb + cld +#else subw %ax, %bx jnc forward movb $0x90, %ah @@ -255,6 +331,7 @@ rep movsb jns forward +#endif #ifndef NO_CURSOR_DEFINITION movb $1, %ah movb $0, %bh @@ -267,7 +344,12 @@ #endif comstart: cld # assume nothing +#ifdef ONLY8086 + movw $INITSEG, %ax + pushw %ax +#else pushw $INITSEG +#endif popw %es #ifdef CMDLINE movw %sp, %di @@ -345,7 +427,6 @@ int $0x67 movl $FLAT20(sw2pm_params),%esi movb $0x0C,%al // DE0C switchpm(ESI) - cli jmp call_vcpi pm_code: movl %cr0,%eax @@ -362,7 +443,17 @@ # endif #else # ifdef SHUTDOWNDOS +# ifdef ONLY8086 + pushw %ax + pushw %bx + pushw %cx + pushw %dx + pushw %si + pushw %di + pushw %bp +# else pushaw +# endif trace_int19 # endif retf @@ -386,7 +477,6 @@ return: #ifndef NO_DOTS movw $0xE2E,%ax - movb $7,%bl int $0x10 #endif ret @@ -405,21 +495,26 @@ ja next_cylinder # no -> store it check_cylinder: #endif -#endif - pushaw -#ifndef FLOPPY_1440K_ONLY + pushw %ax cbw # %ah = 0 +#else + pushw %dx #endif int $0x13 # reset controler - popaw +#ifndef FLOPPY_1440K_ONLY + popw %ax movb $1, %al # sector by sector... +#else + movw $1, %ax + jmp more1trk +#endif read_sectorslp: pushw %dx # some bios break dx... #ifndef FLOPPY_1440K_ONLY pushw %ax # limits subb %cl, %al # sectors remaining in track ja tolastsect - movb $1, %al # 1 sector mini + movb $1, %al # first track sector by sector tolastsect: #else movb $FLOPPY_SECTORS+1, %al @@ -444,20 +539,20 @@ #ifndef FLOPPY_1440K_ONLY xchgw %ax, %bp addw %dx,%cx # next sector - movw %cx, %gs + movw %cx, %si + pushw %dx + shlclw $5, %dx movw %es, %cx - pushw %dx - shlw $5, %dx addw %dx, %cx popw %dx subw %dx,%di # update sector counter popw %dx #else addw %ax,%cx # next sector - movw %cx, %gs + movw %cx, %si + pushw %ax + shlclw $5, %ax movw %es, %cx - pushw %ax - shlw $5, %ax addw %ax, %cx popw %ax subw %ax,%di # update sector counter @@ -466,10 +561,10 @@ movw %cx, %es # next location jz return read_sectors: - movw %gs, %cx + movw %si, %cx #ifndef FLOPPY_1440K_ONLY # al is last sector+1 -# ah is last cylinder+1 +# ah is last head+1 xchgw %ax, %bp #endif #ifndef FLOPPY_1440K_ONLY @@ -552,3 +647,8 @@ .word stacktop-4-16-4,INITSEG # endif #endif +#ifdef ELKS + .org 0x1E3 + .byte 13,10,7 + .asciz "ELKS Boot" +#endif diff -r 06a7eacc4e80 -r 1421f93cc28a memtest/stuff/unlzma.S --- a/memtest/stuff/unlzma.S Mon Jan 29 19:08:54 2018 +0100 +++ b/memtest/stuff/unlzma.S Thu Feb 01 12:59:51 2018 +0100 @@ -106,13 +106,27 @@ */ mov $ws1, CX +#ifdef ONLY8086 + movw $2048/2, %ax +lzd1: + pushw %ax +#else lzd1: pushw $2048/2 +#endif loop lzd1 mov SP, BP movb $((LOCALS+3)/4)*2, %cl +#ifdef ONLY8086 + movw $1, %ax + cwd +initlocals: + pushw %dx + pushw %ax +#else initlocals: pushl $1 +#endif loop initlocals #if !defined(FLAT32) && !defined(FLAT16OUT) @@ -175,12 +189,22 @@ // ((((nowPos) & literalPosMask) << lc) + (previousByte >> (8 - lc)))); #if PROP_LC != 0 +# ifdef ONLY8086 + movb $8-PROP_LC, %cl + shrb %cl, %bl +# else shrb $8-PROP_LC, %bl +# endif #endif #if PROP_LP != 0 movb posState2(BP), %dl +# ifdef ONLY8086 + movb $PROP_LC, %cl + shl %cl, DX +# else shl $PROP_LC, DX +# endif movb $0, %bh add BX, DX #endif @@ -338,6 +362,23 @@ // rep1 = rep0; rep0 = distance; lzd11z: +# ifdef ONLY8086 + shl $1, CX + shl $1, CX // 8->32 bits + sub CX, DI // &rep[cx] + movw (BP, DI), %ax + pushw 2(BP, DI) +rotreplp: + movb 4(BP, DI), %bl + movb %bl, (BP, DI) + inc DI + loop rotreplp + popw %bx + testb %dh, %dh + jnz lzd10 + movw %ax, (BP, DI) + movw %bx, 2(BP, DI) +# else shl $2, CX // 8->32 bits sub CX, DI // &rep[cx] movl (BP, DI), %eax @@ -349,6 +390,7 @@ testb %dh, %dh jnz lzd10 movl %eax, (BP, DI) +# endif // } lzd12: @@ -497,7 +539,17 @@ // rep0 <<= numDirectBits; neg AX +# ifdef ONLY8086 + pushw %cx + movb $0, %ch +shllrep0: + shlw $1, (BP, DI) + rclw $1, 2(BP, DI) + loop shllrep0 + popw %cx +# else shll %cl, (BP, DI) +# endif add (BP, DI), AX // prob = p + SpecPos /*688*/ + rep0 - posSlot - 1; @@ -515,6 +567,26 @@ lzd23z: call RC_NORMALIZE +# ifdef ONLY8086 + pushw %dx + shrw $1, Range+2(BP) + rcrw $1, Range(BP) + movw Range(BP), %ax + movw Range+2(BP), %dx + cmpw Code+2(BP), %dx + ja lzd25 + jb lzd25x + cmpw Code(BP), %ax + ja lzd25 +lzd25x: + subw %ax, Code(BP) + sbbw %dx, Code+2(BP) + stc +lzd25: + popw %dx + rclw $1, (BP, DI) + rclw $1, 2(BP, DI) +# else shrl $1, Range(BP) movl Range(BP), %eax cmpl Code(BP), %eax @@ -523,6 +595,7 @@ stc lzd25: rcll $1, (BP, DI) +# endif // } while (--numDirectBits != 0); @@ -532,7 +605,17 @@ // prob = p + Align /* 802 */; numDirectBits = kNumAlignBits /*4*/; // rep0 <<= numDirectBits; +# ifdef ONLY8086 + pushw %cx + movb $0, %ch +shlrep0: + shlw $1, (BP, DI) + rclw $1, 2(BP, DI) + loop shlrep0 + popw %cx +# else shll %cl, (BP, DI) +# endif mov $802, AX // } @@ -554,7 +637,13 @@ lzd22: // if (++rep0 == (UInt32)(0)) break; /* EOF */ +# ifdef ONLY8086 + incw (BP, DI) + jnz lzd19 + incw 2(BP, DI) +# else incl (BP, DI) +# endif lzd19: pop CX @@ -610,6 +699,24 @@ Dico2ESDI: #if !defined(FLAT32) && !defined(FLAT16OUT) +# ifdef ONLY8086 + pushw %ax + movw nowPos(%bp), %bx + movw nowPos+2(%bp), %ax + jnc Dico2ESDIz + subw rep0(%bp), %bx + sbbw rep0+2(%bp), %ax +Dico2ESDIz: + movw $0xF, %di + andw %bx, %di + pushw %cx + movb $4, %cl + shrw %cl, %bx + shlw %cl, %ax + popw %cx + addb %al, %bh + popw %ax +# else movl nowPos(%bp), %ebx jnc Dico2ESDIz subl rep0(%bp), %ebx @@ -617,6 +724,7 @@ movw %bx, %di xorw %bx, %bx shrl $4, %ebx +# endif movw %bx, %es #else mov nowPos(BP), DI @@ -673,7 +781,14 @@ andb $((1 << PROP_LP) -1), posState2(BP) # endif #endif +#ifdef ONLY8086 + incw nowPos(BP) + jnz incnowPosDone + incw nowPos+2(BP) +incnowPosDone: +#else incl nowPos(BP) +#endif ret // @@ -690,8 +805,20 @@ jne RC_NORMALIZE_1 RC_LOAD_BYTE: push AX +#ifdef ONLY8086 + movw Range+1(BP), %ax + movw %ax, Range+2(BP) + movw Code+1(BP), %ax + movw %ax, Code+2(BP) + xorw %ax, %ax + movb Range(BP), %ah + movw %ax, Range(BP) + movb Code(BP), %ah + movw %ax, Code(BP) +#else shll $8, Range(BP) shll $8, Code(BP) +#endif #if !defined(FLAT16) && !defined(FLAT32) testw %si, %si jns RC_READ_BYTE @@ -741,7 +868,14 @@ call RC_NORMALIZE // kill %ax, update %si +#ifdef ONLY8086 + pushw %ax + pushw %cx + pushw %dx + pushw %di +#else pushal +#endif xchg AX, DI add DI, DI // short * @@ -749,19 +883,48 @@ // bound = (Range>>kNumBitModelTotalBits /*11*/) * *(p); +#ifdef ONLY8086 + movw Range(BP), %dx + movw Range+2(BP), %ax + movw $11, %cx +shr11lp: + shrw $1, %ax + rcrw $1, %dx + loop shr11lp + movw %dx, %cx + mulw (BP, DI) + xchgw %ax, %cx + mulw (BP, DI) + addw %cx, %dx +#else movl Range(BP), %eax shrl $11, %eax movzwl (BP, DI), %edx mull %edx +#endif // if (Code < bound) { +#ifdef ONLY8086 + cmpw Code+2(BP), %dx + jb Bit1_1 + ja Bit1_1x + cmpw Code(BP), %ax + jbe Bit1_1 +Bit1_1x: + +// Range = bound; + + movw %ax, Range(BP) + movw %dx, Range+2(BP) +#else cmpl Code(BP), %eax jbe Bit1_1 // Range = bound; movl %eax, Range(BP) +#endif // *(p) += (kBitModelTotal /*2048*/ - *(p)) >> kNumMoveBits /*5*/; @@ -778,8 +941,15 @@ // Range -= bound; Code -= bound; +#ifdef ONLY8086 + subw %ax, Range(BP) + sbbw %dx, Range+2(BP) + subw %ax, Code(BP) + sbbw %dx, Code+2(BP) +#else subl %eax, Range(BP) subl %eax, Code(BP) +#endif // *(p) -= (*(p)) >> kNumMoveBits /*5*/; @@ -791,10 +961,22 @@ Bit1_2: pushf subw (BP, DI), %ax +#ifdef ONLY8086 + movb $5, %cl + sarw %cl, %ax +#else sarw $5, %ax +#endif addw %ax, (BP, DI) popf +#ifdef ONLY8086 + popw %di + popw %dx + popw %cx + popw %ax +#else popal +#endif sbb AX, AX // } diff -r 06a7eacc4e80 -r 1421f93cc28a memtest/stuff/unpack.S --- a/memtest/stuff/unpack.S Mon Jan 29 19:08:54 2018 +0100 +++ b/memtest/stuff/unpack.S Thu Feb 01 12:59:51 2018 +0100 @@ -1,4 +1,3 @@ -#define TOP (0x90000+_start-end) #define SYSTEM 0x10000 #define SETUP 14 #define SYSSIZE 0x1F4 @@ -11,11 +10,22 @@ #define FLAT16 1 //#define FLAT16OUT 0 #define SAVEREGS 0 +#define ELKS 1 .text .code16 .org 0 +#if ELKS + .arch i8086 +#define FLAT16 1 +#define LINUX_HEADER 0 +#define SAVEREGS 0 +#define TOPSEG 0x2000 +#else +#define TOPSEG 0x8000 +#endif + .globl _start _start: #if LINUX_HEADER @@ -50,20 +60,35 @@ pushw $0 # endif #endif +#if ELKS + movw $0x100, %ax + pushw %ax +#else #if UPDATE_SYSSIZE pushw %ds // #else pushw %cs // #endif +#endif #if FLAT16 -# 1- move 9020..9020+stp -> 8000 - pushw $0x8000 +# 1- move 9020..9020+stp -> TOPSEG +#if ELKS + movb $TOPSEG/256, %ah + movw %ax, %es +#else + pushw $TOPSEG popw %es +#endif movw $0x200, %si #if SAVEREGS == 0 pushw %es +#if ELKS + movw $cont, %ax + pushw %ax +#else // pushw $cont .byte 0x6A, cont +#endif jmp jumpinto #else # if HARDCODED_SETUPSIZE @@ -82,28 +107,48 @@ lret #endif cont: -# 2- move 1000..1000+sys -> 8000+stp +# 2- move 1000..1000+sys -> TOPSEG+stp +#if ELKS + movw $0x1000, %ax + movw %ax, %ds +#else pushw $0x1000 popw %ds +#endif xorw %si, %si subw %di, %cx rep movsb -# 3- unlz(8000+stp:end, 1000-stp:0) +# 3- unlz(TOPSEG+stp:end, 1000-stp:0) pushw %es // # if HARDCODED_SETUPSIZE setup_seg: +#if ELKS +# if UPDATE_SYSSIZE + movw $0x1000-(SETUP*32)-32, %ax +# else + movw $0x1000-(SETUP*32), %ax +# endif + movw %ax, %es +#else # if UPDATE_SYSSIZE pushw $0x1000-(SETUP*32)-32 # else pushw $0x1000-(SETUP*32) # endif popw %es +#endif # else # if UPDATE_SYSSIZE incb %dh # endif +#if ELKS + shrw $1, %dx + shrw $1, %dx + shrw $1, %dx +#else shrw $3, %dx +#endif movw %ds, %ax subw %dx, %ax movw %ax, %es @@ -140,7 +185,13 @@ # else movb %ss:SETUPSIZE, %ch movw %cx, %ax +#if ELKS + shrw $1, %ax + shrw $1, %ax + shrw $1, %ax +#else shrw $3, %ax +#endif subw %ax, %dx # endif pushw %cx // @@ -225,6 +276,9 @@ unpack: #define NO_LZMA_HEADER +#if ELKS +#define ONLY8086 1 +#endif #include "unlzma.S" end: