Professional Documents
Culture Documents
CAOS - Portfolio 2010 - 2011
CAOS - Portfolio 2010 - 2011
Module Number: CE0714A Module Name: Computer Architecture and Operating Systems
Declaration
I have read and understood the University of Abertay Dundee policy on academic deceit and certify
I also give permission to the University to check the authenticity of my work using electronic
David Gordon
1004103
2
First Year Portfolio University of Abertay
University of Abertay
Acknowledgements
All trademarks and names are owned and copyrighted by their respective owners.
3 University of Abertay
Abstract.................................................................................................................................................3
Acknowledgements...............................................................................................................................3
Table of Contents..................................................................................................................................4
Table of Figures.....................................................................................................................................6
Tables....................................................................................................................................................6
Hardware Familiarisation......................................................................................................................7
The Motherboard..............................................................................................................................7
The Central Processing Unit.............................................................................................................11
Random Access Memory.................................................................................................................13
Hard Disk Drive(s)............................................................................................................................14
Power Supply Unit...........................................................................................................................16
CD and DVD drive(s)........................................................................................................................16
Network card...................................................................................................................................17
4 University of Abertay
System Profiling...................................................................................................................................19
Memory Profiling.............................................................................................................................19
BIOS Profiling...................................................................................................................................19
Operating System Profiling..............................................................................................................20
Currently, possible results include:..................................................................................................20
Disk Drive Profiling..........................................................................................................................21
Data Representation............................................................................................................................23
Binary..............................................................................................................................................23
Hexadecimal....................................................................................................................................24
Question 1:......................................................................................................................................25
Question 2:......................................................................................................................................25
Question 3:......................................................................................................................................25
Question 4:......................................................................................................................................25
Question 5:......................................................................................................................................26
Question 6.......................................................................................................................................26
Question 7.......................................................................................................................................26
Question 8.......................................................................................................................................28
Tables
TABLE 1: EXAMPLE BINARY SCALE (INCOMPLETE)............................................................................................................23
TABLE 2: THE HEXADECIMAL SCALE.............................................................................................................................24
TABLE 3: EXAMPLE BINARY USAGE CONVERSION SCALE..................................................................................................24
TABLE 4: TWOS-COMPLIMENT VALUE RANGE FOR 16BIT BINARY.....................................................................................25
TABLE 5: BINARY TO DECIMAL CONVERSION TABLE (32 BIT – FIRST 16 BITS)......................................................................26
TABLE 6: BINARY TO DECIMAL CONVERSION TABLE (32 BIT – LAST 16 BITS)......................................................................26
TABLE 7: WORKING OUT FOR QUESTION 5-C................................................................................................................26
TABLE 8: HEXADECIMAL TO BINARY AND DECIMAL CONVERSION......................................................................................28
TABLE 9: BOOLEAN ALGEBRA DESCRIPTION...................................................................................................................28
TABLE 10: XOR TRUTH TABLE...................................................................................................................................29
TABLE 11: NAND TRUTH TABLE................................................................................................................................29
TABLE 12: CIRCUIT TRUTH TABLE...............................................................................................................................29
TABLE 13: : CIRCUIT TRUTH TABLE..............................................................................................................................30
TABLE 14: AND A NOT B GATE TRUTH TABLE............................................................................................................30
TABLE 15: : A OR (B AND C)...................................................................................................................................31
TABLE 16:: (A AND B) NOR (A AND C) TRUTH TABLE.................................................................................................32
7 University of Abertay
TABLE 17: HALF ADDER TRUTH TABLE.........................................................................................................................40
Within this laboratory I was required to open a suitable computer system case, identify and
catalogue the main components and conduct some profiling of the components. This was a very
straightforward laboratory as I worked for many years, building and repairing computer systems in a
commercial environment.
Motherboard
CPU
RAM
hard disk
PSU
CD/DVD drive
Network card
8 University of Abertay
The Motherboard
The motherboard has become an increasingly complex central component of any computer system.
In the 1980s motherboards were less complicated with most of the now on-board functions being
controlled by add-on Industry Standard Architecture (ISA) cards. Motherboards come in numerous
form factors (designs), from highly compact and integrated boards for netbooks, to massively
expandable boards more suitable for servers. Boards are also designed for particular central
processing systems (CPU) with the main
two consumer manufacturers being Intel
and AMD.
Modern boards have a number of expansion slots; which are predominantly PCI based, correctly
known as (Peripheral Component Interconnect). PCI-E and AGP slots are also commonly available on
consumer motherboards. PCI-E are an enhanced form of the PCI standard, the “E” stands for
Express; and reflects that this PCI slot is generally faster than standard PCI slots which is why the PCI-
E was commonly used for a time to allow faster graphics cards to be added to the system. Now AGP
(Accelerated Graphics Port) slots are used to allow very fast graphics cards to be connected.
CPU
Memory
Expansion Slots
Power Management
Storage
Audio
Ethernet LAN
USB
LVDS
Rear Panel I / O
Internal I / O
BIOS
Form Factor
Temperature
There is clearly a wealth of information that can be gained about a motherboard simply by knowing
its serial number or model number. However, being able to access the manufacturer’s web site gives
us access to manuals, drivers, BIOS updates, and of course direct access to their technical support
The CPU comprises tens of millions of transistors; effectively, little switches which can be either in an
on or off state. This polar state is precisely the reason that the internal processing of end user
actions are in binary; as binary mathematics lends itself ideally to the polemic states of the
transistors. Occasionally, the CPU is inaccurately referred to as the base unit, the case, within which
most computer components reside.
CPU serial numbers are normally either etched onto the core
itself or displayed on an attached sticky label. It should be
noted that knowledge of the serial number is not as important
with CPUs as it is for motherboards. Simply the
manufacturer’s name and the model of the CPU displayed on
12 University of Abertay
the top of the core is all that is required to gain all the
information about the core that one could desire.
Again, going to the vendor’s web site will provide more Figure 3: Quad Core Intel CPU
information on the CPU than any digital forensic professional
will ever need. Modern CPUs run hot, that is they generate a great deal of heat and do not function
properly, or for long, if they are not cooled. As a result CPUs are now found under either a large
cooling fan, or under a water cooling heat-sink. These cooling systems need to be removed before
one can access the CPU.
Intel® Core™2 Quad Processor Q9650 (12M Cache, 3.00 GHz, 1333 MHz FSB)
Essentials
Status Launched
Launch Date Q3'08
Processor Number Q9650
# of Cores 4
# of Threads 4
Clock Speed 3 GHz
L2 Cache 12 MB
Bus/Core Ratio 9
FSB Speed 1333 MHz
Advanced Technologies
Intel® Turbo Boost Technology No
Intel® Hyper-Threading Technology No
Intel® Virtualization Technology (VT-x) Yes
Intel® Virtualization Technology for Directed I/O (VT-d) Yes
Intel® Trusted Execution Technology Yes
AES New Instructions No
Intel® 64 Yes
Idle States Yes
13 Enhanced Intel SpeedStep® Technology Yes University of Abertay
Intel® Demand Based Switching No
Thermal Monitoring Technologies Yes
Execute Disable Bit Yes
Features:
Stable and Durable, Highly Compatible
100% tested
Lifetime Warranty
Specification:
Memory Type: DDR3 Memory
Pin and Module Type: 240Pin Long-DIMM
Frequency: DDR3-1333
Function: ECC Unbuffer Memory
Capacity: 4GB
DRAM: 256Mx8
Voltage: 1.5 V
CL: 9
For modern computers to be useful, they need to have a non-volatile memory; which allows
information to be saved prior to the shutdown of the computer to a medium which it can be
recovered from after the computer has been restarted. The most typical form of such non-volatile
memory is called a Hard Drive, or Hard Disk.
15 University
Hard disks can be external as well as internal, that is they can be readily attached of Abertay
and detached from
the main system; usually through a USB 2 connection. From the point of a digital forensic
professional it is important to keep this in mind, as a great deal of evidence could be missed if a
proper search for external storage devices is not made.
Traditionally Hard Disk labels contain an abundance of information which allows digital forensic
professionals and system technicians to repair and manipulate the drive at a low level; it also
permits [professionals to calculate disk space – to see if there are hidden volumes on the drive that
the operating system and perhaps discovery software cannot detect.
Performance Specifications
Transfer Rates
Buffer To Host (Serial ATA) 3 Gb/s (Max)
Physical Specifications
Formatted Capacity 2,000,398 MB
Capacity 2 TB
Interface SATA 3 Gb/s
User Sectors Per Drive 3,907,029,168
David Gordon (1004103)
CE0714A
Physical Dimensions
English
Height 1.028 Inches
Length 5.787 Inches
Width 4.00 Inches
Weight 1.61 Pounds
Metric
Height 26.1 mm
Length 147 mm
Width 101.6 mm
Weight 0.73 kg
Environmental Specifications
Shock
Operating Shock (Read) 65G, 2 ms
Non-operating Shock 300G, 2 ms
16 University of Abertay
Acoustics
Idle Mode 25 dBA (average)
Seek Mode 0 29 dBA (average)
Seek Mode 3 26 dBA (average)
Vibration
Operating
Linear 20-300 Hz, .75G (0 to peak)
Random 10-300 Hz, 0.008 g² / Hz
Non-operating
Low Frequency 5-20 Hz, 0.195 inches (double amplitude)
High Frequency 20-500 Hz, 4.0G (0 to peak)
Electrical Specifications
Current Requirements
Power Dissipation
Read/Write 6.00 Watts
Idle 3.70 Watts
Standby 0.80 Watts
Sleep 0.80 Watts
On the side, or top, of the typical PSU the warning label is displayed announcing the dangers of
working with high voltage apparatus. This is where the manufacturers also traditionally place
information about who made the unit, and its serial and model numbers. Using the model number
and the manufacturer’s name it is possible to get the full data sheet of the PSU from the
manufacturer’s website.
18 University of Abertay
CD and DVD drive(s)
CD drives are not as common
as they once were; however,
DVD drives are very common
particularly the writeable and
re-writeable, and slowly the
popularity of Blue-ray drives
are taking off. The latter are
called Blue-ray after the
colour of laser that is
employed. The colour blue
has a shorter wavelength to
red which is used in more
traditional CD and DVD drives.
Thus a blue laser can pack
more data into the same area Figure 6: Compaq DVD-ROM
as a tradition drive. As these devices operate lasers, they are particular dangerous to take apart and
Network card
It is common for modern computers to have a built in network card, although NICs can also be
purchased separately and inserted into one of the available PCI slots on the motherboard. NICs as
the name suggests allows the computer to connect to networks; and with modern broadband
19 University of Abertay
Internet services it also permits the computer to be connected to a router and through that – the
Internet.
There is not customary location on network cards for discovering the serial number. It may be a label
on the back, front or external facia of the card, it may be inscribed into the board, or there may be
no serial number or part number visually present.
Power Consumption
1
[CITATION 10110 \l 2057 ]
Regulatory Compliance
Environmental Specifications
Package Contents
Package Dimensions/Weight
Product Dimensions/Weight
The target machine is a Microsoft Windows 7 based computer running as a virtual machine on
Oracle’s VirtualBox. The process and software used would remain the same on any machine running
a version of Windows from Windows XP, onwards.
Memory Profiling
System Information revealed that the machine had:
Task Manager and Resource Monitor could provide further information about memory availability
and usage. For instance, Task manager stated that Firefox was using the most memory at
approximately 258,000K, closely followed by Microsoft Word. The DOS command MEM.EXE may also
be available depending upon which version of Microsoft Windows is being tested.
BIOS Profiling
System Information revealed that the (virtual)
machine’s BIOS reported its date as 01/12/2006.
Although a great deal of information can be gathered
concerning the BIOS during the POST (Power On Self-
Test), when the computer is started – it is easier to
interrupt the POST and physically enter the BIOS
configuration screens. This can be done with a hot key
combination during the POST (see Appendix A).
Figure 8: Typical BIOS Screen
System Information translated the version information into a more human understandable name:
Windows 95 4.0.950
Windows 98 4.1.1998
Windows Me 4.90.3000
2
Beta releases have alternative version numbers and are not included in the list above.
There are many tools and third party utilities available for profiling computer components including
hard drives. The Microsoft Windows Operating system makes extensive use of the System
Information tool, and current versions of Windows also have an extensive disk management service
and resource monitor; both of which can be used to gain information about the hard drives and
partitions on a system.
System Information tells us that the hard disk I profiled is 247.15 GB (265,375,707,136 bytes), with
199.92 GB (214,666,682,368 bytes) free space. The full System Information summary was displayed
as follows and Appendix B, has a complete listing of the System Information profile for the computer
examined.
24 University of Abertay
Binary allows CPUs to process a user’s input; but it requires a conversion from one form to another.
The characters we type into a keyboard only appear to us as intelligible text; to the computer the
characters are actually represented as binary. The Unicode standard lists all the numbers associated
with almost every character that can be typed in any language, as well as special notations for music,
and mathematics. Unicode 6 literally has tens of thousands of numerical character representations
for hundreds of different scripts.
The Latin letter “J” for example is common enough to English readers; however, to computers it is
0x004A[ CITATION Con10 \l 2057 ]. This is known as a hexadecimal value or the base 16 numerical
system. Humans often use hexadecimal as an alternative to binary because binary representations of
25 University
numbers can be very space consuming, as well as very difficult to understand. This of Abertay
laboratory work is
designed to illustrate the conversion process between Binary, Hexadecimal and Decimal (Base 10)
values; decimal being the most common base numerical system employed by technologically
enabled people.
Binary
Binary numbers consist of either a 0 (zero) or 1 (one), which represent a value which corresponds to
its position on an imaginary scale. The scale which is represented below starts with the values 1, 2, 4,
8, 16 … and is continued by multiplying the previous number by 2. The scale has no logical limit, but
for space reasons are never completed and when related to computers is often converted to
Hexadecimal.
The value of 512 (Decimal) would be for example, displayed in binary notation as 1000000000. This
form is rather difficult to read and just as in decimal the “,” is used to separate each 3 rd number a
space is used to separate each 4th number. Thus, 512 would customarily be represented by: 0010
0000 0000. Note the prefixed two zeros which are used for padding.
Hexadecimal
Hexadecimal is often used to represent binary values within computer science (ibid.). It has already
been shown that binary can be a cumbersome notation to use, but it is needed when we consider
that computer CPUs work purely with binary. To make binary values more human readable, and
writeable, it is often converted to and from hexadecimal. Hexadecimal, or hex as it is commonly
referred to, is denoted either by preceding the hex value with “0x” or by adding the “h” suffix. The
scale range of hex is from 0 (zero) to 9 (nine) and from ”A” through “F”.
Hex 0 1 2 3 4 5 6 7 8 9 A B C D E F
Dec 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
DIGI 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
T
Table 2: The Hexadecimal scale
The alphabetic characters A – F can be displayed as either upper or lower case letters, although it is
traditional not to mix cases.
26 University of Abertay
16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 Bits
32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1 DEC
Question 1:
a) 0001 0011 = 19
b) 0110 0000 = 96
c) 1111 1010 = 250
Question 2:
a) 0111 = 7
b) 101101000011 = 2,883
Question 3:
a) 1111 1111 1111 1111
b) 0xFFFF
0xF is equal to 1111 (Binary) ∴
1111 1111 1111 1111
F F F F ∴
27 1111 1111 1111 1111 ≡ 0xFFFF University of Abertay
c) 65,535 - 65,536 in real terms because we count the zero value, so 65,535 + 1 = 65,536
Question 4:
The first digit of the binary value represents the singed bit – that is in twos-compliment it tells us
whether it is a positive or negative number – this Signed bit is not used as part of the total value of
the binary value; in twos-compliment the value 1111 does not represent the decimal value of 10 but
is actually representative of +111 (Binary) or the decimal value 7. However, in negative numbers the
full set of binary values is used, this means 0000b is equal to -8 decimal.
32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 B
it
s
2147483648 1073741824 536870912 268435456 134217728 67108864 33554432 16777216 8388608 4194304 2097152 1048576 524288 262144 131072 65536
2147 1073 5368 2684 1342 671 335 167 838 419 209 104 52 26 13 65
4836 7418 7091 3545 1772 088 544 772 860 430 715 857 42 21 10 53
48 24 2 6 8 64 32 16 8 4 2 6 88 44 72 6
1 1 0 0 1 0 1 0 1 1 1 1 1 1 1 0
Table 6: Binary to Decimal Conversion Table (32 Bit – last 16 bits) 3
Question 5:
a) 2795
b) 230
Question 6
a) 00101 + 5 +
10110 = 21 =
0 Carry 1
10 Carry 1
010 Carry 1
1010 Carry Nothing
-------
11010 Final Answer (Decimal 26)
=====
b) 100111 + 39 +
100101 37 =
0 Carry 1
00 Carry 1
100 Carry 1
1100 Carry Nothing
01100
001100 Carry 1
01001100 = Final Answer (Decimal 76)
3
As you can see from the table, row two’s text has to be reduced to such a small size it is impossible to see the
text. Large numbers like those presented here take far too much space to be practical.
a) 100 + 27
100 = 1110 0100
27 = 1001 1011
--- ---------
127 1
11
111
1111
1 1111
11 1111
111 1111
---------
1111 1111 Final Answer
=========
b) 84 + 52
84 = 1101 0100
52 = 1011 0100
--- ---------
136 0
00
000 Carry 1
1000
29 0 1000 Carry 1 University of Abertay
00 1000 Carry 1
000 1000 Carry 1
---------
1000 1000 Final Answer
=========
c) 115 – 64
115 = 1111 0011
64 = 0100 0000
--- ---------
51 1
11
011
0011
1 0011
11 0011
011 0011 Carry 1
---------
1011 0011 Final Answer
=========
-129 is beyond the scale that 8bit twos-compliment allows, the lowest permissible value is -128. We
would need to use 16bit twos-compliment for this calculation if the machine being used could
process a 16bit value. Most current machines are capable of processing 32bit values with many
being able to process 64bit values.
Question 8
Binary Arithmetic
Having an understanding of binary allows us to visualise the mechanics behind how a computer
processes binary instructions to produce expected results. Processing binary to achieve a resultant
requires the manipulation of the binary input to get a correct output – this processing is done
through the two-state mathematics called Boolean algebra.
The two states are True or 1, and False, or 0; these states can be acted upon by a number of
operators.
The NOT operator can be combined with the AND operator, NAND, and the OR Operator, NOR.
There is also the exclusive directive which can be added to produce the XOR, XNOR directives. It is
customary to write logical operators and results in uppercase, such as TRUE, FALSE, AND, OR; this
assists in distinguishing logical expressions from Standard English wordage.
A B NOT A NOT Q To generate the truth table we start at the Inputs, NOT them, and
B put the new values into the OR gate to calculate the results.
0 0 1 1 1
0 1 1 0 1
1 0 0 1 1 Table 12: Circuit Truth Table
1 1 0 0 0
A B XOR A AND B S C
0 0 0 0 0 0
0 1 1 0 1 0
1 0 1 0 1 0
1 1 0 1 0 1
Table 13: : Circuit Truth Table
32 University of Abertay
A B AND A NOT B Q
0 0 0 1 0
0 1 0 0 0
1 0 0 1 0
1 1 1 0 0
Table 14: AND A NOT B Gate Truth Table
A B C A OR B OR B AND C AND Q R
0 0 0 0 0 0 0 0 0
0 0 1 1 1 0 0 1 0
0 1 0 1 1 0 0 1 0
1 0 0 1 1 0 0 1 0
0 1 1 1 1 1 1 1 1
1 1 0 1 1 0 0 1 0
1 1 1 1 1 1 1 1 1
Table 15: : A OR (B AND C)
A B C OR A OR B AND A AND C Q R
0 0 0 0 0 0 0 0 0
0 0 1 1 0 0 1 0 0
0 1 0 1 1 0 0 1 0
1 0 0 1 0 1 0 1 0
1 0 1 1 0 1 1 1 1
1 1 0 1 1 1 0 1 0
1 1 1 1 1 1 1 1 1
A B C X
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 0
34 University of Abertay
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace COAS
{
class Program
{
Console.ReadKey();
}
#region QUESTION1
/// <summary>
/// Output of Question 1
/// </summary>
private static void Question1()
{
Console.WriteLine("Decimal :{0} ", 255);
Console.WriteLine("Decimal :{0} ", 85);
Console.WriteLine("Binary :{0} ", ConvertToBase(255, 2));
Console.WriteLine("Binary :{0} ", ConvertToBase(85, 2));
Console.WriteLine("Hexidecimal:{0} ", ConvertToBase(255, 16));
Console.WriteLine("Hexidecimal:{0} ", ConvertToBase(85, 16));
}
#endregion
#region QUESTION2
#endregion
#region QUESTION3
/// <summary>
/// Output of question 3
/// </summary>
private static void Question3()
{
Console.WriteLine("0xFF AND 0x55: " + calculation3a());
}
#endregion
#region QUESTION3b
private static void Question3b()
{
// Write out the values
36 Console.WriteLine("NOT 0x18 Decimal : " + University of Abertay
HextoInt(ConvertToBase(~calculation3b(), 16)));
Console.WriteLine("NOT 0x18 Binary : " +
ConvertToBase(~calculation3b(), 2));
Console.WriteLine("NOT 0x18 Hexidecimal : " +
ConvertToBase(~calculation3b(), 16));
}
#endregion
#region QUESTION3c
// Part A
if ((byte)(a & a2) != 0)
{
Console.WriteLine("A) 01010101 AND 10101010 = True");
}
else
{
Console.WriteLine("A) 01010101 AND 10101010 = False");
}
// Part B
if ((byte)(b | b2) != 0)
{
Console.WriteLine("B) 01010101 OR 10101010 = True");
}
else
{
37 Console.WriteLine("B) 01010101 OR 10101010 University
= False");
of Abertay
}
// Part C
if ((byte)(c ^ c2) != 0)
{
Console.WriteLine("C) 01010101 XOR 10101010 = True");
}
else
{
Console.WriteLine("C) 01010101 XOR 10101010 = False");
}
}
#endregion
#region QUESTION5
private static void Question5()
{
// Convert everything to Byte Binary
byte b0, b4, b6, b81;
b0 = 0;
b4 = 4;
b6 = 6;
b81 = 81;
#region OR OPERATIONS
if ((byte)(b0 | b81) != 0)
{
Console.WriteLine("b0 | 81 = True");
}
else
38 { University of Abertay
Console.WriteLine("b0 | 81 = False");
}
if ((byte)(b4 | b81) != 0)
{
Console.WriteLine("b4 | 81 = True");
}
else
{
Console.WriteLine("b4 | 81 = False");
}
if ((byte)(b6 | b81) != 0)
{
Console.WriteLine("b6 | 81 = True");
}
else
{
Console.WriteLine("b6 | 81 = False");
}
#endregion
if ((byte)(b4 ^ b81) != 0)
{
Console.WriteLine("b4 ^ 81 = True");
}
else
{
Console.WriteLine("b4 ^ 81 = False");
}
if ((byte)(b6 ^ b81) != 0)
{
Console.WriteLine("b6 ^ 81 = True");
}
else
{
Console.WriteLine("b6 ^ 81 = False");
}
#endregion
}
#endregion
#region QUESTION6
sbyte aa = 127;
Console.WriteLine("sbyte A = " + aa);
aa++;
Console.WriteLine("sbyte A + 1 = " + aa);
// sbyte -128 to 127 Signed 8-bit integer
System.SByte
// Adding 1 to 127 sets the signed bit to - (Negative) -
therefore -128 is the result
}
#endregion
#region QUESTION7
//Multiply a byte by 4 without using * or +. What happens if the
value of the byte is greater than 63?
#region Utilities
/// <summary>
/// Convert an Int to A Base X
/// </summary>
/// <param name="val">
/// Int value to Convert
/// </param>
/// <param name="Base">
/// Int Base to which to convert to (Presuming base 10 as input)
/// </param>
/// <returns>
/// String representation of the conversion of the Int
/// </returns>
static private string ConvertToBase(int val, int Base)
{
string Value = Convert.ToString(val, Base);
return Value.ToString().ToUpper();
}
40 University of Abertay
/// <summary>
/// Do Question 3a's calculations
/// </summary>
/// <returns>
/// Returns a string result
/// </returns>
static string calculation3a()
{
// Convert Hex to Int
Int32 decValueFF = Int32.Parse("FF",
System.Globalization.NumberStyles.HexNumber);
Int32 decValue55 = Int32.Parse("55",
System.Globalization.NumberStyles.HexNumber);
/// <summary>
/// Do Question 3b's calculations
/// </summary>
/// <returns></returns>
static int calculation3b()
{
return binVal18;
}
/// <summary>
/// Convert a Hex String to Int
/// </summary>
/// <param name="hex">
/// String
/// </param>
/// <returns>
/// Int
/// </returns>
static private int HextoInt(string hex)
{
return Convert.ToInt32(hex, 16);
}
#endregion
}
41 } University of Abertay
Output:
Decimal : 255
Decimal : 85
Binary : 11111111
Binary : 1010101
Hexadecimal : FF
Hexadecimal : 55
Decimal : 85
Binary : 1010101
Hexadecimal : 55
0xFF AND 0x55 : 1010101
NOT 0x18 Decimal : -25
NOT 0x18 Binary : 11111111111111111111111111100111
NOT 0x18 Hexidecimal : FFFFFFE7
Decimal (0x85 OR 01010101b) AND 15 : 005
Binary (0x85 OR 01010101b) AND 15 : 101
Hexidecimal (0x85 OR 01010101b) AND 15 : 05
A) 01010101 AND 10101010 = False
B) 01010101 OR 10101010 = True
C) 01010101 XOR 10101010 = True
b0 & 81 = False
b4 & 81 = False
b6 & 81 = False
b0 | 81 = True
b4 | 81 = True
b6 | 81 = True
A B S c Binary
0 0 0 0 0000b
0 1 1 0 0001b
1 0 1 0 0001b
1 1 1 1 0010b
Table 17: Half Adder Truth Table
a b c q s Binary
0 0 0 0 0 0000b
0 0 1 1 0 0001b
0 1 0 1 0 0001b
0 1 1 0 1 0010b
1 0 0 0 1 0010b
1 0 1 1 1 0011b
1 1 1 0 1 0010b
Figure 18: Full Adder Truth Table
As the full adder has only two outputs it can only produce a maximum binary value of 0011b, or 3
decimal. Being based on binary it is relatively easy to see that combining two full adders one would
have a 2 bit adder, combining two 2 bit adders we would have a 4 bit adder ad infinitum.
44 University of Abertay
One can clearly see that the –ve Edge Triggered D-Type flip-flop is
composed of two D-Type Flip-Flops with the X1 input, put through a
NOT before becoming the input to the second D-Type Flip-Flop,
Stage 1: RS Flip-Flop
producing a Negative Edge flip-flop.
46 University of Abertay
47 University of Abertay
48 University of Abertay
50 University of Abertay
51 University of Abertay
52 University of Abertay
53 University of Abertay
Controlling a seven segment LED is quick tricky and requires a number of components to be created
before the final circuit can be constructed. However, as always, one should never reinvent the
wheel. After beginning the design of a BCD Controller based upon the BCD to Seven segment
decoder logic diagram [ CITATION III87 \l 2057 ], I discovered a fully implemented controller with all
54 University of Abertay
Figure 47: 7 Segment LED Controller 4
4
Completed Design by afterawe
This provided enough information to generate a 0-9 display system; however, further investigation is
necessary to allow the display of the remaining six Hexadecimal values.
Subtraction
; ===== WORK OUT 2 Minus 2 ======================================
CLO ; Close unwanted windows.
Division
MOV AL,2 ; Copy a 2 into the AL register.
MOV BL,2 ; Copy a 2 into the BL register.
SUB AL,BL ; Subtract AL to ;BL.
===== WORKgoes
Answer OUT into
2 Divided
AL. by 2 ====================================
END ; Program ends CLO ; Close unwanted windows.
MOV AL,2 ; Copy a 2 into the AL register.
; ===== Program Ends ===========================================
MOV CL,2 ; Copy a 2 into the CL register.
DIV AL,CL ; Divide AL by CL. Answer goes into AL.
END ; Program ends
; ===== Program Ends ===========================================
Divide by Zero
; ===== WORK OUT 2 Divided by 0 ==================================== As was expected the
CLO ; Close unwanted windows.
MOV CL,2 ; Copy a 2 into the CL register.
MOV DL,0 ; Copy a 2 into the DL register. software throws a
DIV AL,BL ; Divide CL by DL. Answer goes into CL.
END ; Program ends “Divide by Zero”
; ===== Program Ends ===========================================
Exception.
04IncJmp.asm - Counting
; ====== Subtract 1 from the previous value in BL
MOV BL,40 ; Set BL to 40
; --------------------------------------------------------------
; Input key presses from the keyboard until Enter is pressed.
; --------------------------------------------------------------
CLO ; Close unwanted windows.
Rep:
IN 00 ; Wait for key press - Store it in AL.
CMP AL,0D ; Was it the Enter key? (ASCII 0D)
MOV [C0],AL ; Copy the Character in AL to top left of the Video Memory (Screen)
JNZ Rep ; No - jump back. Yes - end.
END
; --------------------------------------------------------------
Harder Use BL to point to address [C0] and increment BL after each key press in order to see the
text as you type it.
; --------------------------------------------------------------
; Input key presses from the keyboard until Enter is pressed.
; --------------------------------------------------------------
CLO ; Close unwanted windows. Harder! Store all
MOV BL,C0 ; Copy C0 – Hex to BL
Rep: the text you type
IN 00 ; Wait for key press - Store it in AL.
CMP AL,0D ; Was it the Enter key? (ASCII 0D) in RAM when you
MOV [BL], AL ; Copy the Contents of AL to the Video Location BL
INC BL ; Move the Video Address on one place type it in.
JNZ Rep ; No - jump back. Yes - end.
When you
END
; -------------------------------------------------------------- press Enter,
59 University
display of
theAbertay
stored
text on the VDU display.
Rep:
IN 00 ; Input from port 00 (keyboard)
CMP AL,0D ; Was key press the Enter key?
JZ Stop ; If yes then jump to Stop
MOV [BL],AL ; Copy keypress to RAM at position [BL]
INC BL ; BL points to the next location.
JMP Rep ; Jump back to get the next character
Stop:
MOV AL,0 ; This is the NULL end marker
MOV [BL],AL ; Copy NULL character to this position.
Again:
MOV AL,[BL] ; Copy Memory contents to AL
CMP AL,0 ; End of message (NULL Marker) Found
JZ Bottom ; If Found go to Bottom
MOV [CL],AL ; copy AL contents to Screen location CL
INC CL ; Move the cursor on 1 place on VDU
INC BL ; Goto the next memory location
JMP Again ; Repeat the process
Bottom:
RET ; At present this procedure does
; nothing other than return.
; --------------------------------------------------------------
END ; It is correct to use END at the end.
; --------------------------------------------------------------
Difficult Type in text and store it. When Enter is pressed, display it on
the VDU screen in reverse order. Using the stack makes this task easier.
Rep:
IN 00 ; Input from port 00 (keyboard)
CMP AL,0D ; Was key press the Enter key?
JZ Stop ; If yes then jump to Stop
PUSH AL ; Copy keypress to STACK LIFO
INC DL ; Count how many characters were entered
JMP Rep ; Jump back to get the next character
Stop:
MOV AL,0 ; This is the NULL end marker
PUSH AL ; Copy NULL character Stack.
CALL 40
RET ; Return from the procedure.
; --------------------------------------------------------------
; A PROCEDURE TO DISPLAY TEXT ON THE SIMULATED SCREEN
ORG 40 ; Code starts from address [10]
61 MOV CL,C0 ; Copy VDU 0,0 Hex Address to CL University of Abertay
Again:
CMP DL,0 ; If We have done all the chars end
JZ Bottom ; Go to end if done
POP BL ; Copy Memory contents to AL
CMP BL,0 ; Is this the Null Character?
JZ SKIP
CMP BL,27 ; Is this the LF/CR (Return / Enter Key)?
JZ SKIP
MOV [CL],BL ; Copy the char in BL into the VDU location
INC CL ; Move the VDU location on one place
SKIP: ; Skip the displaying of a character!
DEC DL ; Decrease the Character Counter
JMP Again ; Repeat the process
Bottom:
RET ; At present this procedure does
; nothing other than return.
; --------------------------------------------------------------
END ; It is correct to use END at the end.
; --------------------------------------------------------------
06proc.asm
Re-do the traffic lights program and use this procedure to set up realistic
time delays. 02tlight.asm
END ; EXIT
; --------------------------------------------------------------
17) Write a program using three procedures. The first should read text from the keyboard and
store it in RAM. The second should convert any upper case characters in the stored text to lower
case. The third should display the text on the VDU screen.
63 University of Abertay
Rep:
IN 00 ; Input from port 00 (keyboard)
CMP AL,0D ; Was key press the Enter key?
JZ Stop ; If yes then jump to Stop
MOV [BL],AL ; Copy keypress to RAM at position [BL]
INC BL ; BL points to the next location.
JMP Rep ; Jump back to get the next character
Stop:
MOV AL,0 ; This is the NULL end marker
MOV [BL],AL ; Copy NULL character to this position.
; --------------------------------------------------------------
; A PROCEDURE TO CONVERT UPPERCASE TEXT TO LOWERCASE
ORG 40 ; This routine is at address 40
MOV BL,A0 ; Go to beginning of the RAM
REP2:
MOV AL,[BL] ; Get char from RAM
CMP AL,0 ; Is it Null END OF LINE MARKER?
64 JZ BOT ; Go To BOT We are done here! University of Abertay
OR AL,20 ; OR MASK 0010 0000 (the difference between Upper and Lowercase)
MOV [BL],AL ; Save the lowecase letter back
INC BL ; Go to next RAM character
JMP REP2 ; Do next character
BOT:
RET ; Return from the Routine
; --------------------------------------------------------------
; A PROCEDURE TO DISPLAY TEXT ON THE SIMULATED SCREEN
ORG 70 ; Code starts from address [10]
MOV CL,C0 ; Copy VDU 0,0 Hex Address to CL
MOV BL,A0 ; Set BL to memory location A0
Again:
MOV AL,[BL] ; Copy Memory contents to AL
CMP AL,0 ; End of message (NULL Marker) Found
JZ Bottom ; If Found go to Bottom
MOV [CL],AL ; copy AL contents to Screen location CL
INC CL ; Move the cursor on 1 place on VDU
INC BL ; Goto the next memory location
JMP Again ; Repeat the process
Bottom:
RET ; At present this procedure does
; nothing other than return.
; --------------------------------------------------------------
END ; It is correct to use END at the end.
; --------------------------------------------------------------
18) Improve the traffic lights data table so there is an overlap with
both sets of lights on red.
ENDD:
PUSH BL ; This is the answer put it on the stack for later POPing
RET ; Return from the procedure
; --------------------------------------------------------------
END
67 ; ---- University of Abertay
ALTERNATIVELY RECURSION COULD HAVE BEEN USED.
procedure. Use this definition of Factorial.
Factorial ( 0 ) is defined as 1.
Factorial ( N ) is defined as N * Factorial (N - 1).
Start: 10swint.asm
MOV AL,5 ; AL = 5, the number to factorise.
PUSH AL ; Throw it on the stack
CALL 40 ; Call the ROUTINE at Address 40 26) Write a new
HALT ; STOP THE PROGRAM
interrupt 02 that
;------------------------------- fetches a key press
; THE RECURSIVE FACTORIAL ROUTINE from the keyboard and
ORG 40 ; THE FACTORISING ROUTINE (RECURSIVE)
POP BL ; IGNORE THE STACK FOR THE CALL 40 stores it into RAM.
POP BL ; GET THE COUNTER and put it in BL The IBM PC allocates
DEC BL ; One too many so reduce the counter by one
CMP BL,1 ; Stop if Counter = 1 16 bytes for key
JZ BOT press storage. The
MUL AL,BL ; Multiply CL by the Counter
PUSH BL ; Throw the counter on the stack 16 locations are used
CALL 40 ; CALL SELF (Recursion) in a circular
BOT:
fashion.
RET
END
David Gordon (1004103)
CE0714A
; --------------------------------------------------------------
; An example of software interrupts.
; --------------------------------------------------------------
JMP Start ; Jump past table of interrupt vectors 27) Create a new
DB 51 ; Vector at 02 pointing to address 51
interrupt that puts
Start: characters onto the
next free screen
INT 02 ; Do interrupt 02
JMP Start location. See if you
; -------------------------------------------------------------- can get correct
ORG 50 behaviour in response
DB E0 ; Data byte - could be a whole table here to the Enter key being
; Interrupt code starts here pressed (fairly easy)
MOV CL,40 ; [40] is the address where the text will
PUSH AL ; Save AL onto the stack and if the Back Space
PUSH CL ; Save CL onto the stack key is pressed
PUSHF ; Save the CPU flags onto the stack
(harder).
Rep:
IN 00 ; Input from port 00 (keyboard)
CMP AL,0D ; Was key press the Enter key?
JZ Stop ; If yes then jump to Stop
MOV [CL],AL ; Copy keypress to RAM at position [CL]
INC CL ; CL points to the next location.
JMP Rep ; Jump back to get the next character
Stop:
MOV AL,0 ; This is the NULL end marker A Comparison of
MOV [CL],AL ; Copy NULL character to this position.
68 University of Abertay
69 University of Abertay
ANONYMOUS. 2010. 10/100 Mbps PCI Network Card. [online]. [Accessed 11 Dec 2010]. Available
from World Wide Web: <http://www.usr.com/products/networking/networking-product.asp?
type=specs&sku=USR997900>
ANONYMOUS. 2010. Comprehensive List of How (Key to Press) to Access BIOS for Various OEM and
Computer Systems. [online]. [Accessed 11 Dec 2010]. Available from World Wide Web:
<http://www.mydigitallife.info/2008/07/06/comprehensive-list-of-how-key-to-press-to-access-bios-
for-various-oem-and-computer-systems/>
CONSORTIUM, Unicode. 2010. C0 Controls and Basic Latin (PDF). [online]. [Accessed 13 Dec 2010].
Available from World Wide Web: <http://www.unicode.org/charts/PDF/U0000.pdf>
III, Forrest M. Mims. 1987. Diagram.Com. [online]. [Accessed 22 Dec 2010]. Available from World
Wide Web: <http://thediagram.com/7_2/bcd_decoder.html>
NIRMAL. 2009. Windows OS Version Numbers. [online]. [Accessed 11 Dec 2010]. Available from
World Wide Web: <http://www.nirmaltv.com/2009/08/17/windows-os-version-numbers/>
70 University of Abertay
QUILLEY, Andrew. 2010. IT Jargon Buster. [online]. [Accessed 10 Dec 2010]. Available from World
Wide Web: <http://www.it-station.co.uk/jargon.html#c>
RICKER, Thomas. 2009. Tilera's 100-core Tile-GX processor won't boil the oceans, will still melt faces.
[online]. [Accessed 10 Dec 2010]. Available from World Wide Web:
<http://www.engadget.com/2009/10/26/tileras-100-core-tile-gx-processor-wont-boil-the-oceans-
will/>