Thursday, 1 May 2014

Software

 

                                                            Software




Software is the programs that run on a computer, a program is a set of instructions for a computer to execute. Software can preform lots of different tasks. It is used around the world by lots of  programmers

Thursday, 13 March 2014

Databases



                                                                    Databases


                                     Key Words:

                                     Serial File: A file of items one after another
                                     Sequential File: A serial file in order
                                     Entity: Something that we store data about in a database
                                     Record: All the data about one item in a database
                                     Attribute: A characteristic of an entity. It becomes a field in a data table
                                     Field: A characteristic of something stored in a database
                                     Indexed sequential file: A sequential file that is accessed using an index, 
                                     which is a separate file.
                                     Flat File Database: Database consisting of only one table
                                     Primary Key: A primary key is a unique value so hat a record in the table
                                     can be identified without any mistake.


    A database is an organized collection of data. The data are normally organized to model relevant aspects of reality in a way that supports processes requiring this information. For example, modelling the availability of rooms in hotels in a way that supports finding a hotel with vacancies.

Monday, 9 December 2013

Little Man Computer (Full Program)




                                                        LMC Sample Program
                                              

Program

INP
STA VALUE
LDA ZERO
STA TRINUM
STA N
LOOP LDA TRINUM
SUB VALUE
BRP ENDLOOP
LDA N
ADD ONE
STA N
ADD TRINUM
STA TRINUM
BRA LOOP
ENDLOOP LDA VALUE
SUB TRINUM
BRZ EQUAL
LDA ZERO
OUT
BRA DONE
EQUAL LDA N
OUT
DONE HLT
VALUE DAT 000
TRINUM DAT 000
N DAT 000
ZERO DAT 000
ONE DAT 001

What you should do

  1. Click on the "LMC Simulator Applet" link to start the LMC simulator.
  2. Clear the Message Box and all of the LMC mailboxes -- click the "Clear Messages" button and the "Clear" button if necessary.
  3. Copy the twenty eight line program above and paste it into the Message Box
  4. Click on the "Compile Program" button.
  5. Click on the "Run" button.
  6. When prompted, enter three-digit numbers in the "In-Box", and press the "Enter" button.

What you should see

  • After the program is compiled, you should see from mailbox 0 to 23 the instructions 901, 323, 526, 324, 325, 524, 223, 814, 525, 127, 325, 124, 324, 605, 523, 224, 720, 526, 902, 622, 525, 902.  The Program Counter should start at 0 (click on "Reset" if necessary).
  • DAT reserves mailbox 23 for N (the user input), mailbox 24 for TRINUM (the value of the current triangular number), mailbox 25 for COUNT (the number of triangular numbers that have been calculated), mailbox 26 for ZERO, and mailbox 27 for ONE. 
  • When you click on "Run" or "Step", the Message Box will describe the actions of each instruction.
  • The first two instructions accept the input VALUE from the user.
  • The next three instructions initialize the values of TRINUM and N to ZERO.
  • The algorithm is as follows: calculate triangular numbers until the calculated triangular number is greater than or equal to the input value.  If the triangular number is equal to the input, then output N.  Otherwise, output ZERO.
  • The LOOP starts by checking this exit condition.  The input VALUE is subtracted from TRINUM.  As long as the result is negative, the LMC stays in the loop (i.e. the BRP does nothing) to calculate more triangular numbers.
    • To calculate the next triangular number, N is incremented by ONE, and this new value of N is added to TRINUM.  Remember, the nth triangular number is calculated by adding n to the previous triangular number.
    • The BRA LOOP indicates the end of the loop body.  This BRANCH command causes the execution of the LMC to "jump" back to the start of the loop.
  • After exiting the LOOP, the value of TRINUM is greater than or equal to the input VALUE -- the LMC has calculated enough triangular numbers to determine if the user input is one.
  • The SUB instruction is to check if TRINUM and VALUE are equal.
    • If they are equal, subtracting TRINUM from VALUE will equal 000.  BRZ will allow the LMC to skip past the code section that handles when these two values are not equal.  The LMC will then execute the code segment that outputs N to the Out-Box -- the input VALUE is the Nth triangular number.
    • If they are not equal, the result on the Accumulator will not be 000, and BRZ will do nothing.  The code after of the BRZ instruction is executed.  This code outputs ZERO to the Out-Box, and then skips past the code for the two values being EQUAL to the end of the program.

Little Man Computer (Looping)



                                                        
                                  LMC Branch Instructions (for implementing loops)

Program

LDA ONE
STA COUNT
OUT
LOOPTOP LDA COUNT
ADD ONE
OUT
STA COUNT
SUB TEN
BRP ENDLOOP
BRA LOOPTOP
ENDLOOP HLT
ONE DAT 001
TEN DAT 010
COUNT DAT

What you should do

  1. Click on the "LMC Simulator Applet" link to start the LMC simulator.
  2. Clear the Message Box and all of the LMC mailboxes -- click the "Clear Messages" button and the "Clear" button if necessary.
  3. Copy the fourteen line program above and paste it into the Message Box
  4. Click on the "Compile Program" button.
  5. Click on the "Run" button.
  6. When prompted, enter three-digit numbers in the "In-Box", and press the "Enter" button.

What you should see

  • After the program is compiled, you should see from mailbox 0 to 9 the instructions 511, 313, 902, 513, 111, 902, 313, 212, 810, 603.  The Program Counter should start at 0 (click on "Reset" if necessary).
  • DAT reserves mailbox 11 for ONE, mailbox 12 for TEN, and mailbox 13 for COUNT.  A three-digit number after DAT represents the initial value that the compiler should store in the mailbox (e.g. 001 for ONE and 010 for TEN). 
  • The LOOPTOP identifier is the first instruction in the loop.  When the code in the loop has been executed, a BRANCH always instruction (e.g. BRA LOOPTOP) causes the LMC to "jump" back to the start of the loop so that the code section can be executed again. 
  • When you click on "Run" or "Step", the Message Box will describe the actions of each instruction.
  • The first three instructions initialize the COUNT mailbox to 1 and output this value to the Out-Box.
  • In the body of the loop, COUNT is loaded onto the Accumulator, one is added to it, the new value is output, and then the new value of COUNT is stored back to its mailbox.  The value of COUNT must be repeatedly loaded and stored because the value of COUNT is erased from the Accumulator when the loop termination condition is checked.
  • The SUB instruction is used as part of checking the loop termination condition.  The loop is to execute ten times.  The SUB TEN instruction subtracts ten from the value of the Accumulator.
    • If the value of the Accumulator is smaller, subtracting TEN from it will cause the Accumulator to become negative.  The BRP instruction will then do nothing, and the program will continue to mailbox 9.  Mailbox 9 represent the completion of the loop, so its instruction (BRA LOOPTOP) causes the LMC to return to the top of the loop so that it can be executed again.
    • When the value of the Accumulator/COUNT becomes ten, subtracting TEN from it will cause the Accumulator to become zero.  The BRP instruction will now update the Program Counter to ENDLOOP (mailbox 10).

Little Man Computer (Making descions)

                                                   

                             Little Man Computer Branch Instructions (for making decisions)

 

Program

INP
STA FIRST
INP
STA SECOND
SUB FIRST
BRP SECONDBIG
LDA FIRST
OUT
BRA PROGRAMEND
SECONDBIG LDA SECOND
OUT
PROGRAMEND HLT
FIRST DAT
SECOND DAT

 

 

What you should do

  1. Click on the "LMC Simulator Applet" link to start the LMC simulator.
  2. Clear the Message Box and all of the LMC mailboxes -- click the "Clear Messages" button and the "Clear" button if necessary.
  3. Copy the fourteen line program above and paste it into the Message Box
  4. Click on the "Compile Program" button.
  5. Click on the "Run" button.
  6. When prompted, enter three-digit numbers in the "In-Box", and press the "Enter" button.

What you should see

  • After the program is compiled, you should see from mailbox 0 to 10 the instructions 901, 312, 901, 313, 212, 809, 512, 902, 611, 513, 902.  The Program Counter should start at 0 (click on "Reset" if necessary).
  • DAT reserves mailbox 12 for FIRST and mailbox 13 for SECOND.
  • SECONDBIG and PROGRAMEND are identifiers like FIRST and SECOND that the assembly language program can use to label certain mailboxes.  When an identifier appears before an LMC instruction (e.g. FIRST DAT or PROGRAMEND HLT), the identifier is declared to the compiler, and the compiler records which mailbox the instruction is stored in (e.g. mailbox 12 for DAT and mailbox 11 for HLT).  When an identifier appears after an LMC instruction (e.g. STA FIRST or BRP SECONDBIG), the compiler converts that identifier into a mailbox to complete the machine code instruction (e.g. STA is machine code 3 and FIRST refers to mailbox 12, so STA FIRST becomes machine code 312).
  • When you click on "Run" or "Step", the Message Box will describe the actions of each instruction.
  • The first four instructions store your two input values.
  • The SUB instruction is used to determine which of the two values is larger. 
    • If the FIRST value is larger, subtracting it from the SECOND value will cause the Accumulator to become negative.  The BRP instruction will then do nothing, and the program will continue to mailbox 6.  After the LOAD and OUTPUT instructions to output the FIRST value to the Out-Box, the program will use the BRA instruction to skip the set of instruction that output the SECOND value and go straight to the next/last instruction of the program -- HLT.
    • If the FIRST value is smaller (or equal), subtracting it from the SECOND value will leave the Accumulator with a positive (or zero) value.  The BRP instruction will then update the Program Counter -- 8 means BRANCH on zero or positive and 09 refers to the new value of the Program Counter (i.e. the mailbox which holds the first instruction of the sequence that will output the SECOND value).  This BRANCH instructions causes the LMC to skip the part of the program that outputs the FIRST value.  After outputing the SECOND value, the program continues on with the next/last instruction of the program -- HLT.

LIttle Man Computing (Using&Memory)

 

                                       Little Man Computer (Load Save)


Program

INP
STA FIRST
INP
STA SECOND
LDA FIRST
OUT
LDA SECOND
OUT
HLT
FIRST DAT
SECOND DAT

What you should do

  1. Click on the "LMC Simulator Applet" link to start the LMC simulator.
  2. Clear the Message Box and all of the LMC mailboxes -- click the "Clear Messages" button and the "Clear" button if necessary.
  3. Copy the eleven line program above and paste it into the Message Box
  4. Click on the "Compile Program" button.
  5. Click on the "Run" button.
  6. When prompted, enter three-digit numbers in the "In-Box", and press the "Enter" button.

What you should see

  • After the program is compiled, you should see from mailbox 0 to 7 the instructions 901, 309, 901, 310, 509, 902, 510, 902.  The Program Counter should start at 0 (click on "Reset" if necessary).
  • DAT is the tenth and eleventh instruction of your program, so they refer to mailboxes 9 and 10 (0-indexed counting).  FIRST and SECOND are the identifiers that have been declared to represent these mailboxes in the assembly language program.
  • When you click on "Run" or "Step", the Message Box will describe the actions of each instruction.
  • After the first INP instruction, the Accumulator has a copy of the first value entered in the In Box.
  • After the STA instruction, the input value is copied from the Accumulator to mailbox 9 -- 3 means STORE and 09 refers to the mailbox to store into.
  • After the second INP instruction, the Accumulator has a copy of the second value entered into the In Box (use a different value than the first).
  • After the second STA instruction, the second input value is copied from the Accumulator to mailbox 10.
  • After the LDA instruction, the Accumulator is reset to the first input value.  This value has been retrieved from mailbox 9 -- 5 means LOAD and 09 refers to the mailbox to load from.  Note: since your Accumulator can only work on one value at a time, you have to repeatedly STORE and LOAD values from memory to keep them from getting erased by the next operation.
  • After the OUT instruction, the Out Box has a copy of the value in the Accumulator -- the first input value.