wok view linld/stuff/jump.u @ rev 20458
Up amule (2.3.2)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Oct 10 10:43:41 2018 +0200 (2018-10-10) |
parents | df186455938f |
children |
line source
1 --- LINLD097/JUMP.ASM
2 +++ LINLD097/JUMP.ASM
3 @@ -7,9 +7,16 @@
4 %nomacs
5 p386
7 - group DGROUP _TEXT
8 + group DGROUP _TEXT,_DATA
9 assume cs:DGROUP,ds:DGROUP
11 + segment _DATA byte public use16 'DATA'
12 +
13 + global _saved15:dword
14 + global _first1k:word
15 +
16 + ends _DATA
17 +
18 segment _TEXT byte public use16 'CODE'
20 ;***************************************************************
21 @@ -19,38 +26,102 @@
22 global _set_sregs_jump_seg_ofs:near
23 proc _set_sregs_jump_seg_ofs near
25 - arg sreg :word, \
26 - stk :word, \
27 - jmpseg :word, \
28 - jmpofs :word = PARAM_SIZE
29 -
30 - push bp ;TODO: kinda useless, isn't it?
31 - mov bp,sp
32 -
33 - ;;mov ax,[jmpseg] ;Move data to CS segment var
34 - ;;mov [seg2],ax ; we cannot use any other seg!
35 - ;;mov ax,[jmpofs] ;
36 - ;;mov [ofs2],ax ;
37 - mov cx,[jmpofs] ;Do NOT load in r32:
38 - mov dx,[jmpseg] ; wrong order!
39 -
40 - mov ax,[sreg]
41 - mov sp,[stk] ;Do not use [bp+n] after this...
42 - mov ds,ax
43 - mov es,ax
44 - mov ss,ax
45 - mov fs,ax
46 - mov gs,ax
47 + mov bx, 202h
48 + add bx,[_first1k]
49 + cmp [dword bx],'SrdH' ; head version >= 2 ?
50 + jne oldzimage
51 + test [byte bx+0Fh],1 ; load high ? (clear C)
52 + jne isbzimage
53 +oldzimage:
54 + ; finish loading
55 + extrn @last_ditch$qv
56 + push cs
57 + call near @last_ditch$qv
58 + ; self move
59 + cld
60 + push 9820h ; 512 bytes for cmdline
61 + pop es
62 + xor di,di
63 + mov si,di
64 + extrn _bss_end
65 + mov cx,offset _bss_end
66 + rep
67 + movsb
68 + push es
69 + call near doretf
70 + stc
71 +isbzimage:
72 + pop ax ;caller return address
73 + pop dx ; jmpseg
74 + pop bx ; jmpofs
75 + pop ax ; stk
76 + pop ss ; sseg
77 + xchg sp,ax
78 + push dx bx
79 + jnc nomove
80 + ; DOS shutdown
81 + xor si,si
82 + mov ds,si
83 + push [dword si+4]
84 + mov [word cs:loadsp19+1],sp
85 + ;cmp [byte si+7],0F0h
86 + ;jnc notdos
87 + mov [word si+4],offset step19
88 + mov [si+6],cs
89 + pushf
90 + pop ax
91 + inc ah
92 + push ax
93 + popf
94 + jmp small [dword si+4*19h]
95 +doiret:
96 + iret
97 +step19:
98 + push si
99 + push ds
100 + mov si,sp
101 + lds si,[dword ss:si+4]
102 + cmp [word si],19CDh
103 + pop ds
104 + pop si
105 + jne doiret
106 + xor si,si
107 + mov ds,si
108 +notdos:
109 +loadsp19:
110 + mov sp,0
111 + pop [dword si+4]
112 + ; move zImage system
113 + ; memcpy32(dstseg=0, dstofs=10000h, srcseg=0, srcofs=100000h, size=80000h)
114 + push cs
115 + pop ds
116 + push 8
117 + push si ; size
118 + push 10h ; src
119 + push si ; ofs
120 + push si ; srcseg
121 + push 1 ; dst
122 + push si ; ofs
123 + push si ; dstseg
124 + extrn _memcpy32
125 + call near _memcpy32
126 + add sp,16
127 +nomove:
128 + push ss
129 + pop ds
130 + push ss
131 + pop es
132 + push ss
133 + pop fs
134 + push ss
135 + pop gs
136 assume nothing
137 assume cs:DGROUP
139 - ;;jmp [dword ofs2]
140 -
141 - push dx cx
142 +doretf:
143 retf
144 -; Data
145 -;;ofs2 dw ?
146 -;;seg2 dw ?
147 +
148 +movedend:
149 endp _set_sregs_jump_seg_ofs
151 ends _TEXT