feat: ajout d'un menu permettant de lancer 2 applications: visualisateur de mémoire et visualisateur de mémoire de masse (disquette)

This commit is contained in:
Nicolas Hordé 2001-02-03 21:48:09 +01:00
parent f05d3d49af
commit 2a899f1618
8 changed files with 2113 additions and 321 deletions

View File

@ -1,6 +1,6 @@
@echo off
del system.bin
ren id.com system.bin
copy id.com system.bin
tasm boot.asm /t/x/m4
tlink boot.obj /x
del boot.obj

235
boot.asm
View File

@ -1,6 +1,7 @@
boots segment
.386
org 000h
org 7C00h
;org 100h
assume cs:boots,ds:boots
start:
@ -8,26 +9,33 @@ jmp boot
bootdb db 'COS2000A' ;ID Formatage
dw 512 ;octet/secteur
sizec dw 512 ;octet/secteur
db 1 ;secteur/cluster
dw 1 ;secteur reserv
db 2 ;nb de FAT
dw 224 ;nb secteur rep racine
dw 2880 ;nb secteur du volume
reserv dw 1 ;secteur reserv
nbfat db 1 ;nb de FAT
nbfit dw 25 ;nb secteur rep racine
allclu dw 2880 ;nb secteur du volume
db 0F0h ;ID support
dw 9 ;secteur/FAT
dw 18 ;secteur/piste
dw 2 ;nb de tˆte
dw 0 ;distance 1er sect et sect masse
db 0,0,0,0,0,0,0,0,29h ;?
db 01,02,03,04 ;no de serie
db 'COS2000 ' ;nom de volume
fatsize dw 12 ;secteur/FAT
nbtrack dw 18 ;secteur/piste
head dw 2 ;nb de tˆte
hidden dd 0 ;nombre de secteur cachs
dd 0 ;si nbsecteur = 0 nbsect ; the number of sectors
bootdrv db 0 ;Lecteur de dmarrage
db 0 ;NA
bootsig db 29h ;boot signature 29h
dd 01020304h ;no de serie
pope db 'COS2000 ' ;nom de volume
db 'FAT16 ' ;FAT
specialboot:
db 0 ;Secteur Systeme
errorloading db 'The disk inserted in the floppy drive is not a system disk !!',0dh,0
okloading db 'COS is loading',0dh,0
errorloading db 'It''s not a COS disk!',0dh,0ah,0
okloading db 'COS search system',0Dh,0ah,0
syst db 'Ok',0dh,0ah,0
dot db '.',0
carry db 0dh,0ah,0
Sys db 'System file',0
sys2 db 'sys',0
errorboot:
mov si,offset errorloading
@ -36,77 +44,138 @@ errorboot:
int 16h
int 19h
boot:
cli
mov ax,07C0h
mov ds,ax
mov Bootdrv,dl
cli
mov ax,09000h
mov ss,ax
mov sp,0FFFFh
mov ax,1000h
mov es,ax
sti
sti
p:
push cs
pop ds
xor ax,ax
xor dx,dx
int 13h
jc errorboot
mov si,offset okloading
call showstr
mov cx,13
mov bx,100h
call readsector
jc errorboot
mov cx,es:[bx+26]
call readsector
jc errorboot
add bx,512
inc cx
call readsector
jc errorboot
db 2eh,0ffh,1eh
dw offsets
Offsets dw 100h
dw 1000h
ret
mov cx,nbtrack
les si,ds:[1Eh*4]
mov byte ptr es:[si+4], cl
mov byte ptr es:[si+9], 0Fh
xor ax,ax
mov al,NbFat
mov bx,FatSize
mul bx
mov cx,ax
add cx,word ptr [offset Hidden]
adc cx,word ptr [offset Hidden+2]
add cx,Reserv
mov word ptr [offset BootSig],cx
xor dx,dx
mov ax,allclu
div nbtrack
xor dx,dx
div head
mov word ptr [offset pope],ax
push cs
pop es
mov bx,offset buffer
mov si,bx
xor dx,dx
CheckRoot:
call readsector
jc errorboot
xor di,di
findnext:
cmp byte ptr [bx+di],0
je errorboot
push si di cx
mov si,di
add si,bx
call showstr
mov ax,si
mov si,offset dot
call showstr
mov si,ax
add si,12
call showstr
mov si,offset carry
call showstr
mov si,ax
mov di,offset sys
mov cx,12+4
rep cmpsb
pop cx di si
je oksystem
add di,32
inc dx
cmp dx,nbfit
ja errorboot
cmp di,sizec
jb findnext
inc cx
jmp Checkroot
oksystem:
mov si,offset syst
call showstr
mov cx,[di+BX+26]
mov bx,1000h
mov es,bx
push bx
mov bx,0100h
push bx
mov si,offset dot
fatagain:
cmp cx,0FFF0h
jae finishload
call readsector
jc errorboot
call showstr
add bx,sizec
call getfat
jnc fatagain
finishload:
push es
push es
push es
pop ds
pop fs
pop gs
push 7202h
popf
db 0CBh
DiskSectorsPerTrack dw 18
DiskTracksPerHead dw 80
DiskHeads dw 2
;===================================Afficher un int EDX a l'cran================
ShowInt:
push eax edx esi di es
mov di,xy
mov ax,0B800h
mov es,ax
mov eax,edx
mov esi,10
decint2:
xor edx,edx
div esi
add dl,'0'
mov dh,colors
mov es:[di],dx
sub di,2
cmp ax,0
jne decint2
sub di,2
mov xy,di
pop es di esi edx eax
;<-cx nøsecteur ->cx code FAT
getfat:
push es bx
mov ax,cx
xor dx,dx
div sizec
mov cx,ax
add cx,reserv
mov bx,offset buffer
push cs
pop es
call readsector
jc errorgetfat
shl dx,1
add bx,dx
mov cx,[bx]
errorgetfat:
pop bx es
ret
xy dw 20
colors db 4
ReadSector:
push cx dx si
push ax cx dx si
mov AX, CX
xor DX, DX
div DiskSectorsPerTrack
div nbtrack
mov CL, DL ;{ Set the sector }
and CL, 63 ;{ Top two bits are bits 8&9 of the cylinder }
xor DX, DX
div DiskTracksPerHead
div head
mov CH, DL ;{ Set the track bits 0-7 }
mov AL, DH
ror AL, 1
@ -114,51 +183,37 @@ push cx dx si
and AL, 11000000b
or CL, AL ;{ Set bits 8&9 of track }
xor dX, DX
div DiskHeads
div pope
mov DH, DL ;{ Set the head }
inc CL
mov SI, 4
TryAgain:
mov AL, 1
mov DL, 0
mov AH, 2
mov AX,0201h
mov DL, bootdrv
int 13h
jnc Done
dec SI
jnz TryAgain
Done:
pop si dx cx
pop si dx cx ax
ret
showcrlf:
push ax bx
mov ax, 0E0Dh
xor bx, bx
int 10h
mov al, 0Ah
int 10h
pop bx ax
ret
showstr:
push ax bx si
again:
lodsb
or al,al
jz fin
cmp al,0Dh
jne noret
call showcrlf
jmp again
noret:
mov ah,0Eh
mov bx,07h
int 10h
jmp again
fin:
pop si bx ax
ret
ret
Buffer equ $
end start

600
choice.asm Executable file
View File

@ -0,0 +1,600 @@
.model tiny
.486
smart
.code
org 0100h
start:
push cs
push cs
pop ds
pop es
call clear
mov ax,0
call setxy
mov si,offset msg
call showstring0
mov di,0
mov al,112
call changeattrib
call line
call line
mov si,offset mssg
call showstring0
call line
mov si,offset msg2
call showstring0
call line
xor di,di
mov bx,offset buffer
mov cx,13
call readsector
jc fin2
xor bp,bp
showall:
cmp byte ptr [bx+di],0
je endof2
mov al,[bx+di+12]
mov byte ptr [bx+di+12],0
mov si,bx
add si,di
call showstring0
mov si,offset spaces
call showstring0
mov [bx+di+12],al
mov byte ptr [bx+di+12+5],0
mov si,bx
add si,di
add si,12
call showstring0
call line
add di,32
inc bp
jmp showall
endof2:
call Select
endof:
mov ax,0
int 16h
cmp ah,50h
jne tre1
cmp xxx,bp
je endof
inc xxx
call select
jmp endof
tre1:
cmp ah,48h
jne tre2
cmp xxx,1
je endof
dec xxx
call select
jmp endof
tre2:
cmp al,0Dh
je fin2
jne tre3
mov di,xxx
dec di
shl di,5
mov cx,[di+bx+26]
call line
call line
mov si,offset msgg
call showstring0
call executefat
tre3:
cmp ah,3bh
jne endof
mov di,0
mov cx,1
mov al,7
call changeattribword
mov si,offset popup
mov ax,0200h
call popupmenu
mov di,0
mov cx,1
mov al,112
call changeattribword
jmp endof
fin2:
ret
popup db 4,'&New'
db 5,'&Open'
db 1,'-'
db 7,'&Delete'
db 7,'R&ename'
db 5,'&Copy'
db 5,'&Link'
db 1,'-'
db 8,'&Restart'
db 10,'&Shut down'
db 1,'-'
db 12,'&About me...'
db 0
db 070h ;couleur normale
db 07Fh ;couleur speciale
db 07h ;couleur select
executefat:
push cs
mov bx,offset start
push bx
mov bx,6000h
mov es,bx
push bx
mov bx,0100h
push bx
mov si,offset dot
fatagain:
cmp cx,0FFF0h
jae finishload
call readsector
jc fin2
call showstring0
add bx,sizec
call getfat
jnc fatagain
finishload:
push es
push es
push es
pop ds
pop fs
pop gs
push 7202h
popf
db 0CBh
sizec dw 512
reserv dw 1
;<-cx nøsecteur ->cx code FAT
getfat:
push es ax bx dx
mov ax,cx
xor dx,dx
div sizec
mov cx,ax
add cx,reserv
mov bx,offset buffer
push cs
pop es
call readsector
jc errorgetfat
shl dx,1
add bx,dx
mov cx,[bx]
errorgetfat:
pop dx bx ax es
ret
;selectionne la ligne xx
Select:
push ax di
mov di,xxold
mov al,7
add di,3
call changeattrib
mov ax,xxx
mov xxold,ax
mov di,xxx
mov al,112
add di,3
call changeattrib
pop di ax
ret
;couleur al pour ligne di mot cx
Changeattribword:
push bp bx dx di es
mov dx,0B800h
mov es,dx
mov dx,di
shl dx,5
shl di,7
add di,dx
mov dx,80
xor bp,bp
xor bx,bx
popp:
cmp byte ptr es:[di],' '
je noway
cmp bx,1
je noway2
mov bx,1
inc bp
cmp cx,bp
ja fint
jmp noway2
noway:
xor bx,bx
noway2:
cmp bp,cx
jne noway3
mov es:[di-1],al
noway3:
add di,2
dec dx
jnz popp
fint:
pop es di dx bx bp
ret
;couleur al pour ligne di
changeattrib:
push dx di es
mov dx,0B800h
mov es,dx
mov dx,di
shl dx,5
shl di,7
add di,dx
mov cx,80
inc di
popep:
mov es:[di],al
add di,2
dec cx
jnz popep
pop es di dx
ret
colors db 7
xy dw 0
x db 0
y db 0
xxx dw 1
xxold dw 0
msg db ' File Edition',0
mssg db 'Cos 2000 menu loader release 1.0',0
msg2 db '>',0
spaces db ' ',0
dot db '.',0
msgg db 'Chargement du programme',0
;==========SHOWCHAR===========
;met un caractŠre aprs le curseur
;-> dl
;<-
;=============================
showchar:
push dx bx es
mov bx,0B800h
mov es,bx
mov bx,cs:xy
mov dh,cs:colors
mov es:[bx],dx
add cs:xy,2
pop es bx dx
ret
;==========SPACE===========
;met un espace aprs le curseur
;->
;<-
;=============================
space:
push bx es
add cs:xy,2
mov bx,0B800h
mov es,bx
mov bx,cs:xy
mov byte ptr es:[bx],' '
pop es bx
ret
;==============================Affiche le nombre nb binaire en EDX==============
ShowbinRow:
push es ax bx cx di
mov di,cs:xy
mov bx,0B800h
mov es,bx
mov ax,cx
sub cx,32
neg cx
shl edx,cl
mov ch,cs:colors
binaize:
rol edx,1
mov cl,'0'
adc cl,0
mov es:[di],cx
add di,2
dec al
jnz binaize
mov cs:xy,di
pop di cx bx ax es
ret
;==========SETCOLOR=========
;Change les attributs du texte a CL
;-> CL
;<-
;=============================
setcolor:
mov cs:colors,CL
ret
;=============CLEAR=========
;Efface l'ecran texte
;->
;<-
;=============================
clear:
push es eax cx di
xor di,di
mov ax,0b800h
mov es,ax
mov eax,07200720h
mov cx,1000
cld
rep stosd
pop di cx eax es
ret
;==========SCROLLDOWN=========
;defile de cx lines vers le bas
;-> CX
;<-
;=============================
scrolldown:
push cx si di ds es
mov si,0B800h
mov es,si
mov ds,si
mov si,cx
shl si,5
shl cx,7
add si,cx
mov cx,4000
sub cx,si
xor di,di
cld
rep movsb
pop es ds di si cx
ret
;==========LINE=========
;remet le curseur a la ligne
;->
;<-
;=============================
line:
push ax cx di es
mov ah,cs:x
mov al,cs:y
xor ah,ah
cmp al,24
jne scro
dec al
mov cl,1
call scrolldown
scro:
inc al
call setxy
pop es di cx ax
ret
;==========SETXY=========
;Change les coordonnées du curseur a X:AL,Y:AH
;-> AX
;<- es di
;=============================
setxy:
push ax bx di
mov cs:x,ah
mov cs:y,al
mov bl,ah
xor bh,bh
xor ah,ah
mov di,ax
shl di,5
shl ax,7
shl bx,1
add di,ax
add di,bx
mov cs:xy,di
pop di bx ax
ret
;================Affiche la chaine 0 de caractŠre contenue dans ds:si
showstring0:
push es cx si di
mov di,cs:xy
mov cx,0B800h
mov es,cx
mov ch,cs:colors
strinaize0:
mov cl,[si]
cmp cl,0
je no0
mov es:[di],cx
add di,2
inc si
jmp strinaize0
no0:
mov cs:xy,di
pop di si cx es
ret
;==============================Affiche le nombre nb hexa en EDX==============
ShowHexRow:
push es ax bx cx di
mov di,cs:xy
mov bx,0B800h
mov es,bx
mov ax,cx
sub cx,32
neg cx
shl edx,cl
mov ch,cs:colors
shr ax,2
Hexaize:
rol edx,4
mov bx,dx
and bx,0fh
mov cl,cs:[bx+offset Tab]
mov es:[di],cx
add di,2
dec al
jnz Hexaize
mov cs:xy,di
pop di cx bx ax es
ret
Tab db '0123456789ABCDEF'
ret
;===================================sauve l'ecran rapidement================
SaveScreen:
push cx si di ds es
mov cx,0B800H
mov ds,cx
push cs
pop es
mov cx,(80*25*2)/4
xor si,si
mov di,offset Copy2
cld
rep movsd
pop es ds di si cx
ret
;===================================sauve l'ecran rapidement================
RestoreScreen:
push cx si di ds es
mov cx,0B800H
mov es,cx
push cs
pop ds
mov cx,(80*25*2)/4
mov si,offset Copy2
xor di,di
cld
rep movsd
pop es ds di si cx
ret
;===================================Afficher un int EDX a l'cran en ah,al================
ShowInt:
push eax bx cx edx esi di es ds
mov di,cs:xy
mov cx,0B800h
mov es,cx
xor cx,cx
mov eax,edx
mov esi,10
mov bx,offset showbuffer+27
decint3:
xor edx,edx
div esi
add dl,'0'
mov dh,cs:colors
sub bx,2
add cx,2
mov cs:[bx],dx
cmp ax,0
jne decint3
mov si,bx
push cs
pop ds
cld
rep movsb
mov cs:xy,di
pop ds es di esi edx cx bx eax
ret
showbuffer db 35 dup (0FFh)
Lastread dw 0FFFFh
ReadSector:
push ax cx dx si
cmp cx,cs:lastread
je done
mov cs:LastRead,cx
mov AX, CX
xor DX, DX
div cs:DiskSectorsPerTrack
mov CL, DL ;{ Set the sector }
and CL, 63 ;{ Top two bits are bits 8&9 of the cylinder }
xor DX, DX
div cs:DiskTracksPerHead
mov CH, DL ;{ Set the track bits 0-7 }
mov AL, DH
ror AL, 1
ror AL, 1
and AL, 11000000b
or CL, AL ;{ Set bits 8&9 of track }
xor dX, DX
div cs:DiskHeads
mov DH, DL ;{ Set the head }
inc CL
mov SI, 4
TryAgain:
mov AL, 1
mov DL, 0
mov AH, 2
int 13h
jnc Done
dec SI
jnz TryAgain
mov word ptr cs:lastread,0ffffh
Done:
pop si dx cx ax
ret
WriteSector:
push ax cx dx si
cmp cs:Lastread,cx
jne nodestruct
mov cs:Lastread,0ffffh
nodestruct:
mov AX, CX
xor DX, DX
div cs:DiskSectorsPerTrack
mov CL, DL ;{ Set the sector }
and CL, 63 ;{ Top two bits are bits 8&9 of the cylinder }
xor DX, DX
div cs:DiskTracksPerHead
mov CH, DL ;{ Set the track bits 0-7 }
mov AL, DH
ror AL, 1
ror AL, 1
and AL, 11000000b
or CL, AL ;{ Set bits 8&9 of track }
xor DX, DX
div cs:DiskHeads
mov DH, DL ;{ Set the head }
inc CL
mov SI, 4
TryAgain2:
mov AL, 1
mov DL, 0
mov AH, 3
int 13h
jnc Done2
dec SI
jnz TryAgain2
Done2:
pop si dx cx ax
ret
include menu.Asm
DiskSectorsPerTrack dw 18
DiskTracksPerHead dw 80
DiskHeads dw 2
copy2 equ $
buffer equ $
end start

View File

@ -1,217 +0,0 @@
.model tiny
.486
smart
.code
org 0100h
start:
jmp CopyCOS
DiskSectorsPerTrack dw 18
DiskTracksPerHead dw 80
DiskHeads dw 2
NameBoot db 'Boot.bin',0
Namesystem db 'System.bin',0
Message db 0Ah,0Dh,'Installation of the COS (Celyn Operating System) !!',0Ah,0Dh,'Written By Horde Nicolas',0Ah,0Dh,'Copyright 2000',0Ah,0Dh
db 0Ah,0Dh,'Create boot sector$'
systfile db 0Ah,0Dh,'Creating file allocation table 16 bits$'
systfile2 db 0Ah,0Dh,'Creating file information table 32 bytes$'
systfile3 db 0Ah,0Dh,'Creating operating system files$'
Errormsg db 0Ah,0Dh,0Ah,0Dh,'An error has stopped the copying process !',0Ah,0Dh,'$'
Ok db 0Ah,0Dh,0Ah,0Dh,'The boot sector and the system files had been succefully copied.',0Ah,0Dh, 'To try COS reboot with this system disk',0Ah,0Dh,0Ah,0Dh,'$'
entrie db 'System file',0
db 'sys',0,0
dw 1234h
dw 1234h
dw 1234h
dw 1234h
db 0h
dw 32
dw 512
dw 0h
dw 0
CopyCOS:
mov ah,09
mov dx,offset message
int 21h
jc error
mov ax,3D00h
mov dx,offset nameboot
int 21h
jc error
mov bx,ax
mov ax,4202h
xor cx,cx
xor dx,dx
int 21h
jc error
cmp dx,0
jne error
cmp ax,512
jne error
mov ax,4200h
xor cx,cx
xor dx,dx
int 21h
jc error
mov ah,3fh
mov cx,512
mov dx,offset buffer
int 21h
jc error
mov ah,3eh
int 21h
jc error
mov cx,0
mov bx,dx
call writesector
jne error
mov ah,09
mov dx,offset systfile
int 21h
jc error
mov cx,512/4
mov di,bx
mov eax,0
rep stosd
mov cx,13
fatanymore:
call writesector
jne error
dec cx
cmp cx,1
ja fatanymore
mov di,bx
mov ax,0FFF0h
mov cx,13
rep stosw
mov ax,0FFFFh
stosw
mov word ptr [bx+32*2],33
mov word ptr [bx+33*2],0FFFFh
mov cx,1
call writesector
jne error
mov ah,09
mov dx,offset systfile2
int 21h
jc error
mov cx,13
mov bx,offset entrie
call writesector
jne error
mov ah,09
mov dx,offset systfile3
int 21h
jc error
mov ax,3D00h
mov dx,offset namesystem
int 21h
jc error
mov bx,ax
mov ax,4202h
xor cx,cx
xor dx,dx
int 21h
jc error
cmp dx,0
jne error
sub ax,1 ;+512
cmp ax,0
jl error
shr ax,9
inc ax
mov bp,ax
mov ax,4200h
xor cx,cx
xor dx,dx
int 21h
jc error
mov ah,3fh
mov cx,0FFFFh
mov dx,offset buffer
int 21h
jc error
mov bx,dx
mov cx,32
syst:
call writesector
jne error
add bx,512
inc cx
dec bp
jnz syst
mov ah,09
mov dx,offset ok
int 21h
jc error
ret
error:
mov ah,09
mov dx,offset errormsg
int 21h
ret
WriteSector:
push cx dx si
mov AX, CX
xor DX, DX
div DiskSectorsPerTrack
mov CL, DL ;{ Set the sector }
and CL, 63 ;{ Top two bits are bits 8&9 of the cylinder }
xor DX, DX
div DiskTracksPerHead
mov CH, DL ;{ Set the track bits 0-7 }
mov AL, DH
ror AL, 1
ror AL, 1
and AL, 11000000b
or CL, AL ;{ Set bits 8&9 of track }
xor DX, DX
div DiskHeads
mov DH, DL ;{ Set the head }
inc CL
mov SI, 4
TryAgain:
mov AL, 1
mov DL, 0
mov AH, 3
int 13h
jnc Done
dec SI
jnz TryAgain
Done:
mov cl, AH
mov ah,9
mov dx,offset sign
int 21h
cmp cl,0
pop si dx cx
ret
sign db '.$'
buffer db 512 dup (0)
end start

View File

@ -33,7 +33,7 @@ cmp dx,0
jne error
mov ax,4200h
xor cx,cx
mov dx,512
mov dx,7E00h
int 21h
jc error
mov ah,3fh

24
id.asm
View File

@ -17,15 +17,15 @@ zoomout equ 43h
start:
;mov ax,cs
mov ax,01000h
mov ds,ax
mov es,ax
mov gs,ax
xor eax,eax
xor ebx,ebx
xor ecx,ecx
xor edx,edx
xor esi,esi
xor edi,edi
mov ax,13h
int 10h
int 10h
mov dx,3C8h
mov al,7
out dx,al
@ -40,7 +40,7 @@ start:
mov ds,ax
push ds
push es
push gs
push cs
mov di,logo2coord
mov cx,logo2coordsize
xor si,si
@ -57,7 +57,7 @@ loopcoord2:
mov ax,bx
sub ax,14h
stosw
inc gs:nblogo2
inc cs:nblogo2
nothingcoord2:
add dx,3
cmp dx,0BAh
@ -91,7 +91,7 @@ loopcoord:
shl ax,1
sub ax,1Eh
stosw
inc gs:nblogo
inc cs:nblogo
nothingcoord:
inc dx
inc dx
@ -105,7 +105,7 @@ loc_6:
push ds
pop es
push gs
push cs
pop ds
masterloop:
inc logox ;++++

694
mem.asm Executable file
View File

@ -0,0 +1,694 @@
.model tiny
.386c
.code
org 0100h
start:
push ss
push gs
push fs
push es
push ds
push cs
pushad
pushfd
;cli
;mov dx,21h
;mov al,0FFh
;out dx,al
;mov dx,0A1h
;mov al,0FFh
;out dx,al
push cs
pop es
mov ax,3
int 10h
;mov ax,1100h
;mov bx,2000h ;1000H
;mov cx,0080h ;100h
;xor dx,dx
;mov bp,offset buffer
;int 10h
call savescreen
call clear
mov colors,4
mov si,offset reg
call showstring0
call line
mov colors,7
mov si,offset fla
call showstring0
pop edx
mov cx,32
call showbinrow
call space
call showhexrow
mov si,offset regs
mov ax,8+6
mov colors,6
showall:
call line
cmp ax,7
jb nodr
pop edx
jmp popo
nodr:
mov colors,8
xor edx,edx
pop dx
popo:
call showstring0
call showhexrow
call space
push si
mov si,offset gr
call showstring0
call showint
mov si,offset dr
call showstring0
pop si
add si,5
dec ax
jnz showall
;mov dx,21h
;mov al,0
;out dx,al
;mov dx,0A1h
;mov al,0
;out dx,al
;sti
mov ax,0
int 16h
mov ax,0305h
mov bx,0008h
int 16h
xor ax,ax
mov fs,ax
xor edx,edx
mov ax,0B800h
mov es,ax
xor ebp,ebp
Adres:
call clear
mov xy,0
mov x,0
mov y,0
mov ah,24
mov ebx,ebp
lines:
mov colors,7
mov edx,ebx
shr edx,4*4
shl edx,4*3
mov cx,16
call showhexrow
mov si,offset dep
call showstring0
mov dx,bx
mov cx,16
call showhexrow
mov si,offset spaces
call showstring0
mov al,16
mov edi,ebx
mov cx,8
mov colors,7
doaline:
mov edx,ebx
shr edx,4*4
shl edx,4*3
mov fs,dx
mov dl,fs:[bx]
call showhexrow
call space
inc ebx
dec al
jnz doaline
mov si,offset spaces
call showstring0
mov al,16
mov colors,7
doaline2:
mov edx,edi
shr edx,4*4
shl edx,4*3
mov fs,dx
mov dl,fs:[di]
call showchar
inc edi
dec al
jnz doaline2
call line
dec ah
jnz lines
mov colors,112
mov si,offset menu
call showstring0
mov bx,bp
waitkey:
mov ax,0
int 16h
cmp ax,3B00h
jne suit
inc ebp
jmp adres
suit:
cmp ax,3C00h
jne suit2
dec ebp
jmp adres
suit2:
cmp ax,3D00h
jne suit3
add ebp,24*16
jmp adres
suit3:
cmp ax,3E00h
jne suit4
sub ebp,24*16
jmp adres
suit4:
cmp ax,3F00h
jne suit5
add ebp,010000h
jmp adres
suit5:
cmp ax,4000h
jne suit6
sub ebp,010000h
jmp adres
suit6:
cmp ax,4100h
jne suit7
mov dword ptr [pope],'TIDE'
mov ax,24
call setxy
mov colors,116
mov si,offset menu
call showstring0
mov colors,7
mov xxyy2,1
mov xxyy,1
call calc1
call calc2
waitst:
mov ax,0
int 16h
cmp ah,41h
jne tre
mov dword ptr [pope],' EUV'
jmp adres
tre:
cmp al,0
jne write
cmp ah,48h
jne tre1
cmp yy,0
je waitst
dec yy
jmp cursor
tre1:
cmp ah,50h
jne tre2
cmp yy,23
je waitst
inc yy
jmp cursor
tre2:
cmp ah,4Dh
jne tre4
cmp xx,15
je waitst
inc xx
jmp cursor
tre4:
cmp ah,4Bh
jne waitst
cmp xx,0
je waitst
dec xx
jmp cursor
write:
call AsciiHex2dec
cmp cl,15
ja waitst
call calc1
call calc2
mov edi,es:[bx-1]
mov dx,es:[si-1]
mov byte ptr es:[bx],0112
mov es:[bx-1],al
writs:
mov ax,0
int 16H
mov ch,cl
call AsciiHex2dec
cmp cl,15
ja writs
shl ch,4
add ch,cl
mov es:[bx+1],al
mov es:[si-1],ch
mov ax,bx
call calc3
mov gs:[bx],ch
pusha
popa
mov cl,gs:[bx]
cmp ch,cl
je no
push si ax
mov ax,24
call setxy
mov colors,117
mov si,offset msg
call showstring0
mov ax,0
int 16h
mov ax,24
call setxy
mov colors,116
mov si,offset menu
call showstring0
pop bx si
mov es:[bx-1],edi
mov es:[si-1],dx
no:
inc xx
cmp xx,16
jne pasde
inc yy
mov xx,0h
pasde:
call calc1
call calc2
jmp waitst
cursor:
call calc1
call calc2
jmp waitst
suit7:
cmp ax,4200h
jne waitkey
call restorescreen
db 0CBH
calc1:
push ax dx si
mov ax,xx
mov dx,xx
shl ax,2
shl dx,1
add ax,dx
add ax,25
mov bx,YY
mov dx,yy
shl bx,5
shl dx,7
add bx,dx
add bx,ax
mov byte ptr es:[bx],112
mov byte ptr es:[bx+2],112
mov si,xxyy
mov byte ptr es:[si],07
mov byte ptr es:[si+2],07
mov xxyy,bx
pop si dx ax
ret
calc2:
push ax bx dx
mov si,YY
mov dx,yy
shl si,5
shl dx,7
add si,dx
mov dx,xx
shl dx,1
add si,dx
add si,127
mov byte ptr es:[si],112
mov bx,xxyy2
mov byte ptr es:[bx],07
mov xxyy2,si
pop dx bx ax
ret
calc3:
push dx
xor ebx,ebx
mov bx,xx
mov dx,yy
shl dx,4
add bx,dx
add ebx,ebp
mov edx,ebx
shr edx,4*4
shl edx,4*3
mov gs,dx
pop dx
ret
asciihex2dec:
cmp al,'a'
jb nomin
cmp al,'f'
ja nomin
sub al,'a'-'A'
jmp ismaj
nomin:
cmp al,'A'
jb nomaj
cmp al,'F'
ja nomaj
ismaj:
mov cl,al
sub cl,'A'-10
jmp endt
nomaj:
mov cl,al
sub cl,'0'
endt:
ret
xx dw 0
yy dw 0
xxyy dw 0
xxyy2 dw 0
msg db 'Erreur : zone imodifiable (ROM) appuyer sur une touche ',0
menu db 'Haut F1, Bas F2, Pages F3&F4, Segment F5&F6, Edit F7, Quitter F8 MODE '
pope db 'VUE ',0
spaces db ' ³ ',0
dep db ':',0
reg db 'Etats des registre aprs boot',0
fla db 'Flags:',0
regs db 'EDI:',0
db 'ESI:',0
db 'EBP:',0
db 'ESP:',0
db 'EBX:',0
db 'EDX:',0
db 'ECX:',0
db 'EAX:',0
db ' CS:',0
db ' DS:',0
db ' ES:',0
db ' FS:',0
db ' GS:',0
db ' SS:',0
cxk dw 0
edxk dd 0
dsk dw 0
sik dw 0
gr db '(',0
dr db ')',0
xy dw 0
colors db 7
x db 1
y Db 1
;==========SHOWCHAR===========
;met un caractŠre aprs le curseur
;-> dl
;<-
;=============================
showchar:
push dx bx es
mov bx,0B800h
mov es,bx
mov bx,cs:xy
mov dh,cs:colors
mov es:[bx],dx
add cs:xy,2
pop es bx dx
ret
;==========SPACE===========
;met un espace aprs le curseur
;->
;<-
;=============================
space:
push bx es
add cs:xy,2
mov bx,0B800h
mov es,bx
mov bx,cs:xy
mov byte ptr es:[bx],' '
pop es bx
ret
;==============================Affiche le nombre nb binaire en EDX==============
ShowbinRow:
push es ax bx cx di
mov di,cs:xy
mov bx,0B800h
mov es,bx
mov ax,cx
sub cx,32
neg cx
shl edx,cl
mov ch,cs:colors
binaize:
rol edx,1
mov cl,'0'
adc cl,0
mov es:[di],cx
add di,2
dec al
jnz binaize
mov cs:xy,di
pop di cx bx ax es
ret
;==========SETCOLOR=========
;Change les attributs du texte a CL
;-> CL
;<-
;=============================
setcolor:
mov cs:colors,CL
ret
;=============CLEAR=========
;Efface l'ecran texte
;->
;<-
;=============================
clear:
push es eax cx di
xor di,di
mov ax,0b800h
mov es,ax
mov eax,07200720h
mov cx,1000
cld
rep stosd
pop di cx eax es
ret
;==========SCROLLDOWN=========
;defile de cx lines vers le bas
;-> CX
;<-
;=============================
scrolldown:
push cx si di ds es
mov si,0B800h
mov es,si
mov ds,si
mov si,cx
shl si,5
shl cx,7
add si,cx
mov cx,4000
sub cx,si
xor di,di
cld
rep movsb
pop es ds di si cx
ret
;==========LINE=========
;remet le curseur a la ligne
;->
;<-
;=============================
line:
push ax cx di es
mov ah,cs:x
mov al,cs:y
xor ah,ah
cmp al,24
jne scro
dec al
mov cl,1
call scrolldown
scro:
inc al
call setxy
pop es di cx ax
ret
;==========SETXY=========
;Change les coordonnées du curseur a X:AL,Y:AH
;-> AX
;<- es di
;=============================
setxy:
push ax bx di
mov cs:x,ah
mov cs:y,al
mov bl,ah
xor bh,bh
xor ah,ah
mov di,ax
shl di,5
shl ax,7
shl bx,1
add di,ax
add di,bx
mov cs:xy,di
mov ax,0B800h
mov es,ax
pop di bx ax
ret
;================Affiche la chaine 0 de caractŠre contenue dans ds:si
showstring0:
push es cx si di
mov di,cs:xy
mov cx,0B800h
mov es,cx
mov ch,cs:colors
strinaize0:
mov cl,[si]
cmp cl,0
je no0
mov es:[di],cx
add di,2
inc si
jmp strinaize0
no0:
mov cs:xy,di
pop di si cx es
ret
;==============================Affiche le nombre nb hexa en EDX==============
ShowHexRow:
push es ax bx cx di
mov di,cs:xy
mov bx,0B800h
mov es,bx
mov ax,cx
sub cx,32
neg cx
shl edx,cl
mov ch,cs:colors
shr ax,2
Hexaize:
rol edx,4
mov bx,dx
and bx,0fh
mov cl,cs:[bx+offset Tab]
mov es:[di],cx
add di,2
dec al
jnz Hexaize
mov cs:xy,di
pop di cx bx ax es
ret
Tab db '0123456789ABCDEF'
ret
;===================================sauve l'ecran rapidement================
SaveScreen:
push cx si di ds es
mov cx,0B800H
mov ds,cx
push cs
pop es
mov cx,(80*25*2)/4
xor si,si
mov di,offset Copy2
cld
rep movsd
pop es ds di si cx
ret
;===================================sauve l'ecran rapidement================
RestoreScreen:
push cx si di ds es
mov cx,0B800H
mov es,cx
push cs
pop ds
mov cx,(80*25*2)/4
mov si,offset Copy2
xor di,di
cld
rep movsd
pop es ds di si cx
ret
;===================================Afficher un int EDX a l'cran en ah,al================
ShowInt:
push eax bx cx edx esi di es ds
mov di,cs:xy
mov cx,0B800h
mov es,cx
xor cx,cx
mov eax,edx
mov esi,10
mov bx,offset showbuffer+27
decint3:
xor edx,edx
div esi
add dl,'0'
mov dh,cs:colors
sub bx,2
add cx,2
mov cs:[bx],dx
cmp ax,0
jne decint3
mov si,bx
push cs
pop ds
cld
rep movsb
mov cs:xy,di
pop ds es di esi edx cx bx eax
ret
showbuffer db 35 dup (0FFh)
copy2 db 4000 dup (0)
buffer db 0
end start

660
sect.asm Executable file
View File

@ -0,0 +1,660 @@
.model tiny
.386c
.code
org 0100h
start:
mov ax,0305h
mov bx,0008h
int 16h
;mov ax,1100h
;mov bx,1000h ;2000H
;mov cx,0100h ;80h
;xor dx,dx
;mov bp,offset copy2
;int 10h
call savescreen
xor bp,bp
Adres:
push cs
pop es
mov cx,sect
mov bx,offset buffer
call readsector
jnc noerror
errtr:
mov ax,24
call setxy
mov colors,116
mov si,offset errordisk
call showstring0
mov ax,0
int 16h
noerror:
adres2:
mov bx,offset buffer
call clear
mov ax,0
call setxy
mov ah,24
mov di,bp
mov colors,7
lines:
mov dx,sect
mov cx,16
call showhexrow
mov si,offset dep
call showstring0
mov dx,di
call showhexrow
mov si,offset spaces
call showstring0
mov al,16
mov cx,8
mov colors,7
mov si,di
doaline:
mov dl,[di+bx]
call showhexrow
call space
inc di
dec al
jnz doaline
mov di,si
mov si,offset spaces
call showstring0
mov al,16
mov colors,7
doaline2:
mov dl,[di+bx]
call showchar
inc di
dec al
jnz doaline2
call line
dec ah
jnz lines
mov colors,112
mov si,offset menu
call showstring0
mov bx,bp
waitkey:
mov ax,0
int 16h
cmp ax,3B00h
jne suit
cmp bx,8*16
jae waitkey
add bp,16
jmp adres2
suit:
cmp ax,3C00h
jne suit2
cmp bp,0
je waitkey
sub bp,16
jmp adres2
suit2:
cmp ax,3D00h
jne suit3
cmp sect,2880
ja waitkey
inc sect
jmp adres
suit3:
cmp ax,3E00h
jne suit4
cmp sect,0
je waitkey
dec sect
jmp adres
suit4:
cmp ax,3F00h
jne suit5
jmp adres2
suit5:
cmp ax,4000h
jne suit6
mov cx,sect
mov bx,offset buffer
call writesector
jnc waitkey
jmp errtr
suit6:
cmp ax,4100h
jne suit7
mov dword ptr [pope],'TIDE'
mov ax,24
call setxy
mov colors,116
mov si,offset menu
call showstring0
mov colors,7
mov ax,0B800h
mov es,ax
mov xxyy2,3
mov xxyy,3
call calc1
call calc2
waitst:
mov ax,0
int 16h
cmp ah,41h
jne tre
mov dword ptr [pope],' EUV'
push cs
pop es
mov cx,sect
mov bx,offset buffer
call writesector
jnc adres
jmp errtr
tre:
cmp al,0
jne write
cmp ah,48h
jne tre1
cmp yy,0
je waitst
dec yy
jmp cursor
tre1:
cmp ah,50h
jne tre2
cmp yy,23
je waitst
inc yy
jmp cursor
tre2:
cmp ah,4Dh
jne tre4
cmp xx,15
je waitst
inc xx
jmp cursor
tre4:
cmp ah,4Bh
jne waitst
cmp xx,0
je waitst
dec xx
jmp cursor
write:
call AsciiHex2dec
cmp cl,15
ja waitst
call calc1
call calc2
mov byte ptr es:[bx],0112
mov es:[bx-1],al
writs:
mov ax,0
int 16H
mov ch,cl
call AsciiHex2dec
cmp cl,15
ja writs
shl ch,4
add ch,cl
mov es:[bx+1],al
mov es:[si-1],ch
mov ax,bx
call calc3
mov [bx],ch
inc xx
cmp xx,16
jne pasde
inc yy
mov xx,0h
pasde:
call calc1
call calc2
jmp waitst
cursor:
call calc1
call calc2
jmp waitst
suit7:
cmp ax,4200h
jne waitkey
call restorescreen
ret
calc1:
push ax dx si
mov ax,xx
mov dx,xx
shl ax,2
shl dx,1
add ax,dx
add ax,25
mov bx,YY
mov dx,yy
shl bx,5
shl dx,7
add bx,dx
add bx,ax
mov byte ptr es:[bx],112
mov byte ptr es:[bx+2],112
mov si,xxyy
mov byte ptr es:[si],07
mov byte ptr es:[si+2],07
mov xxyy,bx
pop si dx ax
ret
calc2:
push ax bx dx
mov si,YY
mov dx,yy
shl si,5
shl dx,7
add si,dx
mov dx,xx
shl dx,1
add si,dx
add si,127
mov byte ptr es:[si],112
mov bx,xxyy2
mov byte ptr es:[bx],07
mov xxyy2,si
pop dx bx ax
ret
calc3:
push dx
xor bx,bx
mov bx,xx
mov dx,yy
shl dx,4
add bx,dx
add bx,bp
add bx,offset buffer
pop dx
ret
asciihex2dec:
cmp al,'a'
jb nomin
cmp al,'f'
ja nomin
sub al,'a'-'A'
jmp ismaj
nomin:
cmp al,'A'
jb nomaj
cmp al,'F'
ja nomaj
ismaj:
mov cl,al
sub cl,'A'-10
jmp endt
nomaj:
mov cl,al
sub cl,'0'
endt:
ret
dep db ':',0
sect dw 0
xx dw 0
yy dw 0
xxyy dw 3
xxyy2 dw 3
errordisk db 'Une erreur est survenu sur le lecteur A:, appuyer sur une touche ',0
menu db 'Haut F1, Bas F2, Secteurs F3&F4, Load/Save F4&F5, Edit F7, Quitter F8 MODE '
pope db 'VUE ',0
spaces db ' ³ ',0
xy dw 0
colors db 7
x db 1
y Db 1
;==========SHOWCHAR===========
;met un caractŠre aprs le curseur
;-> dl
;<-
;=============================
showchar:
push dx bx es
mov bx,0B800h
mov es,bx
mov bx,cs:xy
mov dh,cs:colors
mov es:[bx],dx
add cs:xy,2
pop es bx dx
ret
;==========SPACE===========
;met un espace aprs le curseur
;->
;<-
;=============================
space:
push bx es
add cs:xy,2
mov bx,0B800h
mov es,bx
mov bx,cs:xy
mov byte ptr es:[bx],' '
pop es bx
ret
;==============================Affiche le nombre nb binaire en EDX==============
ShowbinRow:
push es ax bx cx di
mov di,cs:xy
mov bx,0B800h
mov es,bx
mov ax,cx
sub cx,32
neg cx
shl edx,cl
mov ch,cs:colors
binaize:
rol edx,1
mov cl,'0'
adc cl,0
mov es:[di],cx
add di,2
dec al
jnz binaize
mov cs:xy,di
pop di cx bx ax es
ret
;==========SETCOLOR=========
;Change les attributs du texte a CL
;-> CL
;<-
;=============================
setcolor:
mov cs:colors,CL
ret
;=============CLEAR=========
;Efface l'ecran texte
;->
;<-
;=============================
clear:
push es eax cx di
xor di,di
mov ax,0b800h
mov es,ax
mov eax,07200720h
mov cx,1000
cld
rep stosd
pop di cx eax es
ret
;==========SCROLLDOWN=========
;defile de cx lines vers le bas
;-> CX
;<-
;=============================
scrolldown:
push cx si di ds es
mov si,0B800h
mov es,si
mov ds,si
mov si,cx
shl si,5
shl cx,7
add si,cx
mov cx,4000
sub cx,si
xor di,di
cld
rep movsb
pop es ds di si cx
ret
;==========LINE=========
;remet le curseur a la ligne
;->
;<-
;=============================
line:
push ax cx di es
mov ah,cs:x
mov al,cs:y
xor ah,ah
cmp al,24
jne scro
dec al
mov cl,1
call scrolldown
scro:
inc al
call setxy
pop es di cx ax
ret
;==========SETXY=========
;Change les coordonnées du curseur a X:AL,Y:AH
;-> AX
;<- es di
;=============================
setxy:
push ax bx di
mov cs:x,ah
mov cs:y,al
mov bl,ah
xor bh,bh
xor ah,ah
mov di,ax
shl di,5
shl ax,7
shl bx,1
add di,ax
add di,bx
mov cs:xy,di
pop di bx ax
ret
;================Affiche la chaine 0 de caractŠre contenue dans ds:si
showstring0:
push es cx si di
mov di,cs:xy
mov cx,0B800h
mov es,cx
mov ch,cs:colors
strinaize0:
mov cl,[si]
cmp cl,0
je no0
mov es:[di],cx
add di,2
inc si
jmp strinaize0
no0:
mov cs:xy,di
pop di si cx es
ret
;==============================Affiche le nombre nb hexa en EDX==============
ShowHexRow:
push es ax bx cx di
mov di,cs:xy
mov bx,0B800h
mov es,bx
mov ax,cx
sub cx,32
neg cx
shl edx,cl
mov ch,cs:colors
shr ax,2
Hexaize:
rol edx,4
mov bx,dx
and bx,0fh
mov cl,cs:[bx+offset Tab]
mov es:[di],cx
add di,2
dec al
jnz Hexaize
mov cs:xy,di
pop di cx bx ax es
ret
Tab db '0123456789ABCDEF'
ret
;===================================sauve l'ecran rapidement================
SaveScreen:
push cx si di ds es
mov cx,0B800H
mov ds,cx
push cs
pop es
mov cx,(80*25*2)/4
xor si,si
mov di,offset Copy2
cld
rep movsd
pop es ds di si cx
ret
;===================================sauve l'ecran rapidement================
RestoreScreen:
push cx si di ds es
mov cx,0B800H
mov es,cx
push cs
pop ds
mov cx,(80*25*2)/4
mov si,offset Copy2
xor di,di
cld
rep movsd
pop es ds di si cx
ret
;===================================Afficher un int EDX a l'cran en ah,al================
ShowInt:
push eax bx cx edx esi di es ds
mov di,cs:xy
mov cx,0B800h
mov es,cx
xor cx,cx
mov eax,edx
mov esi,10
mov bx,offset showbuffer+27
decint3:
xor edx,edx
div esi
add dl,'0'
mov dh,cs:colors
sub bx,2
add cx,2
mov cs:[bx],dx
cmp ax,0
jne decint3
mov si,bx
push cs
pop ds
cld
rep movsb
mov cs:xy,di
pop ds es di esi edx cx bx eax
ret
showbuffer db 35 dup (0FFh)
Lastread dw 0FFFFh
ReadSector:
push ax cx dx si
cmp cx,cs:lastread
je done
mov cs:LastRead,cx
mov AX, CX
xor DX, DX
div cs:DiskSectorsPerTrack
mov CL, DL ;{ Set the sector }
and CL, 63 ;{ Top two bits are bits 8&9 of the cylinder }
xor DX, DX
div cs:DiskTracksPerHead
mov CH, DL ;{ Set the track bits 0-7 }
mov AL, DH
ror AL, 1
ror AL, 1
and AL, 11000000b
or CL, AL ;{ Set bits 8&9 of track }
xor dX, DX
div cs:DiskHeads
mov DH, DL ;{ Set the head }
inc CL
mov SI, 4
TryAgain:
mov AL, 1
mov DL, 0
mov AH, 2
int 13h
jnc Done
dec SI
jnz TryAgain
mov word ptr cs:lastread,0ffffh
Done:
pop si dx cx ax
ret
WriteSector:
push ax cx dx si
cmp cs:Lastread,cx
jne nodestruct
mov cs:Lastread,0ffffh
nodestruct:
mov AX, CX
xor DX, DX
div cs:DiskSectorsPerTrack
mov CL, DL ;{ Set the sector }
and CL, 63 ;{ Top two bits are bits 8&9 of the cylinder }
xor DX, DX
div cs:DiskTracksPerHead
mov CH, DL ;{ Set the track bits 0-7 }
mov AL, DH
ror AL, 1
ror AL, 1
and AL, 11000000b
or CL, AL ;{ Set bits 8&9 of track }
xor DX, DX
div cs:DiskHeads
mov DH, DL ;{ Set the head }
inc CL
mov SI, 4
TryAgain2:
mov AL, 1
mov DL, 0
mov AH, 3
int 13h
jnc Done2
dec SI
jnz TryAgain2
Done2:
pop si dx cx ax
ret
DiskSectorsPerTrack dw 18
DiskTracksPerHead dw 80
DiskHeads dw 2
copy2 equ $
buffer equ $+4000
end start