News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

ringing tones

Started by cl4ud10, March 22, 2006, 10:41:22 AM

Previous topic - Next topic

cl4ud10

hello everybody...
can you help me make a program in assembly, that compose ring tones......

i'm very confused about this, my lecturer gave me this task at our first class.

FYI, the input of that program  is num pad 1 to 7 that represent' C D E F G A B C'  in octaf

thanks 4 ur attention......

skywalker

Quote from: cl4ud10 on March 22, 2006, 10:41:22 AM
hello everybody...
can you help me make a program in assembly, that compose ring tones......

i'm very confused about this, my lecturer gave me this task at our first class.

FYI, the input of that program  is num pad 1 to 7 that represent' C D E F G A B C'  in octaf

thanks 4 ur attention......

Go on and post what you have so far.


NPNW

QuoteFYI, the input of that program  is num pad 1 to 7 that represent' C D E F G A B C'  in octaf

Did he want this done in assembly? I will say yes since we are in assembly forum.

You would need to look up the key codes for num pad "1 to 7" Which correspond  to "C D E F G A B C"

num pad key 1 =C
num pad key 2 =D
etc.

These are musical notes. You would compose a song, or tune useing these keys to represent music that can be played back as a song.

I would get a keyboard of some type and label C through C 1 to 7. Then you could practice making a tune. Write down your numbers. Then create a program to duplicate this.

Otherwise we are guessing what your instructor wants? Ask him what he wants?


cl4ud10

Quote
Go on and post what you have so far.

this is what i have done  :

NoPCsound MACRO
IN AL,61h ; get data from Port 61h
AND AL,0FCh
OUT 61h,AL ; put the value to Port 61h
ENDM
PCsound MACRO Hz
MOV AL,0B6h
OUT 43h,AL
MOV DX,0012h
MOV AX,3540h ; divide 123540H by the frequency
MOV BX,Hz
DIV BX
OUT 42h,AL
MOV AL,AH
OUT 42h,AL
IN AL,61h ; get port 61h  data <Speaker>
OR AL,03
OUT 61h,AL ;speaker
ENDM


.MODEL SMALL
.CODE
ORG 100h

Utama :
MOV AH,0 ; Input a character
INT 16h

salam :
CMP AL,'1'   // if AL=='1' then C();
JE C

CMP AL,'2'   // if AL=='2' then D();
JE D

CMP AL,'3'  // if AL=='3' then E();
JE E

CMP AL,'4'  // if AL=='4' then F();
JE F

CMP AL,'q'  // if AL=='q' then exit();
JMP exit

bagian :
MOV AH,0
INT 16h
JMP salam

C :
PCsound 275 //assume 275 is frequency for C
MOV AH,00
JMP bagian
F :
PCsound 340 //assume 340 is frequency for F
MOV AH,00
JMP bagian

E :
PCsound 220 //assume 220 is frequency for E
MOV AH,00
JMP bagian

D :
PCsound 207  //assume 207 is frequency for D
MOV AH,00
JMP bagian

exit : INT 20h //exit
END Utama


--------

the code works so far.......
but, the problem occured when i put another 'jump' for G, A, B, .....
the error message is : relative jump out of range...

i still dunno why it happened....


ChrisLeslie

cl4ud10,

Just a few comments on your coding style:

Do not use a SMALL model and start with org 100h. Use a TINY model for this.
Put the mode directive at the start, then followed by the macros.
Don't use C-style comment symbols, ie "//". Use ";" instead.
Do not put a space between a label name and the ";". Use "Utama:", not "Utama :"
Try not to use single letter labels, e.g. "C:". Use something like "note_C:".
Don't use "exit" as a label.

Try implementing those suggestions and try again.

Chris