Lab Report2 Keil Simulator
Lab Report2 Keil Simulator
1
Lab2 Keil Simulator & Debugger Khubaib & Saad
Figure 1 Keil Window (If text editor is present, go-to PROJECT, CLOSE PROJECT)
Objectives:
1
Lab2 Keil Simulator & Debugger Khubaib & Saad
1. After opening Keil uV4, go-to PROJECT in main toolbar and select NEW.
2. Browse to save the project
3. In dialog box SELECT YOUR DEVICE MODEL as 89C51 by browsing in ATMEL or using
the SEARCH tab given. Cancel ADD STARTUP FILE OF YOUR DEVICE as we do not
need it
4. Now in PROJECT WINDOW, TARGET, SOURCE GROUP one can add NEW or
EXISTING project
5. Add ASM FILE for assembly language
2
Lab2 Keil Simulator & Debugger Khubaib & Saad
3
Lab2 Keil Simulator & Debugger Khubaib & Saad
General Syntax
Commands
ORG 0: Organize Memory. Start of program. Memory starts from the specified location. If ORG
5 than memory 0 to 4 wasted
Main: Label is optional if desired can be added after ORG
MOV: as MOV destination, source. Sets the value of destination=source, Overwrites the
destination
MOV A, P0 ; A=P0
ADD: Can only be used with special register A. Performs arithmetic addition operation.
ADD A, operand ; A = A + operand i.e. addition result stored in A
SETB: Sets bit to 1
CLR: Resets bit to 0
END: after END everything ignored. It shows END of prgram
4
Lab2 Keil Simulator & Debugger Khubaib & Saad
Registers
Memory Window
Shows all memory of 89C51. Use D:00 to see data-memory at 00 to see code-memory use
C:00. Code memory has Op-codes while data memory stores data values.
1. After writing program , SAVE, TRANSLATE and BUILD. If error code wont
BUILD.
5
Lab2 Keil Simulator & Debugger Khubaib & Saad
4. If program involves port seeing, go-to PERIPHERALS and use the port needed. Also in
memory see FF they are port locations in memory
Figure 8 Debugger
6
Lab2 Keil Simulator & Debugger Khubaib & Saad
5. Goto Proteus, make circuit, double click on µC 89C51 and upload/burn HEX file in it
6. Simulate. Observe that any change in PORT1 is seen in PORT2 i.e. data is being read from
PORT1 and outputted on PORT2
7
Lab2 Keil Simulator & Debugger Khubaib & Saad
8
Lab2 Keil Simulator & Debugger Khubaib & Saad
Conclusion
We learned
Keil Simulation and Debugging
Writing an assembly program
Burning Code on µC
How to input/output data from ports
References
http://www.circuitstoday.com/getting-started-with-keil-uvision