wok view linld/stuff/src/JUMP.ASM @ rev 20528

linld: pascal convention calls
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Nov 09 16:37:55 2018 +0100 (2018-11-09)
parents 17c0ad41f5bf
children af959ebf1305
line source
1 ;***************************************************************
2 ;****** This file is distributed under GPL
3 ;***************************************************************
4 ideal
5 %crefref
6 %noincl
7 %nomacs
8 ifdef NO386
9 p8086
10 else
11 p386
12 endif
14 group DGROUP _TEXT,_DATA,_BSS
15 assume cs:DGROUP,ds:DGROUP
17 segment _DATA byte public use16 'DATA'
19 overflow db "Loaded too close to 9000:0",0
21 ends _DATA
23 segment _BSS byte public use16 'BSS'
25 global _imgs:dword
27 ends _BSS
30 segment _TEXT byte public use16 'CODE'
32 ;***************************************************************
33 ;void dos_shutdown()
34 ;***************************************************************
36 macro dos_shutdown
37 xor di,di
38 mov ds,di
39 ifndef NO386
40 push [dword di+4] ; save step
41 mov [word di+4],offset step19
42 else
43 mov ax,offset step19
44 xchg ax,[word di+4]
45 push [word di+6]
46 push ax ; save step
47 endif
48 mov [word cs:sssp],sp
49 ;cmp [byte di+7],0F0h
50 ;jnc notdos
51 mov [di+6],cs
52 pushf
53 pushf
54 pop ax
55 inc ah ; set TF
56 push ax
57 popf
58 call [dword di+4*19h]
59 notdos:
60 ifndef NO386
61 lss sp,[dword cs:sssp]
62 else
63 lds ax,[dword cs:sssp]
64 push ds
65 pop ss
66 xchg ax,sp
67 endif
68 xor di,di
69 mov ds,di
70 pop [dword di+4] ; restore step
71 endm
72 macro step19code
73 step19:
74 push di
75 push ds
76 mov di,sp
77 lds di,[dword ss:di+4] ; read cs:ip
78 cmp [word di],19CDh ; int 19h ?
79 pop ds
80 pop di
81 je notdos
82 iret
83 endm
86 ;***************************************************************
87 ;void boot_kernel();
88 ;****** Never returns
89 ;***************************************************************
90 global _boot_kernel:near
91 proc _boot_kernel near
93 p8086
94 extrn _heap_top:word
95 global sssp:dword
96 ifdef NO386
97 extrn _topseg:near
98 call near _topseg
99 mov cl,4
100 org $-4
101 sssp dd ?
102 mov [word sssp+2],ax
103 xchg ax,bx
104 mov ax,[_heap_top]
105 shr ax,cl
106 else
107 p386
108 mov ax,[_heap_top]
109 shr ax,4
110 mov bx,9000h
111 org $-4
112 sssp dd ?
113 endif
114 mov es,bx
115 mov dx,cs
116 add ax,dx
117 cmp ax,bx
118 jb @@nooverflow
119 ; Oops! We can stomp on our toes... better stop now
120 mov bx,offset overflow
121 extrn die:near
122 call near die
123 @@nooverflow:
124 ;cli ; we start doing destructive things to DOS
125 push es
126 pop ss
127 mov sp,0A000h
128 extrn _csip:dword
129 push [dword _csip]
130 extrn _rm_size:word
131 mov si,offset _rm_size ; _rm_size, _pm_high, _rm_buf
132 lodsw
133 xchg ax,cx ; _rm_size
134 lodsb ; _pm_high
135 mov si,[si] ; _rm_buf
136 xor di,di
137 ;cld
138 rep
139 movsb
140 extrn _cmdline:word
141 mov si,[_cmdline]
142 mov di,8000h
143 mov ch,10h ; 4k
144 rep
145 movsb
146 ifdef NO386
147 add bh,9
148 push bx ; topseg()+0x0900
149 else
150 push 9800h+(4096/16) ; 4096 bytes for cmdline
151 endif
152 cmp al,cl ; load high ?
153 pushf
154 ; finish loading
155 extrn @last_ditch$qv:near
156 call @last_ditch$qv
157 dos_shutdown ; clear di; ds=0
158 push cs
159 pop ds
160 popf
161 ; self move
162 ;cld
163 pop es ; min 2048 bytes for stack
164 jne @@isbzimage
165 mov cx,offset movedend
166 xor si,si ; A000 -9000 -0800(>movedend)
167 rep
168 movsb
169 mov ax,[word _imgs+2+2] ; get pm->fallback high word
170 push es
171 call near @@isbzimage ; pop cs ; ds=es=ss
173 ; prepare memcpy32 size & srcofs param to move zImage pm
174 mov dx,8
175 cmp ax,dx ; buf > 80000h ?
176 ja @@bufhigh
177 sub dx,ax
178 inc dx ; up to 90000h-1
179 @@bufhigh:
180 push dx ; size hi
181 push cx ; size lo=up to 512k
182 push ax ; src ofs ho = pm.fallback
184 ;in al,70h
185 ;or al,80h ; disable NMI
186 ;out 70h,al
188 xor di,di
189 push di ; src ofs lo
190 push di ; src seg=0
191 ifdef NO386
192 inc di
193 push di ; dst ofs hi
194 dec di
195 else
196 push 1 ; dst ofs hi
197 endif
198 push di ; dst ofs lo : 64k
199 extrn memcpy32:near
200 call memcpy32
202 ifndef noelks
203 ifndef NO386
204 cmp [dword 1E6h],'SKLE'
205 jne @@notelks
206 xor si,si
207 else
208 mov si,1E6h
209 lodsw
210 cmp ax,'LE'
211 jne @@notelks
212 lodsw
213 xor ax,'SK'
214 jne @@notelks
215 xchg ax,si
216 endif
217 push es
218 pop ss
219 mov cx,120h ; CS=0120
220 push cx
221 push si ; IP=0000
222 mov cl,0 ; DS=ES=SS=0100
223 mov es,cx
224 mov ch,05h ; 500h mini
225 rep
226 movsw
227 @@notelks:
228 endif
229 @@isbzimage:
230 push ss
231 pop ds
232 push ss
233 pop es
234 ifndef NO386
235 push ss
236 pop fs
237 push ss
238 pop gs
239 endif
240 assume nothing
241 assume cs:DGROUP
242 retf
244 step19code
246 endp _boot_kernel
248 movedend:
250 ends _TEXT
252 end
254 ;###### END OF FILE ############################################