Tuesday, August 30, 2011

Simple Project in Assembly Language - Menu


This was supposed to be my project in assembly language. (The truth is, I have never tried to master assembly language programming and I have already forgotten how the code below works. LOL! But I'm going to share it anyway.)

I thought I did not have a copy of this but I found a copy on my previous blog.

They called this "Menu"

The code below is just part of the program. Download the whole program here or here
This should be assembled using the A86 Assembler by  Eric Isaacson.


Enjoy!

start:
    ;set video mode
                mov     AH, 00h     ; I want to set the video mode...
                mov     AL, 03h     ; ...to 80x25x16
                int     10h         ; Call video interrupt

    call clear_screen

    ;--------------------------display choices
    mov ah, 09
    lea dx, box1
    int 21h
    

    mov ah, 09
    lea dx, choice
    int 21h
    

    call crlf

    mov ah, 09
    lea dx, choice1
    int 21h

    call crlf
    
    mov ah, 09
    lea dx, choice2
    int 21h

    call crlf   

    mov ah, 09
    lea dx, choice3
    int 21h

    call crlf 
    
    mov ah, 09
    lea dx, choice4
    int 21h
    
    call crlf 
    
    mov ah, 09
    lea dx, choice5
    int 21h
    
    call crlf 
    
    mov ah, 09
    lea dx, choice6
    int 21h

    call crlf 
    
    mov ah, 09
    lea dx, choice7
    int 21h

    call crlf

    mov ah, 09
    lea dx, box2
    int 21h
    

    call crlf

    ;-----------------prompt user of letters a-f or z
    call crlf
    call crlf 
    
    mov ah, 09
    lea dx, prompt
    int 21h

    ;---------------get input character
    mov ah, 01
    int 21h

    ;----compare input character with... and execute chosen subprogram
    cmp al, '1'
    je one
    cmp al, '2'
    je two
    cmp al, '3'
    je three
    cmp al, '4'
    je four    
    cmp al, '5'
    je five    
    cmp al, '6'
    je six
    cmp al, '0'
    je endendend
    
    ;-------------------no match
    mov ah, 09
    lea dx, no_match
    int 21h

    call crlf
    call crlf
    jmp next

     jmp start
one:
    call crlf 
    call crlf 
    call display_biodata_with_border   
    jmp next
two:
    call crlf 
    call crlf 
    call reverse_string
    jmp next
three:
    call crlf 
    call crlf
    call password
    jmp next
four:
    call crlf 
    call crlf
    call horizontal
    call crlf 
    call crlf    
    call crlf 
    call crlf
    call crlf 
    call crlf
    call crlf 
    call crlf

    jmp next
five:
    call crlf 
    call crlf
    call quadrant
    jmp next    
six:
    call crlf 
    call crlf
    call addition
    jmp next
endendend:
    jmp ending

;-------------------press any key to continue
next:
    mov ah, 09
    lea dx, Press_anyKey
    int 21h
    
    mov ah, 01
    int 21h
      
      cmp al, '0'
      je endendend

    
    call crlf 
    call crlf
    call crlf 

    ;set video mode
                mov     AH, 00h     ; I want to set the video mode...
                mov     AL, 03h     ; ...to 80x25x16
                int     10h         ; Call video interrupt

    call clear_screen
    
    jmp start

ending:
    mov ah, 09
    lea dx, closing
    int 21h

    ret

Monday, August 29, 2011

Solution to Decorator Pattern Exercises of C# 3.0 Design Patterns

Decorator Pattern (this description is directly taken from the book C# 3.0 Design Patterns by Judith Bishop)

The role of the Decorator pattern is to provide a way of attaching new state and behavior to an object dynamically. The object does not know it is being “decorated,” which makes this a useful pattern for evolving systems. A key implementation point in the Decorator pattern is that decorators both inherit the original class and contain an instantiation of it.

Image is taken from www.dofactory.com

Click here to download my solution to the exercises.

These are the exercises from the book with a few comments oh how I coded my solution for each:

1. Assume that the Photo class was written with Drawer as a plain (not virtual) method and it cannot be altered. Reconstruct Example 2-2 so that it works under this constraint. (Hint: use an interface as in the theory example.)

2. Add to the Photo Decorator system a second type of component called Hominid. Use the drawing methods for ovals and lines to draw an approximation of a person. Then, use the same two  decorators—Tag and Border—to decorate Hominid objects.

3. Add other event handlers to the constructors of the decorators, together with additional behavior. For example, an OnClick event could cause a tag to appear, rather than having it appear  automatically.

4. Decorate the Console class so that Write and WriteLine methods are trapped and the output is reformatted for lines of a given size, avoiding unsightly wraparounds. Test your decorator with the program in Example 2-1.
Comments:
The Console class cannot be inherited because it is static. What I did here is I created a constructor that has a parameter that takes a TextWriter. The client needs to pass the Console.Out as parameter to the ConsoleDecorator's constructor.


5. Write a program that decorates the Stream class and shows how much of a file has been read in, using a trackbar.

Comments:
I used a ProgressBar instead of a TrackBar.
I created an event that will be raised each time a character is read by the TrackStream.Read() method.

 
6. Write a program that decorates the Stream class and asks for a password before allowing reading to continue.

7. Write a program that decorates a text message with a simple cipher. Include a second decorator that transforms the encrypted message back to plain text.
Comments:
I used a simple cipher called the Caesar's Cipher

Sunday, August 28, 2011

Some reharmonization ideas from Greg Howlett


Greg Howlett is a Christian concert pianist and recording artist.

I have watched many of his free video lessons and blog posts on reharmonization.

Listed below are some of the reharmonization ideas I got from him.
  1. A ii chord substitues for a V chord (and a IV chord).
  2. A iii chord substitutes for a I chord.
  3. A vi chord substitues for a I chord or a V chord.
  4. Change V-I cadences into ii-V-I cadences.
  5. Insert a minor 5 (v) and dominant 1 (I7) in front of a 4 (IV) chord
  6. A dominant chord usually resolves down a fifth or sometimes a half step.
  7. Very often, if a progression is moving with the circle of fifths, you can change one of the normal minor chords to major (making it a secondary dominant).
  8. Add a flat 9th to secondary dominants if resolving to a minor chord.
  9. minor 7 chords likes to resolve down a fifth or in diatonic steps.
  10. You can insert a diminished chord betweet 4 and 5 chords.
  11. You can substitue a sharp4 dim - minor4 6th - minor 3 - flat3 dim - ii7 - V7 -I for a V-I cadence.
  12. Which color note belong to each chord?
Major/Major 7th
9, #11, 13 (9 is the most common)

Minor 7th
9, 11, 13 (9 is the most common)

Dominant
b9, 9, #9, #11, b13, 13 (All are widely used. However, you are most likely to use b9, 9, b13, and 13.)

Here is a sample of his free video lessons: "Relating harmony to melody"






  
Free Lessons for Chruch Pianists:
Free lessons, tips and downloads for church pianists

DVD Courses (Reharmonization, Play by Ear!, Arranging, Accompanying, Theory for Church Pianists, etc.):
Over 30 hours of DVD instruction for church pianists


Visit Vitabase for Quality Health Supplements


Saturday, August 27, 2011

"I will be OK with that... as long as Sarah is there."

Wow! He must be very much in loved he would do everything to be with her.

I got this from Greg Howlett's latest post as of this date. Please read the story here.

It's a tragic story. 
It's sad that things like this happens even among Christians.

If you are also hurting because of the death of a loved one the article "Why Does God’s Creation Include Death and Suffering?" from Answers in Genesis might help you understand things.

Wednesday, August 24, 2011

Random Language Generation & Markov models of language


"Well, that sounds like a good way; but that Saint Louis smarty that thinks he dresses so fine and is
aristocracy! Oh, all right, I'll keep still--because, said she had been taking no
note of time and "sniffing around, the very next morning, he won't think of the
knob, and
open comes the door and fell grateful breath. Tom whistled twice more. Tom saw the state his clothes, sobbing,
snuffling, now, so handsomely engraved and colored
frontispiece--a human figure, stark naked. At that moment, not twenty yards away, and stood by musing a minute. SHE won't
ever have of her child, and ordered him away. So he went
away; but he was
afraid he might possibly be counterfeited to its
injury is an impossible that the raftsmen were all ashamed of their beds, was a
ruin, now, blasted by the body from him with disgust. For frivolity and
jokes and spotted tights were an offense, when the little girl
was wending her way toward the village, and no guards were afforded for it; ten
red tickets equalled a yellow one; for ten yellow
tickets the superintendent gave a very plainly bound Bible (worth forty
cents in those easy times) to the pupils. To his left, back of the performance.
At last he
rose up sighing and departed were they, and then just see 'em look!"

The text above is a sample of what my solution to the Random Language Generation Problem generated. (Assignment 2: ADT Client Applications)

Random Language Generation is Problem 2 of Assignment #2 of the 2011 Spring Quarter CS106B course from Stanford.

You can download the problem specification here. (Go to page 5 of the downloaded document)

Here is a screenshot of my solution:



You can download my code here.

You can download a runnable .exe file here.

You can download my code here.



  
Free Lessons for Chruch Pianists:
Free lessons, tips and downloads for church pianists

DVD Courses (Reharmonization, Play by Ear!, Arranging, Accompanying, Theory for Church Pianists, etc.):
Over 30 hours of DVD instruction for church pianists
 


Visit Vitabase for Quality Health Supplements


Word Ladders


Word Ladders is Problem 1 of Assignment #2: ADT of the 2011 Spring Quarter CS106B course from Stanford.

The description below is taken from the assignment handout (you can download it here).

A word ladder is a connection from one word to another formed by changing one letter at
a time with the constraint that at each step the sequence of letters still forms a valid word.
For example, here is a word ladder connecting "code" to "data".

code -> core -> care -> dare -> date -> data

That word ladder, however, is not the shortest possible one. Although the words may be
a little less familiar, the following ladder is one step shorter:

code -> cade -> cate -> date -> data


Here is a screenshot of my solution:


You can download my solution code here.

You can also download a runnable .exe file here.

You can download my solution here.




  
Free Lessons for Chruch Pianists:
Free lessons, tips and downloads for church pianists

DVD Courses (Reharmonization, Play by Ear!, Arranging, Accompanying, Theory for Church Pianists, etc.):
Over 30 hours of DVD instruction for church pianists
 


Visit Vitabase for Quality Health Supplements


Freedom of Expression Debate




  
Free Lessons for Chruch Pianists:
Free lessons, tips and downloads for church pianists

DVD Courses (Reharmonization, Play by Ear!, Arranging, Accompanying, Theory for Church Pianists, etc.):
Over 30 hours of DVD instruction for church pianists
 


During our class in Professional Ethics (in IT), we had a debate on the subject of "Should publishing nude pictures be considered part of ones freedom of expression or not?"


I would like to hear from you comments about my argument regarding this.


My argument is this:


First let's define 'Freedom of Expression' in simple terms.
I think there can be two simple definitions:

Definition #1 - A person can do anything he want's to do.
OR
Definition #2 - A person can do anything he want's to do but there are restrictions.

[Are my definitions correct? Do you have suggestions?]


I think definition #1 is an impossibility. If that is our definition of 'Freedom of Expression' there would be chaos.
My example on how this will create chaos is this: If person A wants to do something because he is free to do it, person B might prevent person A from doing it because person B also has freedom to do what he wants to do. If person A insists, person B might also insist on preventing him.


So if definition #1 is an impossibility, then we are left with only definition #2.


If definition #2 is true, my question is: "Who should set the restrictions"? Because whether we like it or not, someone is going to set the restrictions.

This question is important because answering this can help us determine who will win the debate. It can help us determine if publishing nude pictures should be part of freedom of expression or part of the restriction.


But first of all, why do we need restrictions?
We need restrictions to prevent chaos, right? Thus, promoting wellness to our society and to each individual in the society.

So my answer to the question "Who sets the restrictions" would be this: Someone who knows what things cause wellness or harm to the society and to each individual in the society.

If that Someone says that "publishing nude pictures" brings WELLNESS to the society then it shoud BE considered part of freedom of expression.

If that Someone says that "publishing nude pictures" brings HARM to the society then it shoud NOT BE considered part of freedom of expression but is part of the restrictions to freedom of expression.


[I think the winner of the debate should be the group that agrees with what that Someone will say. But who should that Someone be?]

Sunday, August 21, 2011

Game Of Life


Here is my solution to the "Game of Life" Problem, a programming assignment from Stanford's CS106B class last Spring Quarter (2011)

Click here to download the problem specification.



You can download my solution (source code) here.

If you want to play with it without compiling it, you can download a stand-alone .exe file here.

You can download my solutions here.

Have fun!




  
Free Lessons for Chruch Pianists:
Free lessons, tips and downloads for church pianists

DVD Courses (Reharmonization, Play by Ear!, Arranging, Accompanying, Theory for Church Pianists, etc.):
Over 30 hours of DVD instruction for church pianists
 


Visit Vitabase for Quality Health Supplements

Boggle


I have been watching the 2011 Spring Quarter CS106B's videos by Steve Cooper from Stanford and have also done the assignments given in the class.

I have finished coding Boggle (assignment # 4) last night. You can download the problem specifications here.

Here's a screenshot of my solution:




You can download my solution (code) here.

If you want a stand-alone .exe file you can download it here.

Pardon my code. I did not follow good style practices in coding this. I did not comment everything.

I hope I can be able to fix this next time.

Enjoy!



  
Free Lessons for Chruch Pianists:
Free lessons, tips and downloads for church pianists

DVD Courses (Reharmonization, Play by Ear!, Arranging, Accompanying, Theory for Church Pianists, etc.):
Over 30 hours of DVD instruction for church pianists
 


Visit Vitabase for Quality Health Supplements

Friday, August 19, 2011

Why I Started Blogging

Hi everyone.

I am going to start blogging today.

I'm doing this because I am planning to stop going to college next semester. I'm going to study in private.

Blogging will give me a way to share the output of the things I'm going to learn [I hope... if I have time... and if I know how to write what I want to say]. I hope this will also help improve my written as well as my spoken English.

I have always wanted to stop since I was third year in college (only that my parents did not permit me, but I think they will permit me now) because I have realized that going to my school everyday is a hindrance to what I really want to become -- a programmer -- and the schools I have attended were not teaching the things that I need to become a proficient programmer.

[I also want to become a computer scientist but maybe that will not happen any time soon. Maybe a hundred years form now!? (LOL). But I will continue to study computer science until forever. ]

I have learned from my schools the EASY part of programming (David Malan said that "Programming is easy"). But I have not learned the "programming well" part, which is harder than the "easy" part (LOL).

[David Malan said that "Programming is easy". His co-professor agreed on that but added that "Programming WELL is hard"]

I'm not saying that I have never learned anything from the schools I attended. In fact, there are things that I believe I could have not known had I not attended these schools (tama ba akong grammar?). So I have learned many important things from my schools.

But it is the "well" part of programming that I need to know now. And I have to find it somewhere else.

You might be asking why I'm thinking of sharing the things I'm going to learn.

Well, I'm just thinking that maybe this will help me keep my sanity (LOL) because my father said that he heard of someone in the past who was not contented with what his teachers were teaching in school so he stopped attending classes and studied things on his own. To make the story short, that child killed himself (I forgot the reason why). I was just thinking that maybe the reason was loneliness.

Maybe blogging will help me not to be alone.

But I have also read about people who did not have a formal (college) education but were successful or at least fulfilled.

I aspire to be like them. But I am also planning to pursue a degree in mathematics in the near future if I have time and enough money.

Have a great day ahead.


[I was trying to check from Google's search engine if my statement above ---"there are things that I believe I could have not known had I not attended these schools"--- is correct grammatically. I did not get my expected results but, incidentally, the first result of the search was NOT Everyone Should Attend College, BUT Let's not Give up on it Entirely.] Great!


UPDATE (July 30, 2016):
I said above that during the time I was writing this post (August 2011), my parents might permit me to stop going to college the next semester (that will be November 2011).
That did not happen. 
I was only able to stop college on April 2012 (that was summer vacation) when I was able to find a home-based job.