Editing and Assembler - Microprocessor Based Systems - Lecture Slides, Slides for Microprocessor and Interfacing. Punjab Engineering College

Microprocessor and Interfacing

Description: The important point in the lecture slides of the Microprocessor Based Systems are:Editing and Assembler, Covered, Instructions, Translating, Assembler Code File, Execution, Input, Data File, Fields, Various
Showing pages  1  -  2  of  22
The preview of this document ends here! Please or to read the full document or to download it.
Document information
Embed this document:
Slide 1

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

Assembler language files

• Translated HLL to assembler. • Edit the assembler language program into an

editor. – 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.

Docsity.com

What is output from the assembler

• Input is your assembler language program

• The output will look something like this

Docsity.com

And a machine code listing

Docsity.com

Another example

Docsity.com

Hand assembly

• Knowing how to hand assemble assembler code is useful knowledge.

• This is the same work the assembler does. – What value does knowing this help a computer

engineer? It goes to knowledge base and a complete understanding of a processors (microprocessor or microcontroller) architecture. It is essential to being able to design and implement front line embedded systems requiring very accurate timing.

Docsity.com

Previous example • The code

– ORG $0010 – unkwn FCB 47 set unknown value – guess RMB 1 location for guess var – incr RMB 1 location for increment var – ORG $C000 – LDAA #50 – STAA guess – LSRA divide by 2 – STAA incr first guess is 50 – LDAB incr – LSRB set to 25

Docsity.com

Previous ex continued – tol CMPA unknwn – BEQ done – BLT low – * guess is too high – SBA subtract increment – incadj LSRB incr = incr/2 – BCC ceilgd – INCB carry was 1 so make ceil – ceilgd BRA tol – low ABA add increment – BRA incadj – done STAA guess done

Docsity.com

Hand assembly

• Assembler directives – ORG $0010 – unknwn FCB 47 set unknown value – guess RMB 1 location for guess var – incr RMB 1 location for increment var

• Assembler output – Label LOC Contents($) – unkwn $0010 $2F – guess $0011 – incr $0012

Docsity.com

Hand assembly continued

• The lines hand assemble – ORG $C000 – LDAA #50 – addr contents – $C000 86 32 – – $32 is 0011 0010 – and hexidecimal – for 50 (32+16+2)

Docsity.com

The next instruction

– STAA guess

– $C002 $97 11

– As address of – Guess is $0011

Docsity.com

And then

– LSRA – $C004 44 – STAA incr $C005 97 12

Docsity.com

And then

• LDAB incr • $C007 D6 12 • LSRB • $C009 54

Docsity.com

And then

• tol CMPA unkwn

• $C00A 91 10

• As unkwn is at memory • Location $0010

• tol will have value of • $C00A

Docsity.com

And then

• BEQ done • BLT low

• $C00C 27 rrdone • $C00E 2d rrlow

• Where the relative

address will be filled in after the first pass.

Docsity.com

And then

– SBA – $C010 10 – incadj LSRB – $C011 54

Docsity.com

And then – BCC ceilgd – $C012 24 rrjump – INCB – $C014 5C – ceilgd BRA tol – $C015 20 back_to_tol

– ceilgd had value $C015 and at time of BCC execution, the PC

will have value of $C014 so rrjump gets value of $01 – back to tol will need a negative offset. The PC for calculation

back to location $C00A from location $C017 is a negative 13 bytes. 0001 0111 – 0000 1010 = 0000 1101

– Or back_to_tol gets $F3 WHY?

Docsity.com

And finally

– low ABA – $C017 18 – And low has an address of $C017 – so rrlow gets 9 – BRA incadj – $C018 20 to_incadj – incadj was at address $C011 so this is a -9 – or to_incadj getting $F7 – done STAA guess – $C01A 97 10

Docsity.com

The full code – ORG $0010 – Loc contents comment – ORG $0010 – $0010 47 unkwn FCB 47 – $0011 00 guess RMB 1 – $0012 00 incr RMB 1 – ORG $C000 – $C000 86 64 LDA #100 – $C002 97 11 STAA guess – $C004 44 LSRA – $C005 97 12 STAA incr – $C007 D6 12 LDAB incr – $C009 54 LSRB – $C00A 91 10 tol CMPA unkwn – $C00C 27 0E BEQ done

 $C00F 2D 09 BLT low

 $C010 10 SBA

 $C011 54 incadj LSRB

 $C012 24 01 BCC ceilgd

 $C014 5C INCB

 $C015 20 F3 ceilgd BRA tol

 $C017 18 low ABA

 $C018 20 F7 BRA incadj

 $C01A 97 10 done STAA guess

 Symbol table

 unkwn $0010 tol $C00A low $C017

 guess $0011 incadj $C011 done $C01A

 incr $0012 ceilgd $C015

Docsity.com

Lecture summary

• Have looked at hand assembly • a very useful skill

Docsity.com

From the assembler

• Copy of the window

Docsity.com

Assignment

 Get to a THR simulator (will be downloadable from Carmen)

 Enter the program we just hand assembled and confirm the hand coding. (CODE IS ON slide 8 and 9)

 NOTE: page 0 has RAM and page E has ROM for you code. Use the table on page 27 for address of I/O. See example code on webpage.

 Submit a 1/3 to full page writeup on if the code agrees or not, and your level of understanding of what an assembler does. Also capture the simulator window and turn in a copy of the simulator window after you have d h bl

Docsity.com

Docsity is not optimized for the browser you're using. In order to have a better experience please switch to Google Chrome, Firefox, Internet Explorer 9+ or Safari! Download Google Chrome