8115fc301d104062a2605f65e4b080980823bcc8
[rrq/maintain_lilo.git] / src / dump.S
1 /* dump.S  -  LILO register dumper */
2
3  Copyright 1995-1997 Werner Almesberger.
4  All rights reserved.
5
6  Licensed under the terms contained in the file 'COPYING' in the 
7  source directory.
8
9 */
10
11
12 #define LILO_ASM
13 #include "lilo.h"
14
15
16         .text
17
18         .globl  _main
19         .org    0
20
21 _main:  push    sp      ! push all registers
22         push    ss
23         pushf
24         push    es
25         push    ds
26         push    cs
27         push    bp
28         push    di
29         push    si
30         push    dx
31         push    cx
32         push    bx
33         push    ax
34         mov     ax,#BOOTSEG     ! let DS point to where we really are
35         mov     ds,ax
36         mov     bx,#msgs        ! set up loop
37 l:      call    say             ! output message
38         cmp     byte ptr (bx),#0 ! at end ?
39         je      back            ! yes -> back to LILO
40         pop     ax              ! get next data word
41         push    bx
42         call    wout            ! output data word
43         pop     bx
44         jmp     l               ! next round
45
46 #if 0
47 back:   mov     ax,#FIRSTSEG
48         mov     ds,ax
49         mov     word ptr (CODE_START_1),#CODE_START_1+8
50         mov     word ptr (CODE_START_1+2),#FIRSTSEG
51         mov     word ptr (CODE_START_1+4),#CODE_START_1+12
52         mov     byte ptr (CODE_START_1+6),#0xfe
53         mov     es,ax           ! adjust segments
54         mov     ax,#BOOTSEG
55         mov     ds,ax
56         mov     word ptr (10),#0xffff ! no timeout
57         mov     si,#haltnow     ! copy string data
58         mov     di,#CODE_START_1+8
59         mov     cx,#6
60         rep
61         movsb
62         mov     ax,#FIRSTSEG    ! restart LILO
63         jmpi    #GO,FIRSTSEG
64 #else
65 back:   hlt                     ! stay here
66         jmp     back
67 #endif
68
69 ! Display a NUL-terminated string on the console
70
71 say:    mov     al,(bx)         ! get byte
72         inc     bx              ! move pointer
73         or      al,al           ! NUL ?
74         jz      aret            ! yes -> done
75         push    bx              ! save pointer
76         mov     ah,#14          ! display, tty-style
77         xor     bh,bh
78         int     0x10
79         pop     bx
80         jmp     say             ! next one
81
82 wout:   push    ax              ! display one word
83         mov     al,ah
84         call    bout
85         pop     ax
86 bout:   push    ax              ! display one byte
87         shr     al,#4
88         call    nout
89         pop     ax
90 nout:   and     al,#15          ! display one nibble
91         add     al,#48
92         cmp     al,#58
93         jb      nokay
94         add     al,#7
95 nokay:  xor     bh,bh           ! display on screen
96         mov     ah,#14
97         int     0x10
98 aret:   ret
99  
100 msgs:   .byte   13,10
101         .ascii  "Register dump:"
102         .byte   13,10,10
103         .ascii  "AX="
104         .byte   0
105         .ascii  " BX="
106         .byte   0
107         .ascii  " CX="
108         .byte   0
109         .ascii  " DX="
110         .byte   0,13,10
111         .ascii  "SI="
112         .byte   0
113         .ascii  " DI="
114         .byte   0
115         .ascii  " BP="
116         .byte   0,13,10
117         .ascii  "CS="
118         .byte   0
119         .ascii  " DS="
120         .byte   0
121         .ascii  " ES="
122         .byte   0,13,10
123         .ascii  "F="
124         .byte   0,13,10
125         .ascii  "SS:SP="
126         .byte   0
127         .ascii  ":"
128         .byte   0,13,10,10
129 #if 0
130         .ascii  "Restarting LILO ..."
131 #else
132         .ascii  "System halted."
133 #endif
134         .byte   13,10,10,0,0
135
136 haltnow:.ascii  "LILO"                  ! prevent automatic reboot
137         .byte   0