;********************************************************************* ; Programm-Name: MACROS.ASM ; ------------------------- ; ; Dieses File enthält nützliche MACROS, die man immer wieder braucht; ; sie werden mit 'INCLUDE MACROS.ASM' in andere Programme eingebunden. ; ; Es werden DOS- und BIOS-Funktionen verwendet. ---> INT 10H (BIOS) ; INT 21H (DOS ) ; ;********************************************************************* ;-------------------------------------------------------------------- ; Bildschirm löschen (indem der Videomodus noch einmal gesetzt wird) ;-------------------------------------------------------------------- ClrScr MACRO push ax mov ah,0 ; Set Mode mov al,3 ; 80 x 25 Color INT 10H ; BIOS-Funktion pop ax ENDM ;-------------------------------------------------------------------- ; Positionierung des Cursors ;-------------------------------------------------------------------- Set_Cursor MACRO Zeile,Spalte push ax push bx push dx mov ah,2 mov dh,Zeile mov dl,Spalte mov bh,0 ; Nummer der Bildschirmseite INT 10H ; BIOS-Funktion pop dx pop bx pop ax ENDM ;-------------------------------------------------------------------- ; Ein Zeichen von der Tastatur lesen und auf dem Bildschirm ausgeben. ; Das eingelesene Zeichen steht in AL (im ASCII Code) ;-------------------------------------------------------------------- Read_KBD_and_Echo MACRO mov ah,1 INT 21H ; DOS-Funktion ENDM ;-------------------------------------------------------------------- ; Ein Zeichen von der Tastatur lesen; keine Bildschirmausgabe. ; Das eingelesene Zeichen steht in AL (im ASCII Code) ;-------------------------------------------------------------------- Read_KBD_no_Echo MACRO mov ah,8 INT 21H ; DOS-Funktion ENDM ;-------------------------------------------------------------------- ; Ein Zeichen auf dem Bildschirm ausgeben; Zeichen muss in DL stehen! ;-------------------------------------------------------------------- Display_Char MACRO push ax mov ah,2 INT 21H ; DOS-Funktion pop ax ENDM ;-------------------------------------------------------------------- ; Ausgabe einer Zeichenkette auf den Bildschirm ;-------------------------------------------------------------------- Display_String MACRO String_adr push dx push ax mov dx,OFFSET String_adr mov ah,9 INT 21H ; DOS-Funktion pop ax pop dx ENDM ;-------------------------------------------------------------------- ; Piepton erzeugen ;-------------------------------------------------------------------- Beep MACRO push dx mov dl,7 display_char ; MACRO ! pop dx ENDM ;-------------------------------------------------------------------- ; Warteschleife --> Wartezeitangabe in ms, z.B. WARTE 1000 ;-------------------------------------------------------------------- Warte MACRO Zeit LOCAL SCHL1,SCHL2 push cx mov cx,Zeit SCHL1: push cx mov cx,4700 SCHL2: loop SCHL2 pop cx loop SCHL1 pop cx ENDM ;-------------------------------------------------------------------- ; Neue Zeile beginnen (new line) --> Ausgabe von CR / LF ;-------------------------------------------------------------------- nl MACRO mov dl,10 Display_Char mov dl,13 Display_Char ENDM ;-------------------------------------------------------------------- ; Programm beenden ;-------------------------------------------------------------------- Terminate_Program MACRO mov ah,4CH mov al,0 ; DOS-Exit-Code! INT 21H ; DOS-Funktion ENDM ;-------------------------------------------------------------------- ;-------------------------------------------------------------------- ; ; Eigene Makros ; ;-------------------------------------------------------------------- ;-------------------------------------------------------------------- ;-------------------------------------------------------------------- ; DOS-Versionsnummer ermitteln ;-------------------------------------------------------------------- DOS_Version MACRO mov ah,30h xor al,al int 21h ; DOS-Funktion ENDM ;-------------------------------------------------------------------- ; DOS-Versionsnummer ermitteln ;-------------------------------------------------------------------- Freier_Speicher MACRO Geraet push bx push cx mov ah,36h xor al,al mov dl,Geraet INT 21h ; DOS-Funktion mul cx mul bx pop cx pop bx ENDM