100 likes | 232 Views
ECE 447: Lecture 13. Assembler Directives. ECE 447: Defining a Constant. Assembly language. C. #define PORTB 0x1004. PORTB EQU $1004. DELAY SET 100 ……. DELAY SET 200. #define DELAY 100 ………. #undef DELAY #define DELAY 200. ECE 447: Assembler Directives.
E N D
ECE 447: Lecture 13 Assembler Directives
ECE 447: Defining a Constant Assembly language C #define PORTB 0x1004 PORTB EQU $1004 DELAY SET 100 ……. DELAY SET 200 #define DELAY 100 ………. #undef DELAY #define DELAY 200
ECE 447: Assembler Directives Declaration of global uninitialized variables rmb - reserve memory bytes Assembly language C cu: rmb 1 char cu; or unsigned char cu; int ku; or unsigned int ku; or char * ku; ku: rmb 2 mu: rmb 4 long mu; or float mu; a1u: rmb 20*2 int a1u[20]; unsigned char a2u[5][4]; a2u: rmb 5*4
ECE 447: Assembler Directives Declaration of global initialized variables fcb - form constant byte fdb - form double byte Assembly language C char ci = -1; or unsigned char ci = 255; ci: fcb $ff int ki=-1; or unsigned int ki=0xffff; ki: fdb $ffff mi: fdb $abcd,$ef10 long mi = 0xabcdef10; a1i: fdb 3,12,87 int a1i[3] = {3, 12, 87};
ECE447: Assembler Directives Declaration of global initialized character arrays (strings) fcc - form constant character C Assembly language char s1[] = “ECE447” s1: fcc “ECE447” fcb 0
ECE447: Assembler Directives Defining external variables and functions Assembly language C int a; int func1() { ……. } .global a a: rmb 2 (outside of any function) .global func1 func1: ………
ECE 447: Assembler Directives Defining static variables and functions C Assembly language static int a; static int func1() { ……. } a rmb 2 (outside of any function) func1 ………
ECE 447: Assembler Directives C Assembly language unsigned char var1 = 0xAB; unsigned char * ptr1; var1: fcb $AB ptr1: rmb 2 var1 &var1 var1 #var1 LDX #var1 STX ptr1 LDX ptr1 LDAA #4 STAA 0,X ptr1 = & var1; *ptr1 = 4;
ECE 447: Assembler Directives Including a file #include <stdio.h> #include “stdio.h” #include “mydefs.h” #include “mydefs.h”
ECE 447: Linker Oriented Directives Putting Code in Specific Sections section .text section .data Manually Placing Code in Memory org $C000 Indicating 68HC11 assembly language convention .mri 1 Telling Assembler where the end of ASM file is end