PC Assembler Ing E E Mak MSc Cluster
PC Assembler Ing. E. E. Mak MSc
Cluster 1 • • • Introduction Microprocessors Numbers, Binary, Hexadecimal, ASCII Adding and subtracting Instructions and Flags Deeds Z 80 simulator
Computer Lay-out MEM data+instructions I/O CPU External
Model CPU PC M A R M D R R 1 A R 2 B ALU IR SR DECODER C ICU TIMER CLOCK
Z 80 Processor Register Layout Main registers. Interupt register Alternative registers. I R Memory Refresh Accumulator Registers A’ W B D H I I S P Z C E L X Y P C W’ B’ D’ H’ Z’ C’ E’ L’ A Alternative Registers Adress Registers F F’ Flags 8 bit S Sign Z Zero H Half-Carry P/V Parity/overfl. N Negate C Carry
Negative Numbers Using the 8 -th bit as a SIGN bit 53 = 0 0 1 1 0 1 -53 = 1 0 1 0 1 Inverting the bits 53 = 0 0 1 1 0 1 -53 = 1 1 0 0 1 0
Two’s Complement 13 0 0 1 1 0 1 inv 1 1 0 0 1 0 +1 1 Two’s Complement 1 1 0 0 1 0
Packed Decimals 53 = 35 = 0 0 1 1 0 1 binary 0 0 1 1 0 1 Binary packed decimal 3 5
Addition 1 0 0 0 0 1 0 1 1 1 1 0 0 1 1 0 +
Subtraction 1 1 1 0 0 0 1 1 0 0 0 0 1 -
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
Example programs LD A, 86 d ADD A, 57 d LD A, 86 d ADC A, 57 d
Example programs 2 Adding 57 to HL: LD ADD LD LD ADC LD A, L A, 57 d L, A A, H A, 0 H, A
Assignments 1. Write a program to store 100 into DE and 385 into BC ADD thereafter DE and BC into HL 2. Investigate substraction using negative numbers for all number-configurations demonstrated in previous sheets 3. Investigate how to multiply using binary numbers 4. Investigate using shift operators could facilitate the multiplication process. 5. What are floating point decimals , how are they implemented?
links • Simple reference list Z 80 opcodes: – http: //www. ticalc. org/pub/text/z 80. txt • Lots of information about the Z 80 – http: //www. z 80. info/ • full reference list op-codes Z 80: – http: //www. ticalc. org/pub/text/z 80_reference. txt • Crash-course Z 80 assembly-programming – http: //www. ticalc. org/pub/text/z 80 asmg. zip
Binary Packed 0 E 1 A 0 0 1 1 1 0 28 0 0 1 0 0 0 1 1 0 The use of half bytes let us express two adjacent hexadecimal numbers. As a consequence, we may use this two-digit hexadecimal byte presentation to perform calculations as well, whereas the carrymechanism while adding work accordingly + In hexadecimal coding, each digit of one halfbyte represents a hexadecimal number
Binary Packed Decimal 07 17 0 0 0 1 1 1 24 0 0 1 0 0 0 1 1 1 The use of half bytes for numbers 0. . 9 only, forces while adding special corrections to facilitate adding of these decimal numbers. (What would the result have been without this corrections? ) + Could you develop an algorithm to make this corrections?
- Slides: 18