wok-current rev 19391
memtest: tiny shrink
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Aug 27 12:07:37 2016 +0200 (2016-08-27) |
parents | 7c66c894e9ba |
children | 867f233184fc |
files | memtest/stuff/pack memtest/stuff/unlzma.S memtest/stuff/unpack.S |
line diff
1.1 --- a/memtest/stuff/pack Wed Aug 24 18:11:12 2016 -0400 1.2 +++ b/memtest/stuff/pack Sat Aug 27 12:07:37 2016 +0200 1.3 @@ -1,12 +1,12 @@ 1.4 #!/bin/sh 1.5 if [ "$1" == "--build" ]; then 1.6 set -- ${2:-bootloader.bin} ${3:-unpack.bin} 1.7 - x=$(grep -s packed_syssize ${2/.bin/.lst}|sed '$!d;s/.*t:\([^ ]*\).*/\1/') 1.8 - [ -n "$x" ] && sed -i "s/XXXP/$((513+0x$x))/" $0 || sed -i s="/XXXP$/d" $0 1.9 - x=$(grep -s original_syssize ${2/.bin/.lst}|sed '$!d;s/.*t:\([^ ]*\).*/\1/') 1.10 - [ -n "$x" ] && sed -i "s/XXXO/$((513+0x$x))/" $0 || sed -i s="/XXXO$/d" $0 1.11 - x=$(grep -s original_setupsize ${2/.bin/.lst}|sed '$!d;s/.*t:\([^ ]*\).*/\1/') 1.12 - [ -n "$x" ] && sed -i "s/XXXS/$((516+0x$x))/" $0 || sed -i s="/XXXS$/d" $0 1.13 + x=$(grep -s packed_syssize$ ${2/.bin/.lst}|sed '$!d;s/.*t:\([^ ]*\).*/\1/') 1.14 + [ -n "$x" ] && sed -i "s/XXXP/$((513+0x$x))/" $0 || sed -i "/XXXP$/d" $0 1.15 + x=$(grep -s original_syssize$ ${2/.bin/.lst}|sed '$!d;s/.*t:\([^ ]*\).*/\1/') 1.16 + [ -n "$x" ] && sed -i "s/XXXO/$((513+0x$x))/" $0 || sed -i "/XXXO$/d" $0 1.17 + x=$(grep -s original_setupsize$ ${2/.bin/.lst}|sed '$!d;s/.*t:\([^ ]*\).*/\1/') 1.18 + [ -n "$x" ] && sed -i "s/XXXS/$((516+0x$x))/" $0 || sed -i "/XXXS$/d" $0 1.19 helpmsg=$(sed '/helpmsg:/!d{n;s/ [0-9]* \([^ ]*\).*/\1/}' ${1/.bin/.lst} | sed '$!d') 1.20 helpend=$(sed '/helpend:/!d{n;s/ [0-9]* \([^ ]*\).*/\1/}' ${1/.bin/.lst} | sed '$!d') 1.21 sed -i "s/YYY/$((0x$helpmsg))/" $0
2.1 --- a/memtest/stuff/unlzma.S Wed Aug 24 18:11:12 2016 -0400 2.2 +++ b/memtest/stuff/unlzma.S Sat Aug 27 12:07:37 2016 +0200 2.3 @@ -115,7 +115,7 @@ 2.4 pushl $1 2.5 loop initlocals 2.6 2.7 -#ifndef FLAT32 2.8 +#if !defined(FLAT32) && !defined(FLAT16OUT) 2.9 movb $4, %cl 2.10 movw %es, %bx 2.11 shrw %cl, %bx 2.12 @@ -127,7 +127,7 @@ 2.13 incw %cx 2.14 #else 2.15 movb $5, %cl 2.16 - movl %edi, outStream(%ebp) 2.17 + mov DI, outStream(BP) 2.18 #endif 2.19 2.20 // Byte previousByte = 0; 2.21 @@ -609,7 +609,7 @@ 2.22 */ 2.23 2.24 Dico2ESDI: 2.25 -#ifndef FLAT32 2.26 +#if !defined(FLAT32) && !defined(FLAT16OUT) 2.27 movl nowPos(%bp), %ebx 2.28 jnc Dico2ESDIz 2.29 subl rep0(%bp), %ebx 2.30 @@ -618,13 +618,16 @@ 2.31 xorw %bx, %bx 2.32 shrl $4, %ebx 2.33 movw %bx, %es 2.34 +#else 2.35 + mov nowPos(%bp), DI 2.36 + jnc Dico2ESDIz 2.37 + sub rep0(%bp), DI 2.38 +Dico2ESDIz: 2.39 +#endif 2.40 +#ifdef FLAT32 2.41 + movb (DI), %bl 2.42 +#else 2.43 movb %es:(%di), %bl 2.44 -#else 2.45 - movl nowPos(%bp), %edi 2.46 - jnc Dico2ESDIz 2.47 - subl rep0(%bp), %edi 2.48 -Dico2ESDIz: 2.49 - movb (%edi), %bl 2.50 #endif 2.51 ret 2.52 2.53 @@ -689,7 +692,7 @@ 2.54 push AX 2.55 shll $8, Range(BP) 2.56 shll $8, Code(BP) 2.57 -#ifndef FLAT32 2.58 +#if !defined(FLAT16) && !defined(FLAT32) 2.59 testw %si, %si 2.60 jns RC_READ_BYTE 2.61 movw %ds, %ax
3.1 --- a/memtest/stuff/unpack.S Wed Aug 24 18:11:12 2016 -0400 3.2 +++ b/memtest/stuff/unpack.S Sat Aug 27 12:07:37 2016 +0200 3.3 @@ -10,6 +10,9 @@ 3.4 #define HARDCODED_SYSSIZE 1 3.5 #define HARDCODED_SETUPSIZE 1 3.6 #define HARDCODED_IP 1 3.7 +#define SHUTDOWNDOS 0 3.8 +#define FLAT16 1 3.9 +//#define FLAT16OUT 0 3.10 3.11 .text 3.12 .code16 3.13 @@ -42,12 +45,49 @@ 3.14 getip: 3.15 #endif 3.16 pushal 3.17 +#if SHUTDOWNDOS 3.18 + xorw %si, %si 3.19 + movw %si, %ds # %ds = 0 3.20 + pushl 4(%si) 3.21 + movw %sp, %cs:loadsp19+1(%si) 3.22 + cmpb $0xF0, 7(%si) 3.23 + jnb notdos 3.24 + movw $step19, 4(%si) 3.25 + movw %cs, 6(%si) 3.26 + pushfw 3.27 + popw %ax 3.28 + incb %ah # set TF 3.29 + pushw %ax 3.30 + popfw 3.31 + ljmp *4*0x19(%si) 3.32 +step19: 3.33 + pushw %si 3.34 + pushw %ds 3.35 + movw %sp, %si 3.36 + ldsw %ss:4(%si), %si 3.37 + cmpw $0x19CD, (%si) 3.38 + popw %ds 3.39 + popw %si 3.40 + jne doiret 3.41 + xorw %si, %si 3.42 + mov %si, %ds 3.43 + popl 4*0x19(%si) 3.44 +notdos: 3.45 +loadsp19: 3.46 + movw $0, %sp 3.47 + popl 4(%si) 3.48 + pushw %ss 3.49 + popw %ds 3.50 +#endif 3.51 +#if !FLAT16 3.52 +#undef FLAT16 3.53 #if HARDCODED_SYSSIZE 3.54 packed_syssize: 3.55 movw $0, %bx // system size 3.56 #else 3.57 movw SYSSIZE, %bx 3.58 #endif 3.59 +#endif 3.60 #if HARDCODED_SETUPSIZE == 0 3.61 xorw %dx, %dx 3.62 movb SETUPSIZE, %dh 3.63 @@ -64,6 +104,39 @@ 3.64 pushw %es 3.65 3.66 cld 3.67 + 3.68 +#if FLAT16 3.69 +flat16mv: 3.70 +#if CHANGE_STACK 3.71 +STKSZ=0x9000-0x0990 3.72 + pushw $(TOP-STKSZ)/16-0x1000 3.73 +#else 3.74 + pushw $TOP/16-0x1000 3.75 +#endif 3.76 + popw %es 3.77 + pushw %es // moved 3.78 + .byte 0x6A, moved-_start // unpack code 3.79 + pushw %cs 3.80 + popw %ds 3.81 + xorw %di, %di 3.82 +#if HARDCODED_SETUPSIZE 3.83 + movw $SETUP*256, %cx 3.84 +#else 3.85 + xorw %cx, %cx 3.86 + movw SETUPSIZE, %ch 3.87 +#endif 3.88 + pushw %si 3.89 + rep 3.90 + movsw // move header part 3.91 + movw $0x1000, %bp 3.92 + movw %bp, %ds 3.93 + xorw %si, %si 3.94 + subw %di, %cx 3.95 + rep 3.96 + movsb // move system part 3.97 + popw %di 3.98 + movw $end-_start, %si 3.99 +#else 3.100 #if CHANGE_STACK 3.101 STKSZ=0x9000-0x0990 3.102 movw $(TOP-STKSZ)/16, %ax 3.103 @@ -77,6 +150,7 @@ 3.104 popw %ds 3.105 xorw %di, %di 3.106 movw $end-_start, %cx 3.107 + pushw %cx 3.108 pushw %si 3.109 rep 3.110 movsb // move upack code to $TOP 3.111 @@ -111,13 +185,13 @@ 3.112 pushw %si 3.113 rep 3.114 movsw // move header part 3.115 - 3.116 + popw %di 3.117 + popw %si 3.118 +#endif 3.119 pushw %es 3.120 popw %ds 3.121 - movw $end-_start, %si 3.122 pushw %cs 3.123 popw %es // restore setup seg 3.124 - popw %di 3.125 retf 3.126 3.127 moved: