📄 m68k-atari.tos.s
字号:
section nrv2d.init //moveq.l #-1,d5 // last_off = -1 moveq.l #-128,d0 // d0.b = $80 moveq.l #-1,d7 moveq.l #-0x50,d6 // 0xffffffb0 lsl.w #4,d6 // 0xfffffb00 == -0x500 // a3 still points to the start of the compressed block move.l d4,a4 // dest. for decompressingsection nrv2e.init //moveq.l #-1,d5 // last_off = -1 moveq.l #-128,d0 // d0.b = $80 moveq.l #0,d7 moveq.l #-0x50,d6 // 0xffffffb0 lsl.w #4,d6 // 0xfffffb00 == -0x500 // a3 still points to the start of the compressed block move.l d4,a4 // dest. for decompressing// ------------- jump to copied decompressorsection jmp_decompressor_a6.w jmp up31_a6:w(a6) // jmp decompr_startsection jmp_decompressor_d4.w move.l d4,a0 jmp up31_d4:w(a0) // jmp decompr_startsection jmp_decompressor_a6.w2 lea.l 32767(a6),a0 jmp up31_a6:w(a0) // jmp decompr_startsection jmp_decompressor_d4.l move.l d4,a0 add.l #up31_d4,a0 jmp (a0) // jmp decompr_start/*************************************************************************// this is the final part of the startup code which runs in the stack**************************************************************************/section code_on_stack // on entry: // ASTACK == pc == code_on_stack (on stack) // a6 start of dirty bss [long living register] // d6 number of clr loops for clear_dirty_bss // d3.l 0// ------------- clear dirty bsssection clear_dirty_bsssection loop3_labelsection loop3.small move.l d3,(a6)+section loop3.fast // the dirty bss is usually not too large, so we don't // bother making movem optimizations here move.l d3,(a6)+ move.l d3,(a6)+ move.l d3,(a6)+ move.l d3,(a6)+section loop3_subql subq.l #1,d6 bnes loop3_labelsection loop3_subqw subq.w #1,d6 bnes loop3_labelsection loop3_dbra dbra d6,loop3_label// ------------- flush the cache#ifdef FLUSH_CACHE// info:// This is also called as a subroutine (before decompression, NOT running// in the stack). When running in the stack the `rts' is replaced by a `nop'.section flush_cache FLUSH_CACHEGL(flush_cache_rts) // for flush_cache_rts_offset rts#endif// ------------- restore stacksection restore_stack lea code_on_stack_end+4:w(pc),sp// ------------- clear the dirty stacksection clear_dirty_stack // clear down to code_on_stack(pc) + 32 extra longs ////moveq.l #((clear_dirty_stack_loop-code_on_stack+3)/4+32-1),d0 moveq.l #clear_dirty_stack_len,d0 lea 1f(pc),a0GL(clear_dirty_stack_loop) // for clear_dirty_stack_len1: move.l d3,-(a0) dbra d0,1b// ------------- start programsection start_program movem.l (sp)+,d1-d7/a0-a6 move.l a0,d0 beqs 1f sub.l sp,sp // accessory: no stack1: dc.w 0x4ef9 // jmp $xxxxxxxx - jmp to text segmentGL(code_on_stack_end) // for copy_to_stack_len/*************************************************************************// UPX ident & packheader**************************************************************************/// IDENTSTR// align4#include "include/header.S" // end of text segment - size is a multiple of 4/*************************************************************************// This part is appended after the compressed data.// It runs in the last part of the dirty bss (after the// relocations and the original fileheader).**************************************************************************/section CUTPOINT// ------------- decompress (from a3 to a4)#define a0 A3#define a1 A4#define a3 A2#define d2 D3#define L(label) .L ## label#define NRV_BB 8#undef SMALLsection nrv2b_8.fast# define N(x) nrv2b_8_fast_ ## x# include "arch/m68k/rename.ash"# include "arch/m68k/nrv2b_d.ash"# undef Nsection nrv2d_8.fast# define N(x) nrv2d_8_fast_ ## x# include "arch/m68k/rename.ash"# include "arch/m68k/nrv2d_d.ash"# undef Nsection nrv2e_8.fast# define N(x) nrv2e_8_fast_ ## x# include "arch/m68k/rename.ash"# include "arch/m68k/nrv2e_d.ash"# undef N#define SMALL 1section nrv2b_8.small# define N(x) nrv2b_8_small_ ## x# include "arch/m68k/rename.ash"# include "arch/m68k/nrv2b_d.ash"# undef Nsection nrv2d_8.small# define N(x) nrv2d_8_small_ ## x# include "arch/m68k/rename.ash"# include "arch/m68k/nrv2d_d.ash"# undef Nsection nrv2e_8.small# define N(x) nrv2e_8_small_ ## x# include "arch/m68k/rename.ash"# include "arch/m68k/nrv2e_d.ash"# undef N#include "arch/m68k/rename.ash"#undef L#undef NRV_BB#undef SMALL#undef a0#undef a1#undef a3#undef d2#include "arch/m68k/lzma_d.S" // note: d3.l is 0 from decompressor above// ------------- relocsection reloc// The decompressed relocations now are just after the decompressed// data segment, i.e. at the beginning of the (dirty) bss. // note: d3.l is still 0 move.l a6,a0 // a0 = start of relocations moveq.l #1,d1 move.l d4,a1 add.l (a0)+,a1 // get initial fixup1: add.l d3,a1 // increase fixup add.l d4,(a1) // reloc one address2: move.b (a0)+,d3 beqs 3f cmp.b d1,d3 // note: d1.b is #1 from above bnes 1b lea 254(a1),a1 // d3 == 1 -> add 254, don't reloc bras 2b3: // note: d3.l is still 0// ------------- clear dirty bss & start program // number of loopssection loop3_set_count.b moveq.l #loop3_count,d6section loop3_set_count.w move.w #loop3_count,d6section loop3_set_count.l move.l #loop3_count,d6section jmp_stack// We are currently running in the dirty bss.// Jump to the code we copied below the stack. jmp (ASTACK) // jmp code_on_stack (on stack)/*************************************************************************// support**************************************************************************/section __mulsi3#if 0 // compute high-word move.w 4(sp),d1 // 12 move.w 6(sp),d0 // 12 mulu.w 8(sp),d0 // 78 mulu.w 10(sp),d1 // 78 add.w d1,d0 // 4 swap d0 // 4 clr.w d0 // 4 // add low-word move.w 6(sp),d1 // 12 mulu.w 10(sp),d1 // 78 add.l d1,d0 // 6 rts // 16#else // slightly smaller and faster // compute high-word lea 4(sp),a0 // 8 move.w (a0)+,d1 // 8 move.w (a0)+,d0 // 8 mulu.w (a0)+,d0 // 74 mulu.w (a0),d1 // 74 add.w d1,d0 // 4 swap d0 // 4 clr.w d0 // 4 // add low-word move.w 6(sp),d1 // 12 mulu.w (a0),d1 // 74 add.l d1,d0 // 6 rts // 16#endif/*************************************************************************// absolute symbols ("*ABS*")**************************************************************************/#if 0section abs_symbols#define N(a,b) \ .globl a##_##b##_start_offset; \ a##_##b##_start_offset = a##_##b##_decompr_start - a.bN(nrv2b_8,fast)N(nrv2d_8,fast)N(nrv2e_8,fast)N(nrv2b_8,small)N(nrv2d_8,small)N(nrv2e_8,small)#undef N#define N(a,b) \ .globl a##_##b##_start_offset; a##_##b##_start_offset = 0N(lzma,fast)N(lzma,small)#undef N#endif// vi:ts=4:et:nowrap
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -