# HG changeset patch # User Pascal Bellard # Date 1472292457 -7200 # Node ID 3b334b26197f6ad82bb9c9f35961ca80e84e8bac # Parent 7c66c894e9badfcab1e942c2cdab620015450487 memtest: tiny shrink diff -r 7c66c894e9ba -r 3b334b26197f memtest/stuff/pack --- a/memtest/stuff/pack Wed Aug 24 18:11:12 2016 -0400 +++ b/memtest/stuff/pack Sat Aug 27 12:07:37 2016 +0200 @@ -1,12 +1,12 @@ #!/bin/sh if [ "$1" == "--build" ]; then set -- ${2:-bootloader.bin} ${3:-unpack.bin} - x=$(grep -s packed_syssize ${2/.bin/.lst}|sed '$!d;s/.*t:\([^ ]*\).*/\1/') - [ -n "$x" ] && sed -i "s/XXXP/$((513+0x$x))/" $0 || sed -i s="/XXXP$/d" $0 - x=$(grep -s original_syssize ${2/.bin/.lst}|sed '$!d;s/.*t:\([^ ]*\).*/\1/') - [ -n "$x" ] && sed -i "s/XXXO/$((513+0x$x))/" $0 || sed -i s="/XXXO$/d" $0 - x=$(grep -s original_setupsize ${2/.bin/.lst}|sed '$!d;s/.*t:\([^ ]*\).*/\1/') - [ -n "$x" ] && sed -i "s/XXXS/$((516+0x$x))/" $0 || sed -i s="/XXXS$/d" $0 + x=$(grep -s packed_syssize$ ${2/.bin/.lst}|sed '$!d;s/.*t:\([^ ]*\).*/\1/') + [ -n "$x" ] && sed -i "s/XXXP/$((513+0x$x))/" $0 || sed -i "/XXXP$/d" $0 + x=$(grep -s original_syssize$ ${2/.bin/.lst}|sed '$!d;s/.*t:\([^ ]*\).*/\1/') + [ -n "$x" ] && sed -i "s/XXXO/$((513+0x$x))/" $0 || sed -i "/XXXO$/d" $0 + x=$(grep -s original_setupsize$ ${2/.bin/.lst}|sed '$!d;s/.*t:\([^ ]*\).*/\1/') + [ -n "$x" ] && sed -i "s/XXXS/$((516+0x$x))/" $0 || sed -i "/XXXS$/d" $0 helpmsg=$(sed '/helpmsg:/!d{n;s/ [0-9]* \([^ ]*\).*/\1/}' ${1/.bin/.lst} | sed '$!d') helpend=$(sed '/helpend:/!d{n;s/ [0-9]* \([^ ]*\).*/\1/}' ${1/.bin/.lst} | sed '$!d') sed -i "s/YYY/$((0x$helpmsg))/" $0 diff -r 7c66c894e9ba -r 3b334b26197f memtest/stuff/unlzma.S --- a/memtest/stuff/unlzma.S Wed Aug 24 18:11:12 2016 -0400 +++ b/memtest/stuff/unlzma.S Sat Aug 27 12:07:37 2016 +0200 @@ -115,7 +115,7 @@ pushl $1 loop initlocals -#ifndef FLAT32 +#if !defined(FLAT32) && !defined(FLAT16OUT) movb $4, %cl movw %es, %bx shrw %cl, %bx @@ -127,7 +127,7 @@ incw %cx #else movb $5, %cl - movl %edi, outStream(%ebp) + mov DI, outStream(BP) #endif // Byte previousByte = 0; @@ -609,7 +609,7 @@ */ Dico2ESDI: -#ifndef FLAT32 +#if !defined(FLAT32) && !defined(FLAT16OUT) movl nowPos(%bp), %ebx jnc Dico2ESDIz subl rep0(%bp), %ebx @@ -618,13 +618,16 @@ xorw %bx, %bx shrl $4, %ebx movw %bx, %es +#else + mov nowPos(%bp), DI + jnc Dico2ESDIz + sub rep0(%bp), DI +Dico2ESDIz: +#endif +#ifdef FLAT32 + movb (DI), %bl +#else movb %es:(%di), %bl -#else - movl nowPos(%bp), %edi - jnc Dico2ESDIz - subl rep0(%bp), %edi -Dico2ESDIz: - movb (%edi), %bl #endif ret @@ -689,7 +692,7 @@ push AX shll $8, Range(BP) shll $8, Code(BP) -#ifndef FLAT32 +#if !defined(FLAT16) && !defined(FLAT32) testw %si, %si jns RC_READ_BYTE movw %ds, %ax diff -r 7c66c894e9ba -r 3b334b26197f memtest/stuff/unpack.S --- a/memtest/stuff/unpack.S Wed Aug 24 18:11:12 2016 -0400 +++ b/memtest/stuff/unpack.S Sat Aug 27 12:07:37 2016 +0200 @@ -10,6 +10,9 @@ #define HARDCODED_SYSSIZE 1 #define HARDCODED_SETUPSIZE 1 #define HARDCODED_IP 1 +#define SHUTDOWNDOS 0 +#define FLAT16 1 +//#define FLAT16OUT 0 .text .code16 @@ -42,12 +45,49 @@ getip: #endif pushal +#if SHUTDOWNDOS + xorw %si, %si + movw %si, %ds # %ds = 0 + pushl 4(%si) + movw %sp, %cs:loadsp19+1(%si) + cmpb $0xF0, 7(%si) + jnb notdos + movw $step19, 4(%si) + movw %cs, 6(%si) + pushfw + popw %ax + incb %ah # set TF + pushw %ax + popfw + ljmp *4*0x19(%si) +step19: + pushw %si + pushw %ds + movw %sp, %si + ldsw %ss:4(%si), %si + cmpw $0x19CD, (%si) + popw %ds + popw %si + jne doiret + xorw %si, %si + mov %si, %ds + popl 4*0x19(%si) +notdos: +loadsp19: + movw $0, %sp + popl 4(%si) + pushw %ss + popw %ds +#endif +#if !FLAT16 +#undef FLAT16 #if HARDCODED_SYSSIZE packed_syssize: movw $0, %bx // system size #else movw SYSSIZE, %bx #endif +#endif #if HARDCODED_SETUPSIZE == 0 xorw %dx, %dx movb SETUPSIZE, %dh @@ -64,6 +104,39 @@ pushw %es cld + +#if FLAT16 +flat16mv: +#if CHANGE_STACK +STKSZ=0x9000-0x0990 + pushw $(TOP-STKSZ)/16-0x1000 +#else + pushw $TOP/16-0x1000 +#endif + popw %es + pushw %es // moved + .byte 0x6A, moved-_start // unpack code + pushw %cs + popw %ds + xorw %di, %di +#if HARDCODED_SETUPSIZE + movw $SETUP*256, %cx +#else + xorw %cx, %cx + movw SETUPSIZE, %ch +#endif + pushw %si + rep + movsw // move header part + movw $0x1000, %bp + movw %bp, %ds + xorw %si, %si + subw %di, %cx + rep + movsb // move system part + popw %di + movw $end-_start, %si +#else #if CHANGE_STACK STKSZ=0x9000-0x0990 movw $(TOP-STKSZ)/16, %ax @@ -77,6 +150,7 @@ popw %ds xorw %di, %di movw $end-_start, %cx + pushw %cx pushw %si rep movsb // move upack code to $TOP @@ -111,13 +185,13 @@ pushw %si rep movsw // move header part - + popw %di + popw %si +#endif pushw %es popw %ds - movw $end-_start, %si pushw %cs popw %es // restore setup seg - popw %di retf moved: