Turbo C++ 3.1 und Inline Asembler

Diskussion zum Thema Programmierung unter DOS (Intel x86)
Antworten
Benutzeravatar
matze79
DOS-Gott
Beiträge: 7910
Registriert: So 9. Sep 2012, 20:48

Turbo C++ 3.1 und Inline Asembler

Beitrag 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
https://www.shadowcircuit.de - Die kleine Community rund um Retro Computing
https://www.retroianer.de
wobo
DOS-Guru
Beiträge: 614
Registriert: So 17. Okt 2010, 14:40

Re: Turbo C++ 3.1 und Inline Asembler

Beitrag 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...
Benutzeravatar
matze79
DOS-Gott
Beiträge: 7910
Registriert: So 9. Sep 2012, 20:48

Re: Turbo C++ 3.1 und Inline Asembler

Beitrag 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
https://www.shadowcircuit.de - Die kleine Community rund um Retro Computing
https://www.retroianer.de
wobo
DOS-Guru
Beiträge: 614
Registriert: So 17. Okt 2010, 14:40

Re: Turbo C++ 3.1 und Inline Asembler

Beitrag 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;
}
Benutzeravatar
matze79
DOS-Gott
Beiträge: 7910
Registriert: So 9. Sep 2012, 20:48

Re: Turbo C++ 3.1 und Inline Asembler

Beitrag von matze79 »

Ja so gehts :)

Besten Dank!

EDIT:
Es geht :)
https://www.shadowcircuit.de - Die kleine Community rund um Retro Computing
https://www.retroianer.de
Antworten