Anda di halaman 1dari 10

TECHNOLOGICAL INSTITUTE OF THE PHILIPPINES

COMPUTER ENGINEERING DEPARTMENT


Quezon City

Laboratory Manual

in

COMPUTER SYSTEMS ORGANIZATION


with ASSEMBLY LANGUAGE

By:

Leah Belaya
Maria Cecilia Atienza-Venal
Table of Contents

Experiment No Title Page No.

1 Debug Commands Familiarization 4


Assembly Language using Turbo
2 11
Assembler
3 Services / Functions with Interrupts 15

4 String Manipulation 18

5 Displaying Character with Attribute 22

6 Arithmetic Operations 26

7 File Handling 31

8 Case Study 35
EXPT. TITLE DATE TEACHERS
GRADE
NO. PERFORMED SIGNATURE
Debug Commands
1 Familiarization
Assembly Language using Turbo
2
Assembler
Services / Functions with
3
Interrupts
4 String Manipulation

5 Displaying Character with Attribute

6 Arithmetic Operations

7 File Handling

8 Case Study

Name: Elnar, Hem Lock T.

Student Number: 1511470

Time/Day/Room No.: 7:30-10:30AM/Tuesday/Q-3206

Instructor: Engr. Verlyn Vicente


EXPERIMENT NO. 1
DEBUG COMMANDS FAMILIARIZATION

OBJECTIVE (S):
At the end of this laboratory activity the students will be able to:

1. familiarize themselves with the common DEBUG commands;


2. investigate the 8088/8086 instructions sets and familiarize themselves with their functions; and
3. construct an assembly language program-using DEBUG.com.

REQUIREMENTS:
Personal Computer with Windows XP, 2000, 2003
Debug.com

DISCUSSION:

DOS_DEBUG.COM

DOS offers a debugging utility as one of its internal commands. The DEBUG program can
be used to:

Provide a controlled testing environment so one can monitor and control the execution
of a program.
Load, alter or display any file
Execute object files. Object files are executable programs in machine language
format.

DEBUG COMMMANDS

- The prompt from DEBUG program is a hyphen ( - )


- A command is a single letter, usually followed by one or more parameters, commands
become effective only after you press the ENTER KEY.
- Commands and parameters can be entered in uppercase or lowercase, or a
combination of both.
- Delimiters may separate commands and parameters.

PROCEDURES:
1. Open your command prompt at START>Run. Invoke DEBUG from the PCs RAMDRIVE.

C:\WINDOWS>debug /?

Runs Debug, a program testing and editing tool.


DEBUG [[drive:][path]filename [testfile-parameters]]
[drive:][path]filename Specifies the file you want to test.
testfile-parameters Specifies command-line information required by the file you want to test.

Write down the meaning of display usage above when you invoke the PCs RAM Drive
It explains what happens when you type C:\>debug and the specification of the drive, parameters, path
and such.
2. Investigate the Debug.com commands. Write your observation on the 3 rd column of the table below.

Debug.com Commands Description Example(s) Observation(s)


It simply quits
Quit: Q C:\WINDOWS>debug the debug
program in
Immediately quits (exits) the Debug program! -q command
prompt
Hex: H value1 value2
C:\WINDOWS>debug
A very simple (add and subtract only) Hex
It shows the
calculator. Never forget that all numbers -h aaa 531 -h fff 3 -h dbf sum and
inside of DEBUG are always Hexadecimal. ace difference of
Enter two Hex values (no more than four 0FDB 0579 1002 hexadecimal
digits each) and DEBUG shows first the 0FFC 188D 02F1 values inputted
SUM, then the DIFFERENCE of those - - -
values.
Dump: D [range] C:\WINDOWS>debug It displays
D [address] [length]
Displays the contents of a block of VGA
-d c000:0010
memory. The Memory locations near the Compatible
-d 100 130
beginning of Segment C000 (even under
-d 102 l24 BIOS in the
Windows 2000/XP) should display right of memory
information about the kind of video card
installed on your PC.
codes.
C:\WINDOWS>debug
Search: S range list
Searches within a range of addresses for a
-s fe00:0 ffff "BIOS" It searches a
-d fe00:0
pattern of one or more byte values given in a pattern of byte
- s 0:0 dff 'A20'
list. The list can be comprised of numbers or
-d 0:c40 values if there
character strings enclosed by matching are more of it.
-s 0:0 dff 43 4f 4d
single or double quote marks.
-d 0:770
C:\WINDOWS>debug It simply
-c 140 148 340 compares two
Compare: C range address memory codes
Compares two blocks of memory. If there if there is no
are no differences, then DEBUG simply differences it
displays another prompt (-). will just
continue to
debug
C:\WINDOWS>debug It simply clear a
Fill: F range list
-f 100 12f 'BUFFER'
This command can also be used to
-d 100 12f
segment
clear a whole segment of Memory as well as memory and
filling smaller areas with a continuously make it a
repeating phrase or single byte. repeatedly
phrase, here it
is BUFFER
C:\WINDOWS>debug
-e ffcb d2
Enter: E address [list] -e 200 'An "ASCII-Z string" is It directly puts
Used to enter data or instructions (as always followed by '
the data in
machine code) directly into Memory -e 22a "a zero-byte ('00h')." 00
locations. -e 100 B4 09 BA 0B 01 CD 21 B4 memory
00 CD 21 locations
-e ffff 24
-g =100
C:\WINDOWS>debug It starts the
-g =100 debugging. at
Go: G [=address] [addresses] the end there
Go is used to run a program and set are terminated
breakpoints in the program's code. normally
means it runs
as should it be.
C:\WINDOWS>debug
-a 100
xxxx:0100 jmp 126
xxxx:0102 db 0d,0a,"This is my
Assemble: A [address]
first DEBUG program!"
Creates machine executable code in memory
xxxx:0123 db 0d,0a,"$" After inputting
beginning at CS:0100 (or the specified
address) from the 8086/8088 (and 8087)
xxxx:0126 mov ah,9 this, the debug
Assembly Language instructions which are
xxxx:0128 mov dx,102 program starts.
xxxx:012B int 21
entered.
xxxx:012D mov ah,0
xxxx:012F int 21
xxxx:0131
-g =100
C:\WINDOWS>debug
Unassemble: U [range]
-u 126 12F
Disassembles machine instructions into
8086 Assembly code. Without the optional
xxxx:0126 B409 MOV AH,09 It shows the
xxxx:0128 BA0201 MOV DX,0102
[range], it uses Offset 100 as its starting
xxxx:012B CD21 INT 21
codes and the
point, disassembles about 32 bytes and then
xxxx:012D B400 MOV AH,00 instructions.
remembers the next byte it should start with if
xxxx:012F CD21 INT 21
the command is used again.
C:\WINDOWS>debug
Input: I port
Output: O port byte
-o 70 04 <-- Check the hours. The outport
-i 71
Used I/O commands for handling tasks tells to input
18 <----- 18 hours (or 6 p.m.)
through parallel and serial ports (e.g., to
-o 70 02 <-- Check the minutes. what it should
change the font used by a printer or values in
-i 71 do and display
a modem's control registers).
52 <----- 52 minutes
C:\WINDOWS>debug
Load: It loads the (in
-l 100 2 0 1 [ the C: drive. ]
L [address] [drive] [firstsector] [number]
or program! (See the N command for
-d 100 10f my case it is
more on this)
-d 280 2ff C:\) selected
This command will LOAD the selected -l 100 0 0 1 [ a floppy in the A: number of
number of sectors from any disk's Logical drive. ] sectors of disk.
Drive under the control of MS-DOS or -d 100 13d
Windows into Memory.
-l 100 0 0 1 [ a different floppy in
the A: drive. ]
-d 100 13d

-d 2d0 2ff
Move: M range address C:\WINDOWS>debug It copies the
This command should really be called: -m 7c00 7cff 600
memory codes
COPY (not Move) as it actually copies all the -m 100 2ff 70
bytes from within the specified range to a into another
new address. location
C:\WINDOWS>debug
-n c:\temp\doswinok.com
-a 100
cs:0100 jmp 138
cs:0102 db 0d,0a,"It's OK to run
this " It simply load
cs:0118 db "program under files and
DOS or Windows!"
convert it to
Name: N [pathname] [arglist] cs:0135 db 0d,0a,24
This command can be used to load files cs:0138 mov dx,102 debug
into DEBUG's Memory after you have started cs:013B mov ah,9 program`s
the program, but its main function is to create cs:013D int 21 memory. I
a new file under control of the Operating cs:013F mov ax,4c01 guess you can
System which DEBUG can WRITE data to. cs:0142 int 21
edit the
cs:0144
-rcx memory code
CX 0000 of that certain
:44 file.
-w
Writing 00044 bytes [ 68 bytes in
decimal ]
-q

C:\WINDOWS>debug
-r cx
-r
Register: R [register]
Entering ' r ' all by itself will display all of It shows the
the 8086 register's contents and the next
instruction which the IP register points to in
values on the
both machine code and an unassembled register.
(Assembly Language) form.

3. Use the DEBUG R command to display the contents of the registers. What are the contents of the
following registers?
General Purpose
Segment Registers Pointer and Index Register
Registers
AX 0000 CS 0B25 IP 0100
BX 0000 DS 0B25 SI 0000
CX 0000 ES 0B25 DI 0000
DX 0000 SS 0B25 SP FFEE
BP 0000

4. Write down the complete DEBUG command in changing the content of CX register to 3265.

Debug > r cx > 3265. To check if the value successfully changed just r cx and if the cx value is
now 3265 then you did it right!

5. Load DEBUG enter assembly language program using A command. The A ( assembler ) command
lets you enter mnemonic code assembly language instructions.

Format : A < address >

Address is assumed to be an off set from the address in CS, unless another segment value is
given.

Assemble the following code into memory location 1234:0100


R
1234:0100 mov ah,2
1234:0102 mov dl,54
1234:0104 int 21
1234:0106 mov dl,45
1234:0108 int 21
1234:010a mov dl,43
1234:010c int 21
1234:010e mov dl,48
1234:011g Int 21
1234:011i int 21
1234:010k int 20
1234:011m

6. To write a file, it must first be initialized with the N command. The N command initialized a file
name in the memory before using the load or write command.

Save your program using nsample.com as filename


or
Format : N [drive] [filename] . [extension]

7. g ( go ) command execute the program.


What will be the output after executing?

8.. Place the number of bytes to be written in BX and CX ( BX contains the high 16 bits, and CX contains
the low 16 bits. To change the contents of registers BX and CX with the size of the code you enter. The
W ( write ) command writes a block of memory to a file.
-r cx
cx 0000
:10
-w
writing 00010 bytes
-q

9. See the contents of the RAMDRIVE (C:\>dir).

a. Is the file sample.com present? b. how many bytes does the file consume?
SUMMARY:
This is quite different from any other program I already used, for me this activity is easy but without the
guide and instructions, I know this will be quite confusing. The most difficult part is you need a lot of effort to
type just to show the output and you need to consider the ASCII for conversion.

CONCLUSION:
I conclude that you need to familiarize yourself with the common debug commands because if you do
not, how about the next activity which will be surely use many complex commands with combination. I also
conclude that constructing an assembly language is not that easy because you need to consider a lot of
things such as the ASCII and the functions of commands especially when you use it because it is not the
simply putting command there and you have the assembly, you need to understand what you are doing.

Anda mungkin juga menyukai