Autor Thema: cls in Assembler  (Gelesen 3985 mal)

Cool-Andy

  • Gast
Gespeichert
« am: 30. October 2009, 21:57 »
Hi,

ich bin grad dabei im Real Mode (ja, ich weiß der ist schlecht) eine Funktion in Assembler zu schreiben, die den Bildschirm leeren soll:
        mov     ax, 40h
        mov     ds, ax
        mov     ah, 06h
        mov     al, 0   ; Alle Zeilen scrollen
        mov     bh, 7  ; Schriftfarbe
        mov     ch, 0   ; Zeile
        mov     cl, 0   ; Splate
        mov     di, 84h
        mov     dh, [di]
        mov     di, 4ah
        mov     dl, [di]
        dec     dl     
        int     10h

        ; und den Cursor auf Bildschirmanfang setzen:
        mov     bh, 0   ; Bildschirmpage
        mov     dl, 0   ; Reihe
        mov     dh, 0   ; Zeile
        mov     ah, 02
        int     10h
Der Bildschirm wird zwar gelöscht, der Cursor bleibt auf seiner alten Position!  :-(

Findet jemand von euch den Fehler?

DerHartmut

  • Beiträge: 236
    • Profil anzeigen
    • Mein Blog
Gespeichert
« Antwort #1 am: 30. October 2009, 23:47 »
Bildschirmpage 0 kommt mir etwas komisch vor...und probier's mal mit 1, 1 als Position.
$_="krJhruaesrltre c a cnp,ohet";$_.=$1,print$2while s/(..)(.)//;
Nutze die Macht, nutze Perl ;-)

Cool-Andy

  • Gast
Gespeichert
« Antwort #2 am: 31. October 2009, 08:58 »
Ne, das war's nicht.
Hab allgemein mal ein bisschen an den Positionen/Pages rumgespielt, da verändert sich überhaupt nichts.
Bin echt ratlos!  :?

DerHartmut

  • Beiträge: 236
    • Profil anzeigen
    • Mein Blog
Gespeichert
« Antwort #3 am: 31. October 2009, 11:25 »
       
mov     bh, 0   ; Bildschirmpage
        mov     dl, 0   ; Reihe
        mov     dh, 0   ; Zeile
        mov     ah, 02
        int     10h

Man mach als dem "02" ein "02h".
$_="krJhruaesrltre c a cnp,ohet";$_.=$1,print$2while s/(..)(.)//;
Nutze die Macht, nutze Perl ;-)

Cjreek

  • Beiträge: 104
    • Profil anzeigen
Gespeichert
« Antwort #4 am: 31. October 2009, 11:34 »
02d = 02h   :wink:

Daran wirds nicht liegen  :-D

Edit: Also bei mir funktioniert folgendes (exakt dein Code) ohne Probleme

[ORG 0x7C00]
mov ax, 40h
mov ds, ax
mov ah, 06h
mov al, 0   ; Alle Zeilen scrollen
mov bh, 7  ; Schriftfarbe
mov ch, 0   ; Zeile
mov cl, 0   ; Splate
mov di, 84h
mov dh, [di]
mov di, 4ah
mov dl, [di]
dec  dl     
int 10h

mov bh, 0   ; Bildschirmpage
mov dl, 0   ; Reihe
mov dh, 0   ; Zeile
mov ah, 02
int 10h

jmp $

times 510 - ($-$$) db 0
dw 0xAA55
« Letzte Änderung: 31. October 2009, 11:45 von Cjreek »
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."

DerHartmut

  • Beiträge: 236
    • Profil anzeigen
    • Mein Blog
Gespeichert
« Antwort #5 am: 31. October 2009, 12:45 »
Manche Assembler meckenr aber ohne h oder vorangestelltem 0x dennoch ;-)
$_="krJhruaesrltre c a cnp,ohet";$_.=$1,print$2while s/(..)(.)//;
Nutze die Macht, nutze Perl ;-)

Cjreek

  • Beiträge: 104
    • Profil anzeigen
Gespeichert
« Antwort #6 am: 31. October 2009, 14:33 »
Wieso sollten sie? o.O

Sind dann halt dezimalzahlen  :roll:
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."

Cool-Andy

  • Gast
Gespeichert
« Antwort #7 am: 31. October 2009, 17:03 »
OK, danke
der Bildschirm wird jetzt geleehrt und der Cursor auf den Anfang des Bildschirms gesetzt :-D.
Allerdings: Nach einer Bildschirmlöschung funktioniert die Textausgabe nicht mehr.  :|
Ich versteh's nicht!

Mein Code:
kernel.asm:
; Die include-Funktionen überspringen:
jmp main


; Die Funktionen includen:
%include "functions.asm"


; Das Ziel der "main-Jump"-Anweisung:
main:


; Das Segmentregister updaten:
mov ax, 0x1000
mov ds, ax
mov es, ax


; Hier beginnt der eigentliche Kernel-Code:
mov si, text
mov bh, 7
call textout ; Den String "text" ausgeben

call waitkey ; Auf einen Tastendruck warten
call cls
mov si, msg             ; Den String "msg" ausgeben
mov bh, 7
call textout
call waitkey

call reboot ; und rebooten


; Die Variablen:
text db "Hi",13,10,0
msg db "Hello",13,10,0

und functions.asm:
; Den Bildschirm löschen:
cls:
mov ax, 40h
mov ds, ax
mov ah, 06h
mov al, 0   ; Alle Zeilen scrollen
mov bh, 7  ; Schriftfarbe
mov ch, 0   ; Zeile
mov cl, 0   ; Splate
mov di, 84h
mov dh, [di]
mov di, 4ah
mov dl, [di]
dec  dl     
int 10h

mov bh, 0   ; Bildschirmpage
mov dl, 0   ; Reihe
mov dh, 0   ; Zeile
mov ah, 02
int 10h
ret ; Die Funktion beenden

; Textausgabe: (!ACHTUNG IN "BX" MUSS DER FARBCODE LIEGEN!)
textout:
lodsb ; Byte laden
or al, al
jz short textoutend ; wenn Byte=0, dann zu "textoutend" springen
mov ah, 0x0E ; Funktion 0x0E
int 0x10 ; Interrupt 0x10 Ausführen (Textausgabe)
jmp textout ; nächstes Byte bearbeiten

textoutend:
ret ; Funktion beenden


; Auf einen Tastendruck warten:
waitkey:
mov ah, 0 ; Funktion 0
int 0x16 ; Interrupt 0x16 ausführen (Tastendruck entgegnnehmen)
ret ; Funktion beenden


; Rebooten:
reboot:
jmp 0xffff:0x0000

Cool-Andy

  • Gast
Gespeichert
« Antwort #8 am: 01. November 2009, 13:54 »
Hat den niemand eine Idee?  :|

Cool-Andy

  • Gast
Gespeichert
« Antwort #9 am: 01. November 2009, 15:23 »
Juhuuuuu,
ich hab es hinbekommen!
Keine Ahnung, wo der Fehler lag, aber es funktoniert jetzt!  :-D

 

Einloggen