본문 바로가기
나머지/IT개발.잡다한것.

Assembler Directives 와 LEDCycle 예제

by 무늬만학생 2012. 9. 25.
반응형

Macro Assemblerand Utilities


99p

Chapter 4. Assembler Directives

This chapter describes the assembler directives. It shows how to define symbols

and how to control the placement of code and data in program memory.

Introduction

The Ax51 assembler has several directives that permit you to define symbol

values, reserve and initialize storage, and control the placement of your code.

The directives should not be confused with instructions. They do not produce

executable code, and with the exception of the DB, DW and DD directives, they

have no direct effect on the contents of code memory. These directives change

the state of the assembler, define user symbols, and add information to the object

file.

The following table provides an overview of the assembler directives. Page

refers to the page number in this user’s guide where you can find detailed

information about the directive.


나머지는 Macro Assemblerand Utilities 참고




ISEG         111         ISEG [AT absolute address]             

Define an absolute segment within theinternal data space.

105p

Absolute Segments

Absolute segments reside in a fixed memory location. Absolute segments are

created using the CSEG, DSEG, XSEG, ISEG, and BSEG directives. These

directives allow you to locate code and data or reserve memory space in a fixed

location. You use absolute segments when you need to access a fixed memory

location or when you want to place program code or constant data at a fixed

memory address. Refer to the CSEG, DSEG, ISEG, XSEG, ISEG directives

for more information on how to declare absolute segments.

After reset, the 8051 variants begin program executing at CODE address 0. The

Intel/Atmel WM 251 starts execution at address FF0000. Some type of program

code must reside at this address. You can use an absolute segment to force

program code into this address. The following example is used in the Cx51

startup routines to branch from the reset address to the beginning of the

initialization code.


BSEG, CSEG, DSEG, ISEG, XSEG

The BSEG, CSEG, DSEG, ISEG, XSEG directives select an absolute segment.

This directives use the following formats:

BSEG     AT     address         defines an absolute BIT segment.

CSEG     AT     address         defines an absolute CODE segment.

DSEG     AT     address         defines an absolute DATA segment.

ISEG      AT     address         defines an absolute IDATA segment.

XSEG     AT     address         defines an absolute XDATA segment.


Reserving Memory

The memory reservation directives are used to reserve space in either word,

dword, byte, or bit units. The space reserved starts at the point indicated by the

current value of the location counter in the currently active segment.

DBIT DS

The DS directive reserves a specified number of bytes in a memory space. The

DS directive has the following format:

label: DS expression

where

label is the symbol that is given the address of the reserved

memory. The label is a typeless number and gets the current

address value and the memory class of the active segment.

The label can only be used where a symbol of this type is

allowed.

expression is the number of bytes to reserve. The expression cannot

contain forward references, relocatable symbols, or external

symbols.


The DS directive reserves space in the current segment at the current address.

The current address is then increased by the value of the expression. The sum

of the location counter and the value of the specified expression should not

exceed the limitations of the current address space.




LJMP

;------------------------------------------------------------------------------

; Provide an LJMP to start at the reset address (address 0) in the main module.

; You may use this style for interrupt service routines.

;------------------------------------------------------------------------------

CSEG AT 0 ; absolute Segment at Address 0

LJMP start ; reset location (jump to start)


sd

dd

dd



Location Counter

Each section of an assembler language program has a location counter used to assign storage addresses to your program's statements. As the instructions of a source module are being assembled, the location counter keeps track of the current location in storage. You can use a $ (dollar sign) as an operand to an instruction to refer to the current value of the location counter.

http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.aixassem/doc/alangref/location_count.htm


Address Control

The following directives allow the control of the address location counter or the control of absolute register symbols.


ORG

The ORG directive is used to alter the location counter of the currently active segment and sets a new origin for subsequent statements. The format for the ORG statement is as follows:

ORG     expression


where

expression must be an absolute or simple relocatable expression without any forward references. Only absolute addresses or symbol values in the current segment may be used.

When an ORG statement is encountered, the assembler calculates the value of the expression and changes the location counter for the current segment. If the ORG statement occurs in an absolute segment, the location counter is assigned the absolute address value. If the ORG statement occurs in a relocatable segment, the location counter is assigned the offset of the specified expression.

The ORG directive changes the location counter but does not produce a new segment. A possible address gap may be introduced in the segment. With absolute segments, the location counter may not reference an address prior to the base address of the segment.


MOV 


start: MOV SP,#?STACK-1 ; assign stack at beginning





call

함수호출


ECODE CODE,  XDATA HDATA

http://www.keil.com/support/man/docs/is51/is51_ov_extmemorylayout.htm

그림~



SJMP

Program Addresses

Program addresses are absolute or relocatable expressions with the memory class CODE or ECODE. Typically program addresses are used in jump and call instructions. For indirect jumps or calls it is required to load a program address in a register or a jump table. The following jumps and calls are possible:


SJMP

JZ

JNZ

Relative jumps include conditional jumps (CJNE, DJNZ, JB, JBC,

JC, …) and the unconditional SJMP instruction. The addressable offset

is –128 to +127 bytes from the first byte of the instruction that follows

the relative jump. When you use a relative jump in your code, you must

use an expression that evaluates to the code address of the jump

destination. The assembler does all the offset computations. If the

address is out of range, the assembler will issue an error message.



ACALL

AJMP

In-block jumps and calls permit access only within a 2KByte block of

program space. The low order 11 bits of the program counter are

replaced when the jump or call is executed. For Dallas 390 contiguous

mode the block size is 512KB or 19 bits. If ACALL or AJMP is the

last instruction in a block, the high order bits of the program counter

change and the jump will be within the block following the ACALL or

AJMP.



LCALL

LJMP

Long jumps and calls allow access to any address within a 64KByte

segment of program space. The low order 16 bits of the program

counter are replaced when the jump or call is executed. For Dallas 390

contiguous mode: the block size is 16MB or 24 bits. One Philips

80C51MX and Intel/Atmel WM 251: if LCALL or LJMP is the last

instruction in a 64KByte segment, the high order bits of the program

counter change and the jump will into the segment following the

LCALL or LJMP.


ECALL

EJMP

Extended jumps and calls allow access within the extended program

space of the Intel/Atmel WM 251 or Philips 80C51MX.


CALL

JMP

Generic jumps and calls are two instruction mnemonics that do not

represent a specific opcode. JMP may assemble to SJMP, AJMP,

LJMP or EJMP. CALL may assemble to ACALL, LCALL or

ECALL. These generic mnemonics always evaluate to an instruction,

not necessarily the shortest, that will reach the specified program


DPTR     Data pointer


Instruction Sets

This section lists the instructions of all x51 CPU variants in alphabetical order.

The following terms are used in the descriptions.



MOV DPT, #data16

Load Data Pointer with 16-bit constant


ret



DJNZ




반응형

'나머지 > IT개발.잡다한것.' 카테고리의 다른 글

DWORD and WORD  (0) 2012.09.27
glue logic psen, read signal  (1) 2012.09.26
EQU SET  (0) 2012.09.25
8051 XDATA IDATA DATA FX2  (0) 2012.09.25
SYNCDELAY  (0) 2012.09.24