0% found this document useful (0 votes)
52 views

Tutorial 1

The document provides instructions on how to load and run a simple program using the DEBUG command prompt tool. It explains how to assemble code into memory locations, save the program to a floppy disk, load and run the program. It then steps through the program using breakpoints to observe the values in CPU registers after each instruction executes. This demonstrates the instruction cycle of fetching code from memory, incrementing the instruction pointer, decoding and executing instructions to visualize the memory resident program execution process.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Tutorial 1

The document provides instructions on how to load and run a simple program using the DEBUG command prompt tool. It explains how to assemble code into memory locations, save the program to a floppy disk, load and run the program. It then steps through the program using breakpoints to observe the values in CPU registers after each instruction executes. This demonstrates the instruction cycle of fetching code from memory, incrementing the instruction pointer, decoding and executing instructions to visualize the memory resident program execution process.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Tutorial 1: Examine the Instruction Cycle and observe the

memory resident code in execution:


Follow the following steps: i) From the PROGRAMS GROUP click on the COMMAND PROMPT. ii) change the directory to c:\winnt\system32 by issuing the command: c:\>CD \winnt\system32 iii) load the DEBUG thus: c:\winnt\system32\debug iv) you will see the DEBUG CURSOR as a blinking hyphen - v) assemble the following code into absolute memory location starting at 100 HEX. Follow exactly the screen bellow. NOTE: Here the SEGMET ADDRESS STARTS AT It may be different in your PC.
C:\WINNT\system32>debug -A100 0A9A:0100 MOV AL,20 0A9A:0102 MOV BL,25 0A9A:0104 ADD AL,BL 0A9A:0106 SUB AL,BL 0A9A:0108 MOV AH,4C 0A9A:010A INT 21 0A9A:010C <just press enter key> --

0A9A:

vi)

Now give a name to this program and save it on your floppy by following the steps bellow:
< RESERVES A FILE IN DRIVE B> < TO TELL HOW BIG IS THE FILE IN BYTES> < NOW IT IS ONLY 0 BYTE> < WE ENTER 50 TO SET IT FOR 50 BYTES> < SEE THE VALUE OF BASE COUNTER> < IT IS 0. DONT CHANGE IT.> <JUST PRESS ENTER TO LEAVE IT AT 0> < NOW WRITE IT ON THE FLOPPY DISK> <IT IS WRITING IT> <QUIT THE DEBUGGER> <CHECK TO SEE IT ON A:\>

-N=A:\MYINST1.COM -RCX CX 0000 :50 -RBX BX 0000 : -W Writing 00050 bytes -Q C:\WINNT\system32>DIR A:\MYINST1.COM Volume in drive A has no label. Volume Serial Number is 7CA5-6E80 Directory of A:\ 06/28/01 08:03p 1 File(s) 80 MYINST1.COM 80 bytes 1,028,096 bytes free

<HERE IT IS !>

-nnnn : 010D <press enter> -n = a:\myinst1.com C:\WINNT\system32>

OK! now lets continue with the debugger and step through the program by inserting the break points and see the internal state of the CPU registers after execution of each instruction. We first load our program from floppy a: and step through it. Just follow the following screen.
C:\WINNT\system32>DEBUG A:\MYINST1.COM <load our prog.> -U100 <Unassemble the program> 0AD3:0100 B020 MOV AL,20 <Here it is!> 0AD3:0102 B325 MOV BL,25 0AD3:0104 00D8 ADD AL,BL 0AD3:0106 28D8 SUB AL,BL 0AD3:0108 B44C MOV AH,4C 0AD3:010A CD21 INT 21 <OUR PROGRAM IS UP TO HERE. You see> <some garbage following. Just ignore them> < I have erased them for clarity here!> -R AX=0000 BX=0000 CX=0050 DX=0000 SP=FFFE BP=0000 SI=0000 DI=0000 DS=0AD3 ES=0AD3 SS=0AD3 CS=0AD3 IP=0100 NV UP EI PL NZ NA PO NC 0AD3:0100 B020 MOV AL,20 -G=100 102 AX=0020 BX=0000 CX=0050 DX=0000 SP=FFFE BP=0000 SI=0000 DI=0000 DS=0AD3 ES=0AD3 SS=0AD3 CS=0AD3 IP=0102 NV UP EI PL NZ NA PO NC 0AD3:0102 B325 MOV BL,25 -G=102 104 AX=0020 BX=0025 CX=0050 DX=0000 SP=FFFE BP=0000 SI=0000 DI=0000 DS=0AD3 ES=0AD3 SS=0AD3 CS=0AD3 IP=0104 NV UP EI PL NZ NA PO NC 0AD3:0104 00D8 ADD AL,BL -G=104 106 AX=0045 BX=0025 CX=0050 DX=0000 SP=FFFE BP=0000 SI=0000 DI=0000 DS=0AD3 ES=0AD3 SS=0AD3 CS=0AD3 IP=0106 NV UP EI PL NZ NA PO NC 0AD3:0106 28D8 SUB AL,BL -G=106 108 AX=0020 BX=0025 CX=0050 DX=0000 SP=FFFE BP=0000 SI=0000 DI=0000 DS=0AD3 ES=0AD3 SS=0AD3 CS=0AD3 IP=0108 NV UP EI PL NZ NA PO NC 0AD3:0108 B44C MOV AH,4C -G=108 10A AX=4C20 BX=0025 CX=0050 DX=0000 SP=FFFE BP=0000 SI=0000 DI=0000 DS=0AD3 ES=0AD3 SS=0AD3 CS=0AD3 IP=010A NV UP EI PL NZ NA PO NC 0AD3:010A CD21 INT 21 -

Now lets examine the execution of each instruction after each break point. Observe the value of the affected registers as the result of each instruction execution. Especially check the value of the IP (Instruction Pointer). And try to use your imagination to visualise the MEMORY RESIDENT PROGRAM EXECUTION within the context of INSTRUCTION CYCLE in a BUS ARCHITECTURED COMPUTER SYSTEM. Try to visualise the INFINITE LOOP OF a simple Instruction Cycle:

START

FETCH

INCREMENT

DECODE

EXECUTE

Remember: 1. FETCH ==> Get the instruction addressed by IP in the memory and load it into MBR , thus: 1.1 IP ==>MAR 1.2 [MAR] ==> DATA BUS 1.3 DATA BUS ==> MBR 2. INCREMENT ==> Increment the IP by the increment factor interpreted from the instructions OPERATION CODE (OP CODE) to get ready for next fetch, thus: 2.1 IP = IP + <INCREMENT FACTOR> 3. DECODE ==> Send the Instruction code in the MBR to IR so that IR interpret it and generate the EXECUTION CONTROL SIGNALS needed for its execution, thus: 3.1 MBR ==> IR 3.2 IR ==> <Produce the micro code needed for the execution control at the IRs output> 4. EXECUTE ==> Send the IRs Output to the Seuencer to starts the execution sequence, thus: 4.1 IR ==> Sequencer

You might also like