170 likes | 290 Views
Assembly Microprocessors session 2. ing. Ernst E. Mak MSc. Contents:. Binary numbers, Addition, Subtraction, Two’s complement Starting Deeds, Board, Dipswitches, Editor, Debugger programming structure: Assembly directive: ORG memory designator Labels Statements Operands
E N D
Assembly Microprocessorssession 2 ing. Ernst E. Mak MSc
Contents: • Binary numbers, Addition, Subtraction, Two’s complement • Starting Deeds, Board, Dipswitches, Editor, Debugger • programming structure: • Assembly directive: ORG memory designator • Labels • Statements • Operands • Comments • Deeds Help function • Registers, Flags, Memory, Decimal and Hexadecimal
X-ary Numbers • X = base number of the number system • consist of symbols 0.......(X-1) • QUESTION: Why not 0.....X ???? Adjacent digits (from right to left) represent increasing powers of the X-ary system
0 0 0 9 9 9 1 1 1 8 8 8 2 2 2 3 3 3 7 7 7 4 4 4 6 6 6 5 5 5 MODEL : hodometer
HODOMETER (2) • What was the X? • How many symbols per disc ? • Maximum number? • Now imagine a BINARY disc into the hodometer • write down the first 20 numbers • ? how many discs did you need?
0 0 0 1 1 1 MODEL : hodometer
Addition 1 0 1 0 0 0 0 1 0 1 0 0 0 1 0 1 + 1 1 1 0 0 1 1 0
Negative Numbers Using the 8-th bit as a SIGN bit 53 = 0 0 1 1 0 1 0 1 -53 = 1 0 1 1 0 1 0 1 Inverting the bits 53 = 0 0 1 1 0 1 0 1 -53 = 1 1 0 0 1 0 1 0
Two’s Complement 13 0 0 0 0 1 1 0 1 inv 1 1 1 1 0 0 1 0 1 +1 Two’s Complement 1 1 1 1 0 0 1 1
Two’s Complement (2) 61 0 0 1 1 1 1 0 1 Two’s Complement 13 1 1 1 1 0 0 1 1 + 1 0 0 1 1 0 0 0 0 48
Flags • Carry • Overflow • Zero • Negative • .. • … • ...
Generic Instructions • Input/output data • Load a value (register) into a register • Arithmetic • jumping / subroutine • control • Bitwise operators : Boolean, Register shifts • interrupt handling • stacking
ASSEMBLY-LAY-OUT {LABEL:} [tab] OPCODE [tab] {OPERANDS} [tab] {; remark-line} examples: start: JP 100 ; go to program start loop: JR NC,-10 ; Loop back if not carry AND A,32 ; reset 6th bit in accumulator HALT ; stop execution ; this is a remark line without operation
MNEMONIC • “short-hand” • examples: • add a,10 ;add 10 into the a register • jp 155 ;jump to a location • inc H ;increase the h register by one
ASSEMBLER DIRECTIVES • ORG xxx • lable DW 122 • lable2 DB 10 • organize next code starting at memory location xxxx • define a value 122 into a word type of variable called ‘lable’ • define a value 10 into a byute type variable called ‘lable2’
ASSEMBLER CYCLE text file start: ORG 100 begin: jp 130 add a,3 loop: nop nop inc bc .... ..... LINK ROUTINE modules MEMORY 11010010;10011000;00011101;11101010;11101110;11110110;10100111;01000011;11110000;01100000;10101011;10111000;01111101;11000011;10110111;00010101;01111111;01000010;01000000;11000101;11011110;10110111;01000000;11011101;10011000;10110110; ASSEMBLER LINKER TEXT EDITOR DEBUGGER MICRO PROCESSOR input output
Main registers. Alternative registers. Accumulator Registers Interupt register Alternative Registers Memory Refresh Adress Registers Z80 Processor Register Layout I A’ A F F’ R W Z W’ Z’ B C B’ C’ D E D’ E’ Flags 8 bit H L H’ L’ S Sign Z Zero I X - - H Half-Carry I Y - - S P P/V Parity/overfl. P C N Negate C Carry