Write an HC11 assembly language program segment that starts

Write an HC11 assembly language program segment that starts at memory address $1000. checks bits 0, 3, 4.and 7 at memory address $3000, and if these bits are 1. jumps to address $8000.

Solution

In our previous example (LDAA #$1000), the hex value $1000 is loaded into the A register. This method of loading data into the register is called immediate addressing, because the data to be loaded is located \"immediately\" in the instruction itself. Immediate addressing is commonly used to load a known piece of data into a register.

There are other ways to address data bytes that need to be operated on. These different methods are known as addressing modes. Other than the immediate addressing mode, most addressing modes provide ways of accessing data that is stored somewhere in memory.

The extended addressing mode is one way to access data stored in memory. In this mode, the 16-bit address of a memory byte is specified in the instruction. For example, the instruction

will load the A register with the contents of memory location $1004. This instruction uses three bytes of memory: one byte is the op-code, and two more bytes are needed to specify the 16-bit memory address

In the direct mode, only one byte of address data is required to specify the memory address, since it is known to be in the first 256 bytes of memory. Instructions using direct addressing may require only two bytes: one for the op-code, and one for the address information. They execute in fewer cycles as a result of this savings. The 68HC11 assembler will automatically choose the direct addressing mode if the address specified is in the range $00 to $FF. Extended addressing could also be used to access this portion of memory, but it would rarely be preferable.

The indexed addressing mode uses the X or Y register as a pointer into memory. The value contained in the index register and an offset byte are added to specify the location of the desired memory byte or word.

Consider the following example: Suppose the X register currently has the value $1000. Then the instruction

will load the A register with the contents of location $1000, and the instruction

will load the A register with the contents of location $3000

The offset value is contained in one byte of data, and only positive or zero offsets are allowed. This means that only offsets in the range of 0 to 255 decimal are possible.

Direct

Data is located in RAM (within addresses $0000 to $00FF). One byte is used to specify which RAM location is to be used. Example: STAA $80 stores the A register to the memory location $1000

Extended

Location of data is specified by a 16-bit address given in the instruction. Example: STAA #$1000 stores the contents of the A register at memory location $1000.

Relative

Location is specified by an offset value from the address of the instruction currently being executed. Example: BRA 5 causes a branch to be formed that skips five bytes ahead in the instruction stream. Relative addressing is only used in branching instructions. Offsets range in value from -128 to +127, allowing jumps both forward and backward in the instruction stream

ORG 0

VAR1 RMB 1

ORG $2000

VAR2 RMB 1

ORG $3000

ldaa VAR1 ;

access a zero page variable ldaa VAR2 ; access a variable anywhere in memory

REGBS EQU $1000 ; location of on-board peripherals

ldx #REGBS ; load X with a base address

bclr %00000010 0,X
; clear bit 1 of portA and ;

leave bits 0,2-7 unchanged

 Write an HC11 assembly language program segment that starts at memory address $1000. checks bits 0, 3, 4.and 7 at memory address $3000, and if these bits are 1

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site