Microcomputer systems: introduction to assembly programming

Giuliano Donzellini, Domenico Ponta

Introduction to the Micro Computer Emulator (d-McE)

100010

 

v1.71

In this introductory project, you write and test a few simple DMC8 assembly programs, gaining confidence with the d-McE (Deeds - Micro Computer Emulator).

a) Registers initialization

This first DMC8 assembly program should load the decimal value 230 in the A register, the decimal value 45 in the B register and then the value 30F0h in a 16-bits register, made of two coupled 8-bits registers of your choice. In this simple program, at the end of the code, you can stop the processor with the instruction HALT. You should link the program to the hardware RESET of the processor, using the following statements:

  ORG 0000h
  JP  0100h
  ORG 0100h
PROG_A: ....

Click here to load this piece of code in the d-McE, and start writing your code. When finished, save the program with a name of your choice and test it in the debugger. We suggest to use the step-by-step modality, that will permit you to execute the program instruction by instruction, observing what happens in the micro computer system in the meantime.

Note: repeat the test operations for each of the following assigments.

b) Register swap

Write and test another program that starts with the initialisation of the A and B registers, as requested above (you can copy and paste rows of code from the previous program), and then swaps the two registers content (you can use C as temporary register).

c) Memory direct addressing

Write and test another instruction sequence that, using the direct addressing, will load the decimal 55 in the memory locations C350h and C351h and the decimal 14 in the location C352h. To see the memory write operation, you should scroll down the memory panel until the memory locations of interest will be visible (you can use also the memory context menu).

d) Memory indirect addressing

Write and test another code that execute the same operations of the previous one, but using the HL coupled register for memory indirect addressing [i.e., use the instructions "LD HL,nn" , "LD (HL),A" and "INC HL"].

e) Add and subtract memory locations using indirect addressing

Write and test a program that will start with a sequence of instructions identical to the previous program, in which memory location from C350h to C352h are initialized (re-use the code written for the previous assignment). After these preliminar operations, the new program, using the indirect addressing mode, will reload in the A register the value of the memory location C350h, will add to it the value of the subsequent memory location (C351h) and then subtract the value of the third (C352h). Last, the program will store the result in the memory location C353h. Suggestion: use the arithmetic instructions "ADD A,(HL)" and "SUB (HL)".

f) Remark

Consider what happens if you change the values of the first two operands, setting them to 140 instead of 55. Observe, during the execution of the arithmetic operations, the Carry flag value, and the final value.