1 / 12

ECE 447: Lecture 16

ECE 447: Lecture 16. Assembler Directives. ECE 447: Constants. C. assembly. decimal 23 23 o r 23D hexadecimal 0xf9 $f9 or 0f9H binary — %1011 or 1011B octal 067 @67 or 67O character ’w’ ’w’. Special constants. $0A $09 $07.

fisseha
Download Presentation

ECE 447: Lecture 16

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ECE 447: Lecture 16 Assembler Directives

  2. ECE 447: Constants C assembly decimal 23 23 or 23D hexadecimal 0xf9 $f9 or 0f9H binary — %1011 or 1011B octal 067 @67 or 67O character ’w’ ’w’ Special constants $0A $09 $07 ‘\n’ - new line ‘\t’ - horizontal tab ‘\a’ - alert (bell)

  3. ECE 447: Defining a Constant assembler C #define PORTB 0x1004 PORTB EQU $1004 DELAY SET 100 ……. DELAY SET 200 #define DELAY 100 ………. #undef DELAY #define DELAY 200

  4. ECE 447: Assembler Directives Declaration of global uninitialized variables rmb - reserve memory bytes assembler C c: rmb 1 char c; or unsigned char c; int k; or unsigned int k; or char * k; k: rmb 2 m: rmb 4 long m; or float m; array1: rmb 20*2 int array1[20]; unsigned char array2 [5][4]; array2: rmb 5*4

  5. ECE 447: Assembler Directives Declaration of global initialized variables fcb - form constant byte fdb - form double byte C assembler char c = -1; or unsigned char c = 255; c: fcb $ff int k=-1; or unsigned int k=0xffff; k: fdb $ffff m: fdb $0010, $0000 long m = 0x00100000; array1: fdb 3, 12, 87 int array1[3] = {3, 12, 87};

  6. ECE447: Assembler Directives Declaration of global initialized character arrays (strings) fcc - form constant character assembler C char string1[] = “ECE447” string1: fcc “ECE447” fcb 0 string2: fcc 3, ABC fcb 0 char string2 [4] = “ABC”;

  7. ECE447: Assembler Directives Defining external variables and functions assembler C int a; int func1() { ……. } .global a a: rmb 2 (outside of any function) .global func1 func1: ……… or func1 …………

  8. ECE 447: Assembler Directives Defining static variables and functions C assembler static int a; static int func1() { ……. } a rmb 2 (outside of any function) func1 ………

  9. ECE 447: Assembler Directives assembler C int a = 3; int * b; a fcb 3 b rmb 2 a &a a #a LDX #a STX b LDX #b LDD #4 STD 0,X b = & a; *b = 4;

  10. ECE 447: Assembler Directives Defining a macro #define MAX(a, b) ((a>=b)?a:b) MAX %MACRO a , b, cont LDD a CPD b BGE cont LDD b cont %ENDM

  11. ECE 447: Assembler Directives Including a file #include <stdio.h> %INCLUDE “stdio.h” %INCLUDE “mydefs.h” #include “mydefs.h” Conditional compilation/assembly #if SYSTEM == MSDOS …….. #else ……. #endif %if SYSTEM == MSDOS ………. %else …….. %endif

  12. ECE 447: Linker Oriented Directives Putting Code in Specific Sections section .text section .data section .bss Manually Placing Code in Memory org $C000 Indicating GMU assembly .mri 1 Telling Assembler where the end of ASM file is end

More Related