Because ASM is a low level language you need to know how the cpu works to some extent.
Instructions consist of an opcode and a certain number of operands. Opcodes are the things the CPU understands and executes. Operands are the parameters required for the operation. The most important kind of operands are the Source and Destination operands. These can either be a direct value or an address. An address refers to a specific memory location. Every byte in memory has an address. There are different kinds of addressing modes. Some are useful if you just need fast and small code and others let you access a large amount of memory.
Go to the Addressing Reference Page to read about all the different modes.
The Z8 encore! XP does not have regular RAM, but instead it can have up to 4096 registers. Some registers are special.
Working Registers:
R0-R15
General-Purpose Register File
These registers range from address 000h to EFFh. If your microcontroller has a smaller register file writing to the addresses that are beyond the register file size will not have any result and reading from them will return an undefined value. This tutorial will refer to these registers as RAM.
Special-Purpose Registers:
These registers start at address F00h. Special-Purpose Registers control the various features of the microcontroller such as: I/O, timers, interrupts and ADC.
To load a value to a register you use load instructions. One of these instructions is: LD.
An example on how to load a value to a register:
LD R0,#5 ;Write 5 to register R0 LD R1,R0 ;Write the value in R0 to R1 LD R2,@R1 ;Write the value at the RAM address stored in R1 to R2
Register pairs
A register pair is a set of two registers. The first regiser is the high byte. The second register is the low byte. To load a 16 bit value in a register pair you have to load two 8 bit values since this is an 8 bit cpu:
LD RR0,#1020h ;is not possible and will thow an error at you
LD R0,#10h ;is the right way to do it LD R1,#20h
Some instructions can use a register pair as an operand. Register pairs are often used for storing pointers.
Short: PC. The PC is a special 16 bit register with adder logic. Every time a new byte is loaded in the cpu the PC gets incremented by 1. The cpu can also set the value of the PC. This is called branching. You can branch using jump instructions.
For more specific information on the cpu and peripherals in the microcontroller go to the CPU reference.
Please submit corrections, suggestions, and new documentation here: Submit a ticket
← Return to Tutorial Index
This is not an official Zilog website. Zilog nor 8times8 are liable for any damage done to equipment. Tutorial and reference copyright ©8times8 Creative Commons CC-0 License (public domain.) This reference uses content from Zilog's technical datasheets. Fair use only. Datasheets copyright © 2013 Zilog®, Inc. Z8, Z8 Encore!, Z8 Encore! XP and Z8 Encore! MC are trademarks or registered trademarks of Zilog, Inc. Read Zilog's terms at zilog.com
Website design by Koen van Vliet. Hosted by sourceforge.net