Tutorial 1
Tutorial 1
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 !>
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