0% found this document useful (0 votes)
13 views8 pages

WORKFLOW of Final Assignment 1

The document outlines a final assignment for an IT course, focusing on a program that utilizes MIDI output through syscall 31 to simulate sound. It details the parameters required for MIDI playback, the structure of the program, and the execution flow including song selection and interrupt handling. The program allows users to play four predefined songs and exit by pressing a designated key.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views8 pages

WORKFLOW of Final Assignment 1

The document outlines a final assignment for an IT course, focusing on a program that utilizes MIDI output through syscall 31 to simulate sound. It details the parameters required for MIDI playback, the structure of the program, and the execution flow including song selection and interrupt handling. The program allows users to play four predefined songs and exit by pressing a designated key.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

FINAL ASSIGNMENT – CA Lab – IT3280E

(Project 16)

Student’s name: Hà Đức Dương


Student's code: 20235923

Workflow of the program:

I. BASIC KNOWLEGDE
1.MIDI SYSTEM (SYSCALL 31)
- MIDI output is simulated by your system sound
card, and the simulation is provided by the
javax.sound.midi package.

- These system services come from RARS 1.6 and


provide a means of producing sound. (syscall 31
included in RARS 1.6)

- This service requires four parameters as follows:


+ 1. pitch (a0): Range (0-127). If the parameter
value is outside this range, it applies to a default
value 60 which is the same as middle C on a piano.

+ 2. duration in milliseconds (a1): Accepts a


positive integer value that is the length of the tone
in milliseconds. If the parameter value is negative,
it applies a default value of one second (1000
milliseconds).

+ 3. instrument (a2): Range (0-127) that denotes


the General MIDI "patch" used to play the tone. If
the parameter is outside this range, it applies a
default value 0 which is an Acoustic Grand Piano.
+ 4. volume (a3): Range (0-127) where 127 is the
loudest and 0 is silent. If the parameter value is
outside this range, it applies to a default value of
100.

- To use syscall 31, you have to load all 4 values of 4


initial parameters which were mentioned. The
simple concept of a song played in this program is
like this (based on how many notes you want to
play in a song):

+ Example: song: .word 60, 1000, 1, 100


.word 61, 1000, 1, 100
.word -1
(1 is a value that shows the song will come to its
end when a0 = -1.)

- When running the program, set "run speed at max" to


20 inst/sec for the best experience.
2.Interrupt and stack technique (using DIGITAL
LAB SIM)
(I use Lab 11’s knowledge, and I will explain it in
PROGRAM EXECUTION)
II. PROGRAM EXECUTION
1. The whole main idea of the program is based on
how MIDI OUTPUT (syscall 31), “interrupt and
stack” and DIGITAL LAB SIM work, and I have
created 4 full songs with the simple concept for
testing the codes. (Integrated in the program).
Open DIGITAL LAB SIM and choose the option:

+ 1. ABC song (abcsongm1 in the source code)


(Press 1 and enter)
+ 2. Pickleball (pickleballm2 in the source code)
(Press 2 and enter)
+ 3. ABC song p1 (abcp1m3 in the source code)
(Press 3 and enter)
+ 4. ABC song p2 (abcp2m4 in the source code)
(Press 4 and enter)

To stop and exit the program, press 0 and enter.

2. Main function:
+ Setup the interrupt (main): my first step is
providing first lines of code to enable the
interrupt:

+ loop: the loop is less initial in this source. It is


an infinite loop just to wait for button press
(interrupt occurs):
+ handler: it is the main part of the Interrupt
Service Routine (ISR). It contains 3 main parts:
1. Provide the stack to store a0, a1, a2, a3, t1, t2
using register sp:

2. Read and process the button:


3. Restore the value of a0, a1, a2, a3, t1, t2 using
h_end function:
+play1, play2, play3, play4: those labels are an
important step to reach the playloop, where the
song you choose will be played based on the
note’s concept in each prepared song’s data:

t0 will hold the base address of the song you


choose (for example, if you choose “1”, t0 will
hold the the base address of abcsongm1 or ABC
song). Then, jump to the “playloop” label.

+ playloop:

playloop has 4 main parts that make the song’s


data loaded into the program and play back the
song:
1. Load a0 (pitch) and check the song status:

For example (choosing the “ABC song”, “1”


press):
a0’s value now will be 60 – the base address’s
value of abcsongm1:

2. Load the a1, a2, a3’s value of the first note


(duration, instrument and volume of the first
note):

a1 will receive the value “500”, a2’s will be “1”


and a3’s will be “100” (based on the above
code, just increase the base address by “4” for
three times)
3. Play the note using syscall 31 – MIDI OUTPUT:

4. Move to the next note and repeat until the end


of the song

As the description, the value of t0 is now


increasing by 16, meaning that t0 will hold the
base address of the new note. The loop
continues until a0 meets “-1” then the song
will end immediately.
+exit_program : The end of the code if pressing
“0”

You might also like