Lowlevel
Lowlevel => Lowlevel-Coding => Thema gestartet von: chris12 am 30. August 2008, 23:32
-
ich hab vor längerer zeit die tuts aus der wiki mir durchgelesen und auch ein os, zumindest die anfänge, geschrieben.
einige funktionen hab ich auch übernommen wie z.b. die putstr funktion und da ist jetzt meine frage wie man diese funktion umschreiben müsste um jetzt die standard farbe 0x07 auf z.b. 0x14 zu ändern oder könnte man das auch z.b an den anfang der konsole schreiben das gleich die farbe geändert wird und man dann arbeiten kann? :? :? :?
ich hab mir Ralf Brown's Interrupt List angesehen und da stand bei INT 10/AH=0Eh
AH = 0Eh
AL = character to write
BH = page number
BL = foreground color (graphics modes only)
...
mit BL z.b= 14h oder 0x14 oder 0x1 oder anderem hat nicht gefunzt :-(
dann hab ich's mit BX z.b = 0x001 oder 0x13 oä alles hatte keine wirkung es blieb grauer text auf schwarzem grund :cry:
heir der code:
putstr:
lodsb
or al,al
jz short putstrd
mov ah,0Eh
mov bx, 0x0007 ;<---- hier dacht ich wär die farbe definiert
int 0x10
jmp putstr
putstrd:
retn
ich hoffe es hört sich nicht so an, als wenn ich nicht gesucht hätt aber alles was ich probiert hab funzte nicht bz nicht so wie ich es gern haben wollte :-(
ich hoffe ihr könnt mir helfen sonst muss es halt grau-schwarz bleiben
mfg bb
chris12
-
Ich verwende die Funktion 0x09 (http://www.ctyme.com/intr/rb-0099.htm)
Damit geht es auf jeden fall. 0x0E funktionierte bei mir damals auch nicht richtig.
mov cx, 1 ; Anzahl der ausgaben
xor bh, bh ; Codepage 0
mov bl, 0x14 ; Farbe laden
mov ah, 0x09 ; Int 10>09
int 0x10
-
danke für die schnelle antwort aber nun stimmt zwar die farbe aber es wird nichts mehr ausgegeben
sondern nur noch
(http://stargate-hilfe-forum.blogsite.org/bug.bmp)
anstat
(http://stargate-hilfe-forum.blogsite.org/Virtualbox1.bmp)
aber trotzdem danke :-D
mfg bb
chris12
-
BL = foreground color (graphics modes only)
80x25 oä sind keine Grafikmodi sondern Textmodi...
-
also nur damit ich es richtig verstehe :
80x25 is textmodus und bl funzt nur im grafikmodus
so richtig?
bb chris
-
Ja.
-
und auf diese weise kann ich die farben nicht ändern, oder? :-)
mfg bb
chris
-
offensichtlich.
-
danke :-D
jetzt weiss ich entlich, dass es so nicht geht :-D :-D :-D
mfg bb
chris12
-
mfg bb
chris12
Wie wäre es mit ein paar Leerzeilen weniger? Die stören beim Lesen. Davon abgesehen zeigt das Forum deinen Benutzernamen auch so an, es gibt also keinen Grund, ihn nochmal drunterzusetzen.
Ja, ich weiß, es ist doof, inhaltlich nichts beizutragen und nur über sowas zu meckern. Aber es erleichtert das Lesen wirklich, wenn sich alle dran halten.
-
ok ich werd mich versuchen dran zu halten
-
Also int 0x10, ah=0x09 läuft bei mir im 80x25 und 80x50 TEXTMODE
"Beweisfoto":
(http://reos.re.funpic.de/REOS/screens/000100/boot.png)
Bis Execute video16.bin ist es unverändert der 80x25 textmode. In video16.bin wechsel ich dann in den 80x50 textmode.
getestet unter bochs, qemu, und zwei echten PCs
evtl musst du per hand, die neue Position für das nächste zeichen eingeben...
So hab ich es gemacht - ist aber bestimmt nicht die besste Lösung... Ich hatte damals noch ne menge anderen Mist in dieser funktion stehen (\t \b und sonstiges zeug wurde mit berücksichtigt). Aber sie Tut ihren dienst :)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; putchar ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; al = Zeichen
;; ah = Farbe
putchar:
push ax
push bx
push cx
push dx
cmp al, 10 ; Newline
jz putchar.newline
mov cx, 1 ; Anzahl der ausgaben (f�r int)
xor bh, bh ; Codepage 0
mov bl, ah ; Farbe laden (f�r int)
mov ah, 0x09 ; Int 10>09
int 0x10
putchar.nextchar:
call getcursorpos
cmp dl, 79 ; ende der Zeile erreicht?
jz putchar.newline ; Dann die Zeile wechseln
inc dl ; Sonst die n�chste spalte
call setcursorpos
jmp putchar.ende
putchar.newline:
call getcursorpos
inc dh ; N�chste reihe
xor dl,dl ; Spalte 0
call setcursorpos
jmp putchar.ende
putchar.ende:
pop dx
pop cx
pop bx
pop ax
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; getcursorpos ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; dh = reihe
;; dl = Spalte
getcursorpos:
push ax
push bx
xor bh, bh ;
mov ah, 0x03 ; INT 10>03
int 0x10 ; getcursorposition ( dh <reihe ; dl <spalte )
pop bx
pop ax
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; setcursorpos ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; dh = reihe
;; dl = Spalte
setcursorpos:
push ax
push bx
xor bh, bh ; codepage
mov ah, 0x02 ; INT 10>02
int 0x10 ; Setcursorpos (dh <Reihe ; dl <Spalte)
pop bx
pop ax
ret
-
ok danke die farbe ist jetzt ne anderre aber wie defienierst du dann die strings die du ausgeben willst, ich hab sie immer mit
nachricht db "bla bla bla...",13,10,0
defieniert und das geht so bei mir nicht
-
Hi,
Sieht so aus als würdet ihr eure Strings mit BIOS-Interrupts auf den Bildschirm bringen. Das geht natürlich nur im Realmode und früher oder später müsst ihr in den Protected Mode, wenn ihr ein OS haben wollt. Mit ein wenig Suche hättet ihr auch sicher den Artikel "Textausgabe" in dem Wiki gefunden. Da steht dann erklärt, wie man im PMode Text ausgibt und auch mit Farbe ;)
-
Ich gehe davon aus, das chris12 im RM arbeitet...
Meinse writestring:
;;INPUT
;; si = Adresse der Zeichenkette (offset) 1. Zeichen == Farbe
writestring:
push ax
push bx
push cx
push dx
push si
;Daten vorher �ber die rs232 schicken
call rs232sendstring
mov ah, [si] ; Farbe in ch laden
inc si ; Zum 1. Zeichen gehen
writestring.next:
mov al, [si] ; N�chste zeichen laden
inc si
or al, al ; ISt das Byte 0??
jz writestring.end
; mov ah, ch ; Farbe laden
call putchar
jmp writestring.next
writestring.end:
pop si
pop dx
pop cx
pop bx
pop ax
ret
auch sehr umständlich, da ich stringfunktionen der CPU damals noch nicht kannte :-P
-
thx @ all jetzt funztz :-D
aber ich glaub ich bleib doch erstmal bei dem den ich schon hab und bei der farbe 0x07 :-)
und ja ich arbeite noch im RM
-
Hallo.
Ich hab ein aehnliches Problem
putstr:
lodsb
or al,al
jz short putstrd
mov cx, 1
xor bh, bh
mov ah,0x09
int 0x10
jmp putstr
putstrd:
retn
Jedoch wird bei einer Ausgabe nur ein Zeichen ausgegeben. (Aber ein falsches)
Die Farbe setz ich ueber bl.
msg db "[]",0
mov si,msg
mov bl, 0x03
call putstr
Was mach ich hier falsch?
-
ich hab nochmal ein bisschen probiert und entlich code gefunden der funzt und das ganze hab ich mit zuhilfename dar wiki das als int definiert
hier mal der code:
_int0x21:
_int0x21_ser0x01:
cmp al, 0x01
jne _int0x21_end
cmp ah, 0x01
jne _int0x21_ser0x01_start
_int0x21_ser0x01_ser0x01_start:
lodsb
or al,al
jz _int0x21_ser0x01__ser0x01_end
mov ah,09h
;<--- Farbattribut 0 = Schwarz 1 = Blau 2 = Grün 3 = Türkis 4 = Rot 5 = Magenta 6 = braun 7 = Hellgrau 8 = Dunkelgrau 9 = Hellblau a = Hellgrün b = Helltürkis c = Hellrot d = Hellmagenta e = gelb f = weiß
mov cx,0001h
int 10h
;Cursorposition auslesen
mov ah,03h
int 10h
inc dl
;und Cursorposition schreiben
mov ah,02h
int 10h
jmp _int0x21_ser0x01_ser0x01_start
_int0x21_ser0x01__ser0x01_end:
jmp _int0x21_end
_int0x21_ser0x01_start:
lodsb
or al, al
jz _int0x21_ser0x01_end
mov ah, 0x0E
mov bh, 0x00
mov bl, 0x07
int 0x10
jmp _int0x21_ser0x01_start
_int0x21_ser0x01_end:
jmp _int0x21_end
_int0x21_end:
iret
und auf rufen kann man das mit:
mov si, <text>
mov al, 0x01 ;<--- normale bios teletype output
int 0x21 ;<--- int 21h
mov si, <text>
mov al, 01h ;<--- schreiben
mov ah, 01h ;<--- mit farbe
mov bl, 0x7E ;<--- welche farbe: 0xhintergrund/textfarbe
int 21h ;<--- int 21h
und wie in der wiki steht man muss es noch intialiesieren:
push dx
push es
xor ax, ax
mov es, ax
cli
mov word [es:0x21*4], _int0x21 ; Pointer auf den Handler
mov [es:0x21*4+2], cs ; Pointer auf CS
sti
pop es
pop dx
ich hoffe ich konnte helfen
-
Ich hab mal versucht dass hier gepostete in meinen Kernel zu verpacken:
mov ax, 0x1000
mov ds, ax
mov es, ax
start:
mov ah,0x0
mov al,0x3
int 0x10 ; Textmodus, 80 x 25, 16 Farben
mov si, _s_noos_logo
mov ah, 0x03
call _v_noos_tprintf
mov si, _s_noos_jmp_good
mov ah, 0x0A
call _v_noos_tprintf
mov si,msg_boot
mov ah, 0x07
call _v_noos_tprintf
call _v_noos_getkey
jmp _v_noos_reboot
_s_noos_logo db "[ NoOS ]",0
_s_noos_jmp_good db " Jump into kernel successful",13,10,0
msg_boot db "Press any key...",10,0
; Funktionen
;%%%%%%%
;AL = Farbe
;SI = String
;==========
_v_noos_clrstrout:
lodsb
or al,al
jz short _v_noos_clrstroutd
mov cx, 1
xor bh, bh
mov ah,0x09
int 0x10
jmp _v_noos_clrstrout
_v_noos_clrstroutd
retn
;%%%%%%%%
;SI = String
;============
_v_noos_stdstrout:
lodsb
or al,al
jz short _v_noos_stdstroutd
mov ah,0x0E
mov bx,0x0007
int 0x10
jmp _v_noos_stdstrout
_v_noos_stdstroutd:
retn
_v_noos_getkey:
mov ah, 0
int 0x16
ret
_v_noos_reboot:
jmp 0xffff:0x0000
;%%%%%%%%%%
;AH = Farbe
;SI = String
;===============
_v_noos_tprintf:
lodsb
or al,al
jz short _v_noos_tprintfd
mov cx, 1
xor bh, bh
mov bl, ah
mov ah, 0x09
int 0x10
call _v_noos_inccrs
jmp _v_noos_tprintf
_v_noos_tprintfd:
call _v_noos_inccrs
retn
;%%%%%%%%%%%%
;AL = Zeichen
;==================
_v_noos_inccrs:
cmp al,10
jz _v_noos_incrsa
call _v_noos_get_cursor_pos
cmp dl,79
jz _v_noos_incrsa
inc dl
call _v_noos_set_cursor_pos
retn
_v_noos_incrsa:
call _v_noos_pnewline
retn
;%%%%%%%%%%%%%
_v_noos_pnewline:
call _v_noos_get_cursor_pos
inc dh,
xor dl,dl
call _v_noos_set_cursor_pos
retn
;%%%%%%%%%%
;DL = Spalte
;DH = Reihe
;===============
_v_noos_set_cursor_pos:
push ax
push bx
xor bh,bh
mov ah,0x02
int 0x10
pop bx
pop ax
retn
;%%%%%%%%%%%%%
;ret: DL = Spalte
;ret DH = Reihe
;===================
_v_noos_get_cursor_pos:
push ax
push bx
xor bh,bh
mov ah,0x03
int 0x10
push bx
push ax
retn
Unlustigerweise wird jedoch nur ein '[' ausgegeben.
-
ich würd sgen, dass 'inc dl,' nur 'inc dl heißen muss
und ein {enter} muss mit einer 'normalen' 'bios_string_output' geschrieben werden ich hab das bei mir so gelöst:
;unmengen zeilen an code .....
mov si, sys_msg ;<---- das ist farbig
mov al, 01h
mov ah, 01h
mov bl, 09h
int 21h
mov si, ent ;<-------- das ist das 'Enter'-zeichen
mov al, 0x01
int 0x21
;########
;#Variablen#
;########
;andere variablen...
ent db "",13,10,0
sys_msg db "SolOS System Ready.",0
;noch mehr variablen
;##############
;#int's und funktionen#
;##############
;int....
_int0x21:
_int0x21_ser0x01:
cmp al, 0x01
jne _int0x21_end
cmp ah, 0x01
jne _int0x21_ser0x01_start
_int0x21_ser0x01_ser0x01_start:
lodsb
or al,al
jz _int0x21_ser0x01__ser0x01_end
mov ah,09h
;<--- Farbattribut 0 = Schwarz 1 = Blau 2 = Grün 3 = Türkis 4 = Rot 5 = Magenta 6 = braun 7 = Hellgrau 8 = Dunkelgrau 9 = Hellblau a = Hellgrün b = Helltürkis c = Hellrot d = Hellmagenta e = gelb f = weiß
mov cx,0001h
int 10h
;Cursorposition auslesen
mov ah,03h
int 10h
inc dl
;und Cursorposition schreiben
mov ah,02h
int 10h
jmp _int0x21_ser0x01_ser0x01_start
_int0x21_ser0x01__ser0x01_end:
jmp _int0x21_end
_int0x21_ser0x01_start:
lodsb
or al, al
jz _int0x21_ser0x01_end
mov ah, 0x0E
mov bh, 0x00
mov bl, 0x07
int 0x10
jmp _int0x21_ser0x01_start
_int0x21_ser0x01_end:
jmp _int0x21_end
_int0x21_end:
iret
;funktionen
;....
ich hoffe du kannst damit was anfangen
-
ich würd sgen, dass 'inc dl,' nur 'inc dl heißen muss
und ein {enter} muss mit einer 'normalen' 'bios_string_output' geschrieben werden ich hab das bei mir so gelöst:
ich hoffe du kannst damit was anfangen
Erstmal danke.
Ich hab es mal so probiert (die ints hab ich nicht registriert im interrupt table registriert, ich verwende call)
mov ax, 0x1000
mov ds, ax
mov es, ax
start:
mov ah,0x0
mov al,0x3
int 0x10 ; Textmodus, 80 x 25, 16 Farben
mov si, _s_noos_logo
mov ah, 0x03
call _v_noos_stdstrout
mov si, _s_noos_jmp_good
mov ah, 0x0A
call _v_noos_stdstrout
call _v_noos_printlogo
mov si, _s_noos_detdrvs
mov ah, 0x07
call _v_noos_stdstrout
mov si, _s_noos_drv00
mov ah, 0x07
call _v_noos_stdstrout
mov dl,0x00
call _v_noos_get_drv_state
cmp ah,00h
jne _l_noos_gdrvchk_error
mov si, _s_noos_drv01
mov ah, 0x07
call _v_noos_stdstrout
;mov dl,0x01
;call _v_noos_get_drv_state
;cmp ah,00h
;jne _l_noos_gdrvchk_error
jmp _l_noos_chk_end
_l_noos_gdrvchk_error:
call _v_noos_drvchk_error
retn
_l_noos_chk_end:
mov si,msg_boot
mov ah, 0x07
call _v_noos_stdstrout ;_v_noos_tprintf
call _v_noos_getkey
jmp _v_noos_reboot
_s_noos_logo db "[ NoOS ]",0
_s_noos_jmp_good db " Jump into kernel successful",0
_s_noos_detdrvs db " Detecting drives...",0
_s_noos_drv00 db " drive 00...",0
_s_noos_drv01 db " drive 01...",0
_s_noos_drv80 db " drive 80....",0
_s_noos_drv81 db " drive 81....",0
_s_noos_drvchk_error db " DRIVE ERROR!",0
msg_boot db "Press any key...",0
ent db "",13,10,0
; Funktionen
;%%%%%%%%%%%
_v_noos_drvchk_error:
mov si,_s_noos_drvchk_error
mov ah,0x04
call _v_noos_stdstrout
retn
;%%%%%%%%%
;ret: AH = Fehlercode
;DL = Laufwerknummer
;==============
_v_noos_get_drv_state:
mov ah,0x00
int 0x13
retn
;%%%%%%%%%
_v_noos_printlogo:
mov si, _s_noos_logo
call _v_noos_stdstrout
;%%%%%%%
;AL = Farbe
;SI = String
;==========
_v_noos_clrstrout:
lodsb
or al,al
jz short _v_noos_clrstroutd
mov cx, 1
xor bh, bh
mov ah,0x09
int 0x10
jmp _v_noos_clrstrout
_v_noos_clrstroutd
retn
;%%%%%%%%
;SI = String
;============
_v_noos_stdstrout:
push bx
mov bl,ah
mov al,0x01
mov ah,01h
call _int0x21
mov si, ent
mov al, 0x01
call _int0x21
pop bx
retn
_v_noos_getkey:
mov ah, 0
int 0x16
ret
_v_noos_reboot:
jmp 0xffff:0x0000
;%%%%%%%%%%
;AH = Farbe
;SI = String
;===============
_v_noos_tprintf:
lodsb
or al,al
jz short _v_noos_tprintfd
mov cx, 1
xor bh, bh
mov bl, ah
mov ah, 0x09
int 0x10
call _v_noos_inccrs
jmp _v_noos_tprintf
_v_noos_tprintfd:
call _v_noos_inccrs
retn
;%%%%%%%%%%%%
;AL = Zeichen
;==================
_v_noos_inccrs:
cmp al,10
jz _v_noos_incrsa
call _v_noos_get_cursor_pos
cmp dl,79
jz _v_noos_incrsa
inc dl
call _v_noos_set_cursor_pos
retn
_v_noos_incrsa:
call _v_noos_pnewline
retn
;%%%%%%%%%%%%%
_v_noos_pnewline:
call _v_noos_get_cursor_pos
inc dh
xor dl,dl
call _v_noos_set_cursor_pos
retn
;%%%%%%%%%%
;DL = Spalte
;DH = Reihe
;===============
_v_noos_set_cursor_pos:
push ax
push bx
xor bh,bh
mov ah,0x02
int 0x10
pop bx
pop ax
retn
;%%%%%%%%%%%%%
;ret: DL = Spalte
;ret DH = Reihe
;===================
_v_noos_get_cursor_pos:
push ax
push bx
xor bh,bh
mov ah,0x03
int 0x10
push bx
push ax
retn
_int0x21:
_int0x21_ser0x01:
cmp al, 0x01
jne _int0x21_end
cmp ah, 0x01
jne _int0x21_ser0x01_start
_int0x21_ser0x01_ser0x01_start:
lodsb
or al,al
jz _int0x21_ser0x01__ser0x01_end
mov ah,09h
; <--- Farbattribut 0 = Schwarz 1 = Blau 2 = Grün 3 = Türkis 4 = Rot 5 = Magenta 6 = braun 7 = Hellgrau 8 = Dunkelgrau 9 = Hellblau a = Hellgrün b = Helltürkis c = Hellrot d = Hellmagenta e = gelb f = weiß
mov cx,0001h
int 10h
;Cursorposition auslesen
mov ah,03h
int 10h
inc dl
;und Cursorposition schreiben
mov ah,02h
int 10h
jmp _int0x21_ser0x01_ser0x01_start
_int0x21_ser0x01__ser0x01_end:
jmp _int0x21_end
_int0x21_ser0x01_start:
lodsb
or al, al
jz _int0x21_ser0x01_end
mov ah, 0x0E
mov bh, 0x00
mov bl, 0x07
int 0x10
jmp _int0x21_ser0x01_start
_int0x21_ser0x01_end:
jmp _int0x21_end
_int0x21_end:
retn
;funktionen
Die Ausgabe sieht so aus:
]
Detecting drives
drive 00...
drive 01...
Press any key...
Das ']' hat die Farbe gelb. Irgendwie heisst das ja, dass alles ausgegeben wird, was bl,0x07 hat, nicht aber das, was eine andere Farbe hat?
-
So. Ich habs nun hingekriegt.
main:
mov ax, 0x1000 ;update segment register...
mov ds, ax
mov es, ax
init0:
mov si,s_noos_init0
call noos_putstr
mov bl, 0x05
mov si, s_noos_logo
call noos_printf
mov bl, 0x02
mov si, s_noos_jmp_good
call noos_printf
call noos_inc_line
call noos_getkey
;Variablen
;========
s_noos_init0 db "Init 0",13,10,0
s_noos_logo db "[ NoOS ]",0
s_noos_jmp_good db " Jump into kernel successful",0
;Funktionen
;========
;ret: DL = Spalte; ret: DH = Zeile
noos_get_cursor_pos:
mov ah, 0x03
int 0x10
retn
;DL = Spalte; DH = Zeile
noos_set_cursor_pos:
mov ah, 0x02
push bx
xor bh, bh
int 0x10
pop bx
retn
noos_inc_line:
call noos_get_cursor_pos
inc dh
call noos_set_cursor_pos
retn
noos_inc_row:
call noos_get_cursor_pos
inc dl
call noos_set_cursor_pos
retn
;SI = string
noos_printf:
lodsb
or al,al
jz noos_printf_end
call noos_putchar
call noos_inc_row
jmp noos_printf
noos_printf_end:
retn
;AL = char; BL = Farbe
noos_putchar:
push cx
mov cx, 1
mov ah, 0x09
int 0x10
pop cx
retn
;SI = string
noos_putstr:
lodsb
or al, al
jz noos_putstr_end
mov ah, 0x0E
mov bx, 0x07
int 0x10
jmp noos_putstr
noos_putstr_end:
retn
noos_reboot:
jmp 0xffff:0x0000
noos_getkey:
mov ah,0
int 0x16
retn
Ich hoffe das hilft vlt auch anderen weiter.
Eine kleine Frage verbleibt jedoch:
Bei getkey wird irgendwie die Cursorposition veraendert, seh ich das richtig?
Und wie kann ich dafuer sorgen, dass sie das nicht wird?
-
so wie ich das sehe wird sie erst bei set_key geändert
vermeiden kanst du es in dem du set_key weg lässt ... xD
-
so wie ich das sehe wird sie erst bei set_key geändert
vermeiden kanst du es in dem du set_key weg lässt ... xD
set_key?
-
noos_set_cursor_pos:
bei mir ist es schon bei getkey einen weiter gerückt, wenn du das meintest
-
noos_set_cursor_pos:
bei mir ist es schon bei getkey einen weiter gerückt, wenn du das meintest
Stimmt, vor getkey sollte ich die Cursorpos wieder auf 0 setzen.