Presentation is loading. Please wait.

Presentation is loading. Please wait.

ECE 265 – LECTURE 11 Editing and the Assembler (updated 11/11/10) 12/15/2015 1 ECE265.

Similar presentations


Presentation on theme: "ECE 265 – LECTURE 11 Editing and the Assembler (updated 11/11/10) 12/15/2015 1 ECE265."— Presentation transcript:

1 ECE 265 – LECTURE 11 Editing and the Assembler (updated 11/11/10) 12/15/2015 1 ECE265

2 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 12/15/2015 2 ECE265

3 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. 12/15/2015ECE265 3

4 What is output from the assembler  Input is your assembler language program  The output will look something like this 12/15/2015ECE265 4

5 And a machine code listing 12/15/2015ECE265 5

6 Another example 12/15/2015ECE265 6

7 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. 12/15/2015ECE265 7

8 Previous example  The code  ORG $0010  unkwn FCB47 set unknown value  guessRMB 1 location for guess var  incrRMB1 location for increment var  ORG $C000  LDAA #50  STAA guess  LSRAdivide by 2  STAA incr first guess is 50  LDAB incr  LSRB set to 25 12/15/2015ECE265 8

9 Previous ex continued  tolCMPA unknwn  BEQ done  BLT low  * guess is too high  SBAsubtract increment  incadjLSRBincr = incr/2  BCC ceilgd  INCBcarry was 1 so make ceil  ceilgdBRA tol  lowABAadd increment  BRA incadj  doneSTAA guessdone 12/15/2015ECE265 9

10 Hand assembly  Assembler directives  ORG $0010  unknwnFCB47 set unknown value  guessRMB 1 location for guess var  incrRMB1 location for increment var  Assembler output  Label LOC Contents($)  unkwn $0010 $2F  guess $0011  incr $0012 12/15/2015ECE265 10

11 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) 12/15/2015ECE265 11

12 The next instruction  STAA guess  $C002 $97 11  As address of  Guess is $0011 12/15/2015ECE265 12

13 And then  LSRA  $C004 44  STAA incr $C005 97 12 12/15/2015ECE265 13

14 And then  LDAB incr  $C007 D6 12  LSRB  $C009 54 12/15/2015ECE265 14

15 And then  tol CMPA unkwn  $C00A 91 10  As unkwn is at memory  Location $0010  tol will have value of  $C00A 12/15/2015ECE265 15

16 And then  BEQ done  BLT low  $C00C 27 rrdone  $C00E 2d rrlow  Where the relative address will be filled in after the first pass. 12/15/2015ECE265 16

17 And then  SBA  $C010 10  incadjLSRB  $C011 54 12/15/2015ECE265 17

18 And then  BCC ceilgd  $C012 24 rrjump  INCB  $C014 5C  ceilgdBRA 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? 12/15/2015ECE265 18

19 And finally  lowABA  $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  doneSTAA guess  $C01A97 10 12/15/2015ECE265 19

20 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 12/15/2015ECE265 20  $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

21 Lecture summary 12/15/2015ECE265 21  Have looked at hand assembly  a very useful skill

22 From the assembler  Copy of the window 12/15/2015ECE265 22

23 Assignment 12/15/2015ECE265 23  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 done the assemble.


Download ppt "ECE 265 – LECTURE 11 Editing and the Assembler (updated 11/11/10) 12/15/2015 1 ECE265."

Similar presentations


Ads by Google