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