Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Segments and Pseudo Operations Program Development.

Similar presentations


Presentation on theme: "1 Segments and Pseudo Operations Program Development."— Presentation transcript:

1 1 Segments and Pseudo Operations Program Development

2 2 Format of the source code Each line of code is divided into fields: Label Field Operation Field Operand Field Comment Field

3 3 Code and Data Segments We can organize the code into blocks called segments Segments specify sections of code, data, and reserved areas of memory Segments are useful for modularized program development

4 4 Segments

5 5 Pseudo-Instructions (1) Pseudo-instructions are directives for the Assembler We have already seen some of them ORG - defines the absolute address of a segment ORG $9000 ;set origin of text segment to $9000 EQU - defines an equivalent symbol for a value ONE EQU $01 PORTB EQU $1004 END – delimits the end of the assembly RMB – stands for “reserve memory byte(s)”. It allocates a specified number of bytes. varname RMB 2 DS – stands for “define space”. It is the same as RMB varname DS 2

6 6 Pseudo Instructions (2) FCB – stands for “form constant byte(s)”. It allocates byte(s) of storage with initialized values addrfirstval FCB $01,250,@373,%111001101 FCB $23 DB – stands for define byte(s). It is the same as FCB FDB – stands for “form double byte(s)”. It is a 16-bit version of FCB FDB $0001,$1234,$FFFA DW – stands for “define word”. It is the same as FDB FCC – stands for “form constant character(s)” and it is used to allocate and initialize memory for storage of a string addrfirstchar FCC “some string” FCC “Alarm 5A high!”

7 7 Example * program to drive a stepper motor size equ 4 PORTB equ $1004 ;PB3-PB0 to stepper org $9000 main ldaa #size ldx #steps;address at which $05 is located step ldab 0,x inx stab PORTB; step the motor deca bne step bra main stepsfcb 5,6,10,9;output sequence org$FFFE fdb main end

8 8 Pseudo Instructions (3) FILL – sets a number of bytes to a specified value FILL $FF 16 ZMB – stands for “Zero Memory Bytes” and initialize a specified number of memory bytes to zero ZMB 16 BSZ – stands for “Block Store Zeros and it the same as ZMB BSZ 16

9 9 Assembly two-pass Process For an assembler to understand labels and symbols, it must work through the source code twice. It follows as a two-pass process After the first step the assembler build a “symbol table” that gives the address of each label and symbol.

10 10 Assembler options and preprocessor directives Assembler options and preprocessor directives are assembler specific Assembler options must occur at the beginning of the source code, and start in column one of the code with a $ sign. The preprocessor directives follows the assembler options and begin with a %. The preprocessor directives tell the assembler to do something before beginning the assembly process %INCLUDE “d:\include\iolib.h”


Download ppt "1 Segments and Pseudo Operations Program Development."

Similar presentations


Ads by Google