Presentation is loading. Please wait.

Presentation is loading. Please wait.

MICRO-CONTROLLER MOTOROLA HCS12 Running assembly code Mechatronics Department Faculty of Engineering Ain Shams Univeristy.

Similar presentations


Presentation on theme: "MICRO-CONTROLLER MOTOROLA HCS12 Running assembly code Mechatronics Department Faculty of Engineering Ain Shams Univeristy."— Presentation transcript:

1 MICRO-CONTROLLER MOTOROLA HCS12 Running assembly code Mechatronics Department Faculty of Engineering Ain Shams Univeristy

2 Assembly Directives Commands to the assembler Commands to the assembler Not executable by the microprocessor Not executable by the microprocessor Are not converted to machine codes Are not converted to machine codes Define program constants and reserve space for dynamic variable Define program constants and reserve space for dynamic variable Specifies the end of a program. Specifies the end of a program.

3 Org (origin) org$1000 ldab#$FF;this instruction will be stored in memory starting from location $1000.  Tells the assembler where to place the next instruction/data in memoryExample:

4 equ (equate) loop_countequ50;.” “Informs the assembler whenever the symbol loop_count is encountered, it should be replaced with the value 50.”  Assigns a value to a label.  Makes programs more readable.Example:

5 dc.b (define constant byte) org$800 arraydc.b $11,$22,$33,$44  Define the value of a byte or bytes that will be placed at a given location.Example:

6 dc.w (define constant word) org$800 arraydc.w $AC11,$F122,$33,$F44  Define the value of a word or words that will be placed at a given location.Example:

7 ds (define storage) bufferds100;reserves 100 bytes starting from the location represented by buffer - none of these locations is initialized  Reserves a number of bytes for later use.Example:

8 ds.w (define storage word) Dbufds.w 20;Reserves 20 words (or 40 bytes) starting from the current location counter.  Reserves a number of words for later use.Example:

9 MC68HC12 “Stepper Motor Control” Port T 3|2|1|0$242

10 MC68HC12 “Stepper Motor Control” size equ4; PTTequ$240;Address of port T DDRTequ$242;Data direction register for port T steps:dc.b5,10,9,6 org$4000 ------------------------------------------------------------------ Entry:movb#$FF, DDRT;Set port T wfor output run:ldaa#size;initialize counter in A ldx#steps;Point to the steps in memory step:movb1, x+, PTT;step the motor dbneA, step;Decrement A and check if it’s zero brarun;Always run steps0101 steps +11010 steps +21001 steps +30110

11 Eng. Mohamed Mahmoud Hamdy Eng. Mostafa Ahmed Arafa Prepared by:


Download ppt "MICRO-CONTROLLER MOTOROLA HCS12 Running assembly code Mechatronics Department Faculty of Engineering Ain Shams Univeristy."

Similar presentations


Ads by Google