Você está na página 1de 19

8051 Development Tools

http://bit.kuas.edu.tw/~8051
Assembler / Simulator / C Compiler

Tools Used in This Course


EDITOR PROGRAM
WORD

myfile.a51 ASSEMBLER PROGRAM myfile.lst myfile.hex


ASEM.EXE

Simulator

TS Controls Emulator 8051 1.00

Download Tools
Please go to the web site

http://bit.kuas.edu.tw/~8051
and download the files with underlines. Assembler
Download ASEM-51 v1.3 and unzip it into a subdirectory.

Simulator
Emulator 8051 V1.0 by TS Controls is a software simulator for 8051.

Assembler
ASEM-51, by W.W. Heinz, is a free 8051 macro assembler for MS-DOS, Windows and Linux. It is a two-pass macro assembler for the Intel MCS-51 family of microcontrollers.
Issue "ASEM PROG2-1.A51" within DOS box will process the source file "PROG2-1.A51" and generate a output file "PROG2-1.HEX" in Intel-HEX format and a list file "PROG2-1.LST" in plain text.

Refer to "ASEM_51.DOC" for detail usage. The example program "DEMO.A51" is very instructive.

Demo
C:\Documents and Settings\pcs3412>cd .. C:\Documents and Settings>cd .. C:\>cd 8051asm C:\8051asm>ASEM PROG2-1.A51 no errors C:\8051asm>dir 2002/12/31 01:30 81,920 ASEMW.EXE : 2008/09/29 11:40 50 PROG2-1.hex 2008/09/29 11:40 3,460 PROG2-1.lst C:\8051asm>

PROG2-1.A51
ORG MOV MOV MOV ADD 0H R5,#25H R7,#34H A,#0 A,R5 ;start (origin) at location 0 ;load 25H into R5 ;load 34H into R7 ;load 0 into A ;add contents of R5 to A ;now A = A + R5 ;add contents of R7 to A ;now A = A + R7 ;add to A value 12H ;now A = A + 12H ;stay in this loop ;end of asm source file

ADD A,R7 ADD A,#12H HERE:SJMP HERE END

Part of PROG2-1.LST
Line I Addr Code Source

1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:

N 0000 0002 0004 0006

0000 7D 25 7F 34 74 00 2D

ORG MOV MOV MOV ADD

0007 2F

0008 24 12
000A 80 FE

0H ;start (origin) at location 0 R5,#25H ;load 25H into R5 R7,#34H ;load 34H into R7 A,#0 ;load 0 into A A,R5 ;add contents of R5 to A ;now A = A + R5 ADD A,R7 ;add contents of R7 to A ;now A = A + R7 ADD A,#12H ;add to A value 12H ;now A = A + 12H HERE:SJMP HERE ;stay in this loop END ;end of asm source file

PROG2-1.HEX
:0C0000007D257F3474002D2F241280FE1B :00000001FF

Simulator
Emulator 8051 V1.0 by TS Controls is a software simulator for 8051.
Execute Tsce0100.exe Load PROG2-1.HEX and execute it

Load PROG2-1.HEX

Registers

Program List

Step by Step Execution

Internal RAM

ORG MOV MOV MOV ADD

0H R5,#25H R7,#34H A,#0 A,R5

ADD A,R7 ADD A,#12H HERE:SJMP HERE END

;start (origin) at location 0 ;load 25H into R5 ;load 34H into R7 ;load 0 into A ;add contents of R5 to A ;now A = A + R5 ;add contents of R7 to A ;now A = A + R7 ;add to A value 12H ;now A = A + 12H ;stay in this loop ;end of asm source file

Stop The Program

C Compiler
Small Device C Compiler
SDCC - Small Device C Compiler is a free C compiler for 8051, although library is incomplete. Download sdcc-2.3.0-i586-mingw32msvc.zip and unzip it to "c:\" with directory structure preserved. Add "c:\sdcc\bin" to DOS search path. Issue "sdcc --code-loc 0x4000 --xram-loc 0x8000 Ex7-1.c" within DOS box will generate Ex7-1.ihx" in Intel-HEX format,
"--code-loc 0x4000" is used to specify starting code address. "--xram-loc 0x8000" is used to specify starting address of external data memory.

Refer to "c:\sdcc\share\doc\sdcc\sdccman.pdf" for SDCC Compiler User Guide.

Ex7-1.c
#include <8051.h> void main(void) { unsigned char z; for (z=0; z<=255; z++) P1=z; }

Compiler Ex7-1.c

Ex7-1.ihx
:0440000002405032F8 :01400B003282 :01401300327A :01401B003272 :01402300326A :01402B003262 :0D40500075810712404CE582600302403389 :03405D00024033EB :0540330012403880FE80 :024038007A000C :0C403A008A037C00C374FF9BE49C4005DB :054046008A900A80EFE2 :01404B002252 :03404C007582007A :01404F00224E :00000001FF

Você também pode gostar