Assembly Language Computer language hierarchy High Level Language

  • Slides: 16
Download presentation
Assembly Language

Assembly Language

Computer language hierarchy • High Level Language • Compiled or interpreted • One statement

Computer language hierarchy • High Level Language • Compiled or interpreted • One statement maps to one or more assembly language statement • Assembly language • Assembled • One statement maps to one machine language instruction • Machine language • Loaded directly into the processor memory • One statement maps to one or more RTL statements

Computer language hierarchy • You can toss in the scripting languages (PERL, Python, PHP,

Computer language hierarchy • You can toss in the scripting languages (PERL, Python, PHP, VBScript…) • You can toss in the interpreted languages (BASIC, Haskell, Lisp, Forth) • And other categories • The seem to fit somewhere between HLL and Assembly but don’t run directly on the hardware (virtual machine/interpreter)

Assembly language • This is as close as you ever get to the hardware

Assembly language • This is as close as you ever get to the hardware (without actually keying in binary values – which no one ever does anymore) • Requires a major shift in mindset from programming HLLs

Programming • In HLL programming you concern yourself with variables, datatypes, and control statements

Programming • In HLL programming you concern yourself with variables, datatypes, and control statements – int, float, char, if, for, while, arrays, etc. • In assembly language programming you concern yourself with memory and instruction – RAM, ROM, registers, instruction classes, addressing modes

Programming • In HLL programming you concern yourself with keywords and grammars – Statements,

Programming • In HLL programming you concern yourself with keywords and grammars – Statements, expressions, etc. • In assembly language programming you concern yourself with mnemonics and circuit components – Instruction names, arithmetic units, control units, etc.

Programming • In HLL programming you sit down with a “how to” textbook to

Programming • In HLL programming you sit down with a “how to” textbook to guide you • In assembly language programming you sit down with a chip specification document to guide you

Programming • In HLL programming you might be able to estimate how long a

Programming • In HLL programming you might be able to estimate how long a program will take to run and how much memory it will use • In assembly language programming you can calculate how long a program will take to run and how much memory it will use

Assembly programming • You must have an understanding of the architecture on which you

Assembly programming • You must have an understanding of the architecture on which you are running your program • Each architecture [or family] has it’s own assembly language – The language is intimately tied to the design of the architecture

The 8051 architecture • • • 8 -bit CPU with A (accumulator) and B

The 8051 architecture • • • 8 -bit CPU with A (accumulator) and B registers 16 -bit program counter and data pointer 8 -bit program status word 8 -bit stack pointer Internal ROM Internal RAM – – • • Four register banks of 8 registers each Sixteen bytes of bit addressable locations Eighty bytes of general purpose data memory Thirty two input/output pins Two 16 -bit timer/counters Various control registers Serial port Interrupt sources

The 8051 instruction set • Instruction classes – Arithmetic operations – Logical operations –

The 8051 instruction set • Instruction classes – Arithmetic operations – Logical operations – Data transfer – Boolean variable manipulation – Program branching

The 8051 instruction set • The processor status word (PSW) – Carry flag –

The 8051 instruction set • The processor status word (PSW) – Carry flag – Auxiliary carry flag – General purpose flags (2) – Register bank selector (2 bits) – Overflow flag – Parity flag

The 8051 instruction set • Addressing modes – – – – – Register Direct

The 8051 instruction set • Addressing modes – – – – – Register Direct Indirect-register Constant 8 -bit Constant 16 -bit Address 11 -bit Relative Bit

Addressing modes • Rn where 0 ≤ n ≤ 7 – the contents of

Addressing modes • Rn where 0 ≤ n ≤ 7 – the contents of register n; • 0 x 00 (or other hex number) – the contents of a memory location • @Ri where 0 ≤ i ≤ 1 – indirect, register holds the memory address • #0 x 00 (or other hex number) – 8 -bit constant number • #0 x 00 16 (or other hex number) – 16 -bit constant number • There a few others but these are the most commonly used modes

Data transfer instructions • MOV op-code • Various operands dependant on desired addressing mode

Data transfer instructions • MOV op-code • Various operands dependant on desired addressing mode – Some examples: MOV MOV MOV A, R 0 A, #0 x 00 A, @R 0 R 0, A ; ; ; A = R 0 A = memory[0] A = memory[R 0] R 0 = A

Simulator • We don’t have an 8051 processor • The next best thing is

Simulator • We don’t have an 8051 processor • The next best thing is a simulator • Download Ed. Sim 51 from Ed. Sim 51 – This is a Java executable (. jar) file that runs on both Windows and Mac. OS • Documentation is available on the download site