19
8051 Development Tools http://bit.kuas.edu.tw/~8 051 Assembler / Simulator / C Compiler

8051 Development Tools 8051 Assembler / Simulator / C Compiler

  • View
    282

  • Download
    3

Embed Size (px)

Citation preview

Page 1: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

8051 Development Tools

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

Page 2: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

Tools Used in This Course

EDITORPROGRAM

myfile.a51

ASSEMBLERPROGRAM

myfile.lst

myfile.hex

Simulator

ASEM.EXE

WORD

TS Controls Emulator 8051 1.00

Page 3: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

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 sub-

directory.

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

simulator for 8051.

Page 4: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

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 pro

cess 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.

Page 5: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

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>

Page 6: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

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

Page 7: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

Part of PROG2-1.LST

Line I Addr Code Source

1: N 0000 ORG 0H ;start (origin) at location 0

2: 0000 7D 25 MOV R5,#25H ;load 25H into R5

3: 0002 7F 34 MOV R7,#34H ;load 34H into R7

4: 0004 74 00 MOV A,#0 ;load 0 into A

5: 0006 2D ADD A,R5 ;add contents of R5 to A

6: ;now A = A + R5

7: 0007 2F ADD A,R7 ;add contents of R7 to A

8: ;now A = A + R7

9: 0008 24 12 ADD A,#12H ;add to A value 12H

10: ;now A = A + 12H

11: 000A 80 FE HERE:SJMP HERE ;stay in this loop

12: END ;end of asm source file

Page 8: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

PROG2-1.HEX

:0C0000007D257F3474002D2F241280FE1B

:00000001FF

Page 9: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

Simulator

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

Page 10: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

Load PROG2-1.HEX

Page 11: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

Registers

Page 12: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

Program List

Page 13: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

Step by Step Execution

Page 14: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

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

Page 15: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

Stop The Program

Page 16: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

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 unzi

p it to "c:\" with directory structure preserved. – Add "c:\sdcc\bin" to DOS search path. – Issue "sdcc --code-loc 0x4000 --xram-loc 0x8000 Ex

7-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 ext

ernal data memory. – Refer to "c:\sdcc\share\doc\sdcc\sdccman.pdf" for SD

CC Compiler User Guide.

Page 17: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

Ex7-1.c

#include <8051.h>

void main(void)

{

unsigned char z;

for (z=0; z<=255; z++)

P1=z;

}

Page 18: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

Compiler Ex7-1.c

Page 19: 8051 Development Tools 8051 Assembler / Simulator / C Compiler

Ex7-1.ihx:0440000002405032F8

:01400B003282

:01401300327A

:01401B003272

:01402300326A

:01402B003262

:0D40500075810712404CE582600302403389

:03405D00024033EB

:0540330012403880FE80

:024038007A000C

:0C403A008A037C00C374FF9BE49C4005DB

:054046008A900A80EFE2

:01404B002252

:03404C007582007A

:01404F00224E

:00000001FF