File: dump.S

package info (click to toggle)
lilo 21-4
  • links: PTS
  • area: main
  • in suites: slink
  • size: 812 kB
  • ctags: 895
  • sloc: ansic: 3,420; asm: 2,546; sh: 767; perl: 607; makefile: 193; cpp: 3
file content (131 lines) | stat: -rw-r--r-- 2,201 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/* dump.S  -  LILO register dumper */

/* Copyright 1995-1997 Werner Almesberger. See file COPYING for details. */


#define LILO_ASM
#include "lilo.h"


	.text

	.globl	_main
	.org	0

_main:	push	sp	! push all registers
	push	ss
	pushf
	push	es
	push	ds
	push	cs
	push	bp
	push	di
	push	si
	push	dx
	push	cx
	push	bx
	push	ax
	mov	ax,#BOOTSEG	! let DS point to where we really are
	mov	ds,ax
	mov	bx,#msgs	! set up loop
l:	call	say		! output message
	cmp	byte ptr (bx),#0 ! at end ?
	je	back		! yes -> back to LILO
	pop	ax		! get next data word
	push	bx
	call	wout		! output data word
	pop	bx
	jmp	l		! next round

#if 0
back:	mov	ax,#FIRSTSEG
	mov	ds,ax
	mov	word ptr (CODE_START_1),#CODE_START_1+8
	mov	word ptr (CODE_START_1+2),#FIRSTSEG
	mov	word ptr (CODE_START_1+4),#CODE_START_1+12
	mov	byte ptr (CODE_START_1+6),#0xfe
	mov	es,ax		! adjust segments
	mov	ax,#BOOTSEG
	mov	ds,ax
	mov	word ptr (10),#0xffff ! no timeout
	mov	si,#haltnow	! copy string data
	mov	di,#CODE_START_1+8
	mov	cx,#6
	rep
	movsb
	mov	ax,#FIRSTSEG	! restart LILO
	jmpi	#GO,FIRSTSEG
#else
back:	hlt			! stay here
	jmp	back
#endif

! Display a NUL-terminated string on the console

say:	mov	al,(bx)		! get byte
	inc	bx		! move pointer
	or	al,al		! NUL ?
	jz	aret		! yes -> done
	push	bx		! save pointer
	mov	ah,#14		! display, tty-style
	xor	bh,bh
	int	0x10
	pop	bx
	jmp	say		! next one

wout:	push	ax		! display one word
	mov	al,ah
	call	bout
	pop	ax
bout:	push	ax		! display one byte
	shr	al,#4
	call	nout
	pop	ax
nout:	and	al,#15		! display one nibble
	add	al,#48
	cmp	al,#58
	jb	nokay
	add	al,#7
nokay:	xor	bh,bh		! display on screen
	mov	ah,#14
	int	0x10
aret:	ret
 
msgs:	.byte	13,10
	.ascii	"Register dump:"
	.byte	13,10,10
	.ascii	"AX="
	.byte	0
	.ascii	" BX="
	.byte	0
	.ascii	" CX="
	.byte	0
	.ascii	" DX="
	.byte	0,13,10
	.ascii	"SI="
	.byte	0
	.ascii	" DI="
	.byte	0
	.ascii	" BP="
	.byte	0,13,10
	.ascii	"CS="
	.byte	0
	.ascii	" DS="
	.byte	0
	.ascii	" ES="
	.byte	0,13,10
	.ascii	"F="
	.byte	0,13,10
	.ascii	"SS:SP="
	.byte	0
	.ascii	":"
	.byte	0,13,10,10
#if 0
	.ascii	"Restarting LILO ..."
#else
	.ascii	"System halted."
#endif
	.byte	13,10,10,0,0

haltnow:.ascii	"LILO"			! prevent automatic reboot
	.byte	0