Chapter8 Examples

Chapter8 Examples - Summer 2008 ELEC 2220 – Computer...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Summer 2008 ELEC 2220 – Computer Systems Structured Assembly Language Programming Text: Chapter 8 Summer 2008 ELEC 2220 Computer Systems – V. P. Nelson Summer 2008 ELEC 2220 Computer Systems – V. P. Nelson Summer 2008 ELEC 2220 Computer Systems – V. P. Nelson Summer 2008 ELEC 2220 Computer Systems – V. P. Nelson Program Header Program Element Program Example Program Header ; MC68HC12 Assembler Example ; ; This program is to demonstrate a ; readable programming style. ; It counts the number of characters ; in a buffer and stores the result in ; a data location. It then prints ; the number of characters using ; D-Bug12 Monitor routines. ; Source File: M6812EX1.ASM ; Author: F. M. Cady ; Created: 5/15/97 ; Modifications: None Program Element Program Example Program Header ; Modifications: None Summer 2008 ELEC 2220 Computer Systems – V. P. Nelson Equates Program Element Program Example System Equates. ; Monitor Equates out2hex:EQU $FE16 ; Output 2 hex nibbles putchar:EQU $FE04 ; Print a character ; I/O Ports PORTH: EQU $24 ; Port H address PORTJ: EQU $28 ; Port J address Constant Equates ; Constant Equates CR: EQU $0d ; CR code LF: EQU $0a ; LF code NULL: EQU $00 ; End of ASCII string NIL: EQU 0 ; Initial data value Memory Map Equates ; Memory Map Equates PROG: EQU $4000 ; Locate the program DATA: EQU $6000 ; Variable data areas STACK: EQU $8000 ; Top of stack Program Element Program Example System Equates. Constant Equates Memory Map Equates STACK: EQU $8000 ; Top of stack Summer 2008 ELEC 2220 Computer Systems – V. P. Nelson Program Location Program Element Program Example Program Code Origination ORG PROG ; Locate the program Program Element Program Example Program Code Origination ORG PROG ; Locate the program Summer 2008 ELEC 2220 Computer Systems – V. P. Nelson Program Initialization Program Element Program Example Stack Pointer Initialization lds #STACK ; Initialize stack pointer Variable Data Initialization ; Initialize the data area to zero clr Counter Program Element Program Example Stack Pointer Initialization lds #STACK ; Initialize stack pointer Variable Data Initialization clr Counter Summer 2008 ELEC 2220 Computer Systems – V. P. Nelson Main Program Body Program Element Program Example Main program body ; Count the characters in the string ldd #STRING jsr count_em ; Output the result string ldd #RESULT ; Point to the string jsr outstr ; Output the counter ldab counter jsr [out2hex,PCR] ; Now output a CRLF jsr CRLF Program Element Program Example Main program body jsr CRLF Summer 2008...
View Full Document

This note was uploaded on 09/23/2011 for the course ELEC 2220 taught by Professor Staff during the Summer '08 term at Auburn University.

Page1 / 28

Chapter8 Examples - Summer 2008 ELEC 2220 – Computer...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online