Understanding Assembler: Hand Assembling and Creating Assembler Code, Slides of Microprocessor and Interfacing

An overview of hand assembling assembler code and creating assembler code files. It covers the process of translating high-level language (hll) to assembler, editing assembler language programs, and the role of an assembler in producing machine code. Understanding hand assembly is essential for computer engineers to gain a complete understanding of microprocessor or microcontroller architecture.

Typology: Slides

2012/2013

Uploaded on 05/07/2013

anjushree
anjushree 🇮🇳

4.4

(54)

147 documents

1 / 22

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture Overview
Editing and Assembler
So far have covered the assembler language
instructions and translating a program to
assembler
Now
Creating the assembler code file
What goes on during the execution of the assembler
REF: Chapter 4.10 and 4.11
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download Understanding Assembler: Hand Assembling and Creating Assembler Code and more Slides Microprocessor and Interfacing in PDF only on Docsity!

Lecture Overview

• Editing and Assembler

– So far have covered the assembler languageinstructions and translating a program to

assembler

– Now

• • Creating the assembler code fileWhat goes on during the execution of the assembler

• REF: Chapter 4.10 and 4.

Assembler language files

• Translated HLL to assembler.

• Edit the assembler language program into aneditor.

– This is sometimes called a source file

• What is done with the source file? – It is input as a data file to a program called and

– assembler.Most times you simply use a simple text editor and set

– up the various fields at tabs.The file is save as name.asm typically.

And a machine code listing

Another example

Previous example

• The code – ORG $

– – unkwnguess FCBRMB 1 47 location for guess varset unknown value

– – incr RMBORG 1 $C000 location for increment var

– – LDAA #50STAA guess

– – LSRASTAA incr first guess is 50divide by 2

– – LSRBLDAB incrset to 25

Previous ex continued

– – tol CMPABEQ unknwndone

– – * guess is too highBLT low

– – incadj SBALSRB subtract incrementincr = incr/

– – BCCINCB ceilgd carry was 1 so make ceil

– – ceilgdlow BRAABA tol add increment

– – done BRASTAA incadjguess done

Hand assembly continued

• The lines hand assemble

– ORG $C

– LDAA

– addr contents

– $C000 86 32

– $32 is 0011 0010

– and hexidecimal

– for 50 (32+16+2)

The next instruction

– STAA guess

– $C002 $97 11

– As address of

– Guess is $

And then

• LDAB incr

• $C007 D6 12

• LSRB

• $C009 54

And then

• tol CMPA unkwn

• $C00A 91 10

• As unkwn is at memory

• Location $

• tol will have value of

• $C00A

And then

– SBA

– $C010 10

– incadj LSRB

– $C011 54

And then

– – $C012 24 rrjumpBCC ceilgd

– – $C014 5CINCB

– – $C015ceilgd 20 back_to_tolBRA tol

– will have value of $C014 so rrjump gets value of $01ceilgd had value $C015 and at time of BCC execution, the PC

– back to location $C00A from location $C017 is a negative 13back to tol will need a negative offset. The PC for calculation

– bytes.Or back_to_tol^ 0001 0111 – 0000 1010 = gets $F3 WHY?^ 0000 1101

The full code

  • – (^) Loc contentsORG $0010 comment
  • – (^) $0010 47 ORGunkwn FCB 47 $
  • – $0011 00$0012 00 guessincr RMB 1RMB 1
  • – (^) $C000 86 64ORG LDA #100 $C
  • – $C002 97 11$C004 44 LSRASTAA guess
  • – $C005 97 12$C007 D6 12 LDAB incrSTAA incr
  • – $C009$C00A 91 10 54 LSRBtol CMPA unkwn
  • $C00C 27 0E BEQ done

  $C00F 2D 09$C010 10 BLT lowSBA   $C011$C012 24 01 54 incadj LSRBBCC ceilgd   $C014 5C$C015 20 F3 (^) ceilgd BRAINCB tol   $C017 18$C018 20 F7 low ABABRA incadj  $C01A 97 10 done STAA guess   Symbol tableunkwn $0010 tol $C00A low $C   guessincr $0012$0011 incadj $C011ceilgd $C015 done $C01A

Lecture summary

• Have looked at hand assembly

• a very useful skill