~ubuntu-branches/debian/sid/upx-ucl/sid

« back to all changes in this revision

Viewing changes to src/stub/l_exe.asm

  • Committer: Bazaar Package Importer
  • Author(s): Robert Luberda
  • Date: 2006-06-13 21:23:23 UTC
  • mfrom: (1.3.1 upstream) (3.1.2 edgy)
  • Revision ID: james.westby@ubuntu.com-20060613212323-343yzs4jt6vr5483
* New upstream version.
* Standards-Version: 3.7.2 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
                SECTION .text
36
36
                CPU     8086
37
37
 
 
38
;       __DEVICEENTRY__
 
39
 
 
40
                dd      -1
 
41
                dw      0
 
42
                dw      strategy        ; .sys header
 
43
                dw      0               ; opendos wants this field untouched
 
44
original_strategy:
 
45
                dw      'ST'
 
46
strategy:
 
47
                push    cs
 
48
                push    word [cs:original_strategy]
 
49
                push    ax
 
50
                push    bx
 
51
                push    cx
 
52
                push    dx
 
53
                mov     ax, cs
 
54
                add     ax, 'OS'        ; calculate normal EXE stack
 
55
                mov     bx, 'OP'
 
56
                mov     cx, ss
 
57
                mov     dx, sp
 
58
                mov     ss, ax          ; switch to stack EXE normally has
 
59
                mov     sp, bx
 
60
                push    cx              ; save device stack on EXE stack
 
61
                push    dx
 
62
                push    si
 
63
                push    di
 
64
                push    bp
 
65
                push    ds
 
66
                push    es
 
67
                db      0x72            ; "jc 0xf9" but flag C is 0 => nop
 
68
exe_as_device_entry:
 
69
                stc                     ; flag C is 1
 
70
                pushf
 
71
 
38
72
; =============
39
73
; ============= ENTRY POINT
40
74
; =============
41
75
;       __EXEENTRY__
 
76
exe_entry:
42
77
                mov     cx, 'CX'        ; first_copy_len/2
43
78
                mov     si, 'SI'        ; cx*2-2
44
79
                mov     di, si
47
82
do_copy:
48
83
                mov     ch, 0x80        ; 64 kbyte
49
84
                mov     ax, cs
50
 
                add     ax, 'DS'
 
85
addaxds:
 
86
                add     ax, 'DS'        ; MSB is referenced by the "sub" below
51
87
                mov     ds, ax
52
88
                add     ax, 'ES'
53
89
                mov     es, ax
56
92
                rep
57
93
                movsw
58
94
                cld
59
 
 
60
 
                sub     [byte cs:si+do_copy+6+2], byte 0x10
 
95
;       __DEVICESUB__
 
96
                sub     [byte cs:si + addaxds + 4], byte 0x10
 
97
;       __EXESUB__
 
98
                sub     [byte cs:si + addaxds - exe_entry + 4], byte 0x10
 
99
;       __JNCDOCOPY__
61
100
                jnc     do_copy
62
101
                xchg    ax, dx
63
102
                scasw
152
191
                pop     es
153
192
                push    es
154
193
                pop     ds
 
194
 
 
195
;       __DEVICEEND__
 
196
                popf
 
197
                jc      loaded_as_exe
 
198
                pop     es
 
199
                pop     ds
 
200
                pop     bp
 
201
                pop     di
 
202
                pop     si
 
203
                pop     bx              ; get original device SS:SP
 
204
                pop     ax
 
205
                mov     ss, ax          ; switch to device driver stack
 
206
                mov     sp, bx
 
207
                pop     dx
 
208
                pop     cx
 
209
                pop     bx
 
210
                pop     ax
 
211
                retf                    ; return to original strategy
 
212
 
 
213
loaded_as_exe:
155
214
%ifdef  __EXESTACK__
156
215
                lea     ax, ['SS'+bp]
157
216
                mov     ss, ax