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