ELE22MIC Lecture 8 - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

ELE22MIC Lecture 8

Description:

Understanding of Other languages & better ability to optimise ... Gnu Assembler source can be ... from a 'DOS box' Start- Run. Command ; starts a DOS box ... – PowerPoint PPT presentation

Number of Views:91
Avg rating:3.0/5.0
Slides: 19
Provided by: paul192
Category:

less

Transcript and Presenter's Notes

Title: ELE22MIC Lecture 8


1
ELE22MIC Lecture 8
  • Instruction Set Part 6
  • ASll
  • Why Assembler?
  • JSR / RTS (Call / Return)
  • Interrupt processing (SWI/RTI)
  • DEMUX

2
Why Assembler?
  • Speed
  • Control
  • Access special instructions
  • Code compactness
  • Comprehension of CPU operation
  • Understanding of Other languages better ability
    to optimise

3
Which Assembler?
  • Is assembly language the same for all computers?
  • NO !
  • MASM/TASM for the 80x86
  • AS11 for the HC11
  • Macro for Vax 11/780

4
The GNU Assembler option.
  • Gnu Assembler source can be assembled using GCC
    eg
  • gcc -c -alh file.s where file.s is AS assembly
    code
  • Large number of Machine-specific variations
  • Gnu Assembler source can be created using GCC by
    compiling a C program, and generating assembly
    listing. eg
  • gcc -c -g -O -v -Wa,-alh,-L file.c

5
Procedure Call Standards
  • All registers used in the procedure should be
    preserved, apart from return parameter registers,
    via use of push/pop instructions
  • Any required parameters should be fully
    documented in a descriptive section before the
    routine.
  • Returned parameters should be described
  • The objective of the routine should be described,
    and any unclear side effects.

6
M68HC11 AS11 Assembler
  • Runs on any IBM PC and cross-assembles code for
    the M68HC11 microcontroller
  • It produces an ASCII text file called a S19
    Record which may be loaded into the M68HC11
    memory.
  • The assembler
  • converts the programs mnemonics to opcodes
  • converts its operands to operand codes.

7
AS11 Constants (1)
  • Constants are numerical values that do not change
    during the program execution.
  • Decimal constants must be in the range
    -32768 .. 65536
  • Hexadecimal constants must begin with a , and be
    a maximum of 4 digits from the symbol set 0..9
    and A..F.

8
AS11 Constants (2)
  • Binary constants are specified by the sign, and
    a maximum of sixteen 1s 0s
  • Useful to make programs more readable
  • Single ASCII character constants are preceded by
  • Octal constants _at_ then digits 0..7
  • _at_377 FF 11111111 255
  • _at_101 41 65 A

9
AS11 Labels
  • A Label is defined as either
  • The destination for Jump or Branch instruction
  • A way of referring to the location of a variable
    or constant.
  • Differences in label positions can be used to
    calculate
  • data sizes
  • relative branch distances

10
AS11 Expressions
Valid algebraic operators used in expressions are
Add - Subtract Multiply / Divide Modu
lo Bitwise AND Bitwise OR Bitwise Exclusive
OR Expressions are evaluated left to right.
Arithmetic is done using signed twos complement,
integer precision. The assembler evaluates
expressions and generates constants.
11
AS11 Assembler Directives (1)
  • Program counter origin
  • ORG Set program counter to origin
  • Symbol Definition
  • EQU Equate
  • Variable definition
  • RMB Reserve Memory Byte

12
AS11 Assembler Directives (2)
  • Constant definition
  • BSZ Block Storage of Zeroes
  • FCB Form Constant Byte
  • FCC Form Constant Character
  • FDB Form Double Byte
  • FCC Form Constant Characters
  • FILL Fill Memory
  • ZMB Zero Memory Byte

13
AS11 Assembler Directives (3)
OPT Assembler Output Options nol Turn off
output listing l Turn on output listing
(default) noc Disable cycle counts in listing
(default) c Enable cycle counts in listing
(clear total cycles) contc Re-enable cycle counts
(don't clear total cycles) cre Enable printing
of a cross reference table s generate a symbol
table PAGE Top of page Usage example as11
test.asm -l cre gt test.lst
14
AS11 Listing (1)
0001 Listing 13.21 0002
Shows assembly code
produced by compiling the C source code 0003
of Listing 13.20 with
additional comments manually inserted 0004
by the author. Note that FP
frame pointer and each type int 0005
variable uses two bytes of space.
0006 0007
Assembly mnemonics are lowercase
because that's the 0008
way ICC11 creates them. 0009
0010 opt
s 0011 2000 org
2000 0012 _main 0013
mvar2 -gt 4,x 0014
mvar1 -gt 6,x 0015
4 pshx's to create main
frame 0016 2000 3c pshx set up
space for parameter passing 0017 2001 3c
pshx 0018 2002 3c
pshx unsigned mvar2 - space for mvar2 0019 2003
3c pshx unsigned mvar1 - space
for mvar1 0020 2004 30
tsx SP1-gtIX, assign FP for main 0021 2005 cc
00 05 ldd 5 mvar1 5 0022 2008 ed
06 std 6,x 0023 200a cc 00 0f
ldd 15 mvar2 15 0024 200d ed 04
std 4,x 0025 200f ec 06 ldd
6,x callme(mvar1, mvar2) 0026 2011 ed 00
std 0,x - store arguments to 0027 2013
ec 04 ldd 4,x pass parameters
to callme 0028 2015 ed 02 std
2,x 0029 2017 bd 20 24 jsr _callme
- push return address onto stack 0030
and invoke function 0031
201a 30 tsx SP1-gtIX, reassign
FP for main 0032 201b ec 04 ldd
4,x mvar1 mvar2

15
AS11 Listing (2)
0033 201d ed 06 std 6,x 0034 201f
38 pulx 4 pulx's to remove main
frame 0035 2020 38 pulx 0036
2021 38 pulx 0037 2022 38
pulx 0038 2023 39
rts and return to call by monitor 0039
L1.callex 0040
_callme 0041
var2 -gt 0,x - local variables 0042
var1 -gt 2,x 0043
arg2 -gt 8,x - arguments 0044
arg1 -gt 6,x 0045
2 pshx's to create local variable
space 0046 in callme
frame 0047 2024 3c
pshx unsigned int var1 0048 2025 3c
pshx unsigned int var2 0049 2026 30
tsx SP1-gtIX, assign FP for
callme 0050 2027 ec 06 ldd
6,x var1 2 arg1 0051 2029 05
lsld 0052 202a ed 02 std 2,x 0053
202c ec 08 ldd 8,x var2 2
arg2 0054 202e 05 lsld 0055 202f
ed 00 std 0,x 0056 2031 ec 02
ldd 2,x 0057 2033 e3 00
addd 0,x arg2 var1 var2 0058 2035 ed 08
std 8,x 0059 2037 38
pulx 2 pulx's to remove local variables 0060
2038 38 pulx 0061 2039 39
rts and return to calling routine 0062
L2.callex L1.callex
2024 L2.callex 203a _callme 2024 _main
2000

16
AS11 S19 (2)
S12320003C3C3C3C30CC0005ED06CC000FED04EC06ED00EC04
ED02BD202430EC04ED063802 S11D2020383838393C3C30EC0
605ED02EC0805ED00EC02E300ED08383839DE S9030000FC

17
Running AS11 from a DOS box
  • Start-gtRun
  • Command starts a DOS box
  • CD d\...\AS11 wherever as11.exe is
  • as11 test.asm -l cre
  • -l means create a listing
  • cre means Cross REference listing

18
Interrupt Vectors
VECTORS EQU FFD6 HC11 Vectors start at
FFD6 ORG VECTORS VSCI FDB JSCI Serial
Communications Interface VSPI FDB JSPI Serial
Peripheral Interface Transfer Complete VPAIE FDB J
PAIE Pulse Accumulator Input
Edge VPAO FDB JPAO Pulse Accumulator
Overflow VTOF FDB JTOF Timer
Overflow VTOC5 FDB JTOC5 Timer Output Compare
5 VTOC4 FDB JTOC4
4 VTOC3 FDB JTOC3
3 VTOC2 FDB JTOC2
2 VTOC1 FDB JTOC1
1 VTIC3 FDB JTIC3
Timer Input Capture 3 VTIC2 FDB JTIC2
2 VTIC1 FDB JTIC1
1 VRTII FDB JRTII
Real Time Interrupt VIRQ FDB JIRQ IRQ
VXIRQ FDB JXIRQ XIRQ VSWI FDB JSWI
Software Interrupt VILLOP FDB JILLOP Illegal
op VCOP FDB JCOP Computer Operating Properly -
Watchdog Timeout VCMF FDB JCMF Clock Monitor
Fail VRES FDB E000 RESET address for Buffalo
monitor END OF FILE HC11VEC.ASM
Write a Comment
User Comments (0)
About PowerShow.com