Seite 1 von 1
Turbo C++ 3.1 und Inline Asembler
Verfasst: So 21. Jun 2015, 19:00
von matze79
Ich versuche eine Funktion Beep zu erstellen in Turbo C++ 3.1:
Code: Alles auswählen
void beep(void){
asm{
mov cx,14h
mov ax,0e07h
int 10h
mov ax,4c00h
int 21h
}
}
Leider mag er das nicht.
Der selbe Code lässt sich mit TASM übersetzen und beept auch.
Jemand eine Idee was ich Falsch mache ?
Grüsse
Matthias
Re: Turbo C++ 3.1 und Inline Asembler
Verfasst: So 21. Jun 2015, 20:57
von wobo
Warum rufste denn die DOS EXIT-function $4c auf? Du bist doch in einer Hochsprache?
Was ist denn Int $10, $0e07 für eine Funktion? Ich kenne die nicht und auch Ralph Brown kennt sie nicht...
Re: Turbo C++ 3.1 und Inline Asembler
Verfasst: So 21. Jun 2015, 21:03
von matze79
das liegt daran das ich den Code nur geklaut habe, und ich prinzipiell sogut wie kein x86 ASM kann.
http://www.rohitab.com/discuss/topic/20 ... r-in-tasm/
Code: Alles auswählen
.model tiny
.stack 100h
.code
Start:
mov cx,14h
mov ax,0e07h
Looping:
int 10h
loop looping
jmp exit
Exit:
mov ax,4c00h
int 21h
End Start
Ich möchte einfach nur einen Beep ausgeben :)
Mal sehen:
http://www.gamers.org/dEngine/rsc/pcgpe-1.0/speaker.txt
Re: Turbo C++ 3.1 und Inline Asembler
Verfasst: So 21. Jun 2015, 22:44
von wobo
Jetzt habe ich das kapiert - ganz schön clever:
Code: Alles auswählen
Function 0Eh: Write Character
Writes the specified character to the current cursor position in the current display page. In text modes, the attribute byte is not modified. The cursor is moved to the next screen position, and the screen is scrolled up if necessary. Special ASCII characters, like carriage return and backspace, are interpreted as control codes and will modify the cursor position accordingly.
Inputs
AH = 0Eh
AL = ASCII code.
Wenn Du die Zeilen
mov ax, 4c00h
int 21h
wegläßt, funtioniert es nicht?
Läuft das:
Code: Alles auswählen
#include<stdio.h>
int main()
{
printf("Beept es einmal?!?");
asm{
mov cx,14h
mov ax,0e07h
int 10h
}
return 0;
}
Re: Turbo C++ 3.1 und Inline Asembler
Verfasst: Mo 22. Jun 2015, 17:08
von matze79
Ja so gehts :)
Besten Dank!
EDIT:
Es geht :)