8051 Development Tools Assembler / Simulator / C Compiler
Tools Used in This Course EDITOR PROGRAM myfile.a51 ASSEMBLER PROGRAM myfile.lst myfile.hex Simulator ASEM.EXE WORD TS Controls Emulator
Download Tools Please go to the web site and download the files with underlines. Assembler –Download ASEM-51 v1.3 and unzip it into a sub- directory.ASEM-51 v1.3 Simulator –Emulator 8051 V1.0 by TS Controls is a software simulator for 8051.Emulator 8051 V1.0
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 0H ;start (origin) at location 0 MOV R5,#25H ;load 25H into R5 MOV R7,#34H ;load 34H into R7 MOV A,#0 ;load 0 into A ADD 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
Part of PROG2-1.LST Line I Addr Code Source 1: N 0000 ORG 0H ;start (origin) at location 0 2: 00007D 25 MOV R5,#25H ;load 25H into R5 3: 00027F 34 MOV R7,#34H ;load 34H into R7 4: MOV A,#0 ;load 0 into A 5: 00062D ADD A,R5 ;add contents of R5 to A 6: ;now A = A + R5 7: 00072F ADD A,R7 ;add contents of R7 to A 8: ;now A = A + R7 9: ADD A,#12H ;add to A value 12H 10: ;now A = A + 12H 11: 000A80 FE HERE:SJMP HERE ;stay in this loop 12: END ;end of asm source file
PROG2-1.HEX :0C D257F D2F241280FE1B : FF
Simulator Emulator 8051 V1.0 by TS Controls is a software simulator for –Execute Tsce0100.exe –Load PROG2-1.HEX and execute it
Load PROG2-1.HEX
Registers
Program List
Step by Step Execution
Internal RAM ORG 0H ;start (origin) at location 0 MOV R5,#25H ;load 25H into R5 MOV R7,#34H ;load 34H into R7 MOV A,#0 ;load 0 into A ADD 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
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 i586-mingw32msvc.zip and unzip it to "c:\" with directory structure preserved. –Add "c:\sdcc\bin" to DOS search path. –Issue "sdcc --code-loc 0x 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 void main(void) { unsigned char z; for (z=0; z<=255; z++) P1=z; }
Compiler Ex7-1.c
Ex7-1.ihx : F8 :01400B : A :01401B : A :01402B :0D CE :03405D EB : FE80 : A000C :0C403A008A037C00C374FF9BE49C4005DB : A900A80EFE2 :01404B :03404C A :01404F00224E : FF