Make your own free website on Tripod.com

headerdef.jpg

H O M E - APOLLO181 INTRODUCTION
First Program Example
Binary Clock Algorithm
Shift-and-Add Multiplication
Prime Numbers Benchmark
PWM LED Dimmer
Step Motor Controller
Sound Generator: Part 1
Sound Generator: Part 2
Random Number Generator
EPROM Data Storage
My Previous Z80 Project

 

Binary 8-bit multiplication by repeated addition

 

This is a simple non-optimized program which I used to initially test the capabilities of APOLLO181: this algorithm, that multiplies two integer unsigned 8-bit numbers giving a 16-bit result, uses 14 of the 16 available instructions.

 

Multiplication here is a repeated addition: the first number is the multiplier and tells how many times to add the second number. The second number is the multiplicand and it is added the number of times stated by the first number, the multiplier.

 

The main portion of the algorithm (that is the repeated addition of the multiplicand which you can see in the video at slow clock) consists of 28 instructions, from address 19H to address 34H. APOLLO181, if running at 2,5MHz, is able to perform 625000 complete instructions per second, or one instruction every 1,6 microseconds.

In the worst case, that is 255*255 = 65025 (or "1111 1110 0000 0001" in binary), APOLLO181 will perform the calculation in ( 28 * 255 * 1,6 us )= 11,4 ms.

ADDRESS   INSTRUCTION     DESCRIPTION

 

00    10   ACC = 0  

01    F7   PORT7 = ACC    

02    F8   PORT8 = ACC    

03    F9   PORT9 = ACC    

04    FA   PORTA = ACC    

05    24   REG4 = ACC

06    25   REG5 = ACC

07    26   REG6 = ACC

08    27   REG7 = ACC

Clear Displays and Registers

 

09   E7   ACC = PORT7    

0A   20   REG0 = ACC

0B   E8   ACC = PORT8    

0C   21   REG1 = ACC

Input 8-bit Multiplier

 

0D   1E 

0E   00   GOTO 0Eh

Wait for Interrupt (infinite cycle)

 

0F   E7   ACC = PORT7

Resume from Interrupt (Interrupt Vector switches must be set to address "0F")

 

10   22   REG2 = ACC

11   E8   ACC = PORT8    

12   23   REG3 = ACC

Input 8-bit Multiplicand

 

13   4E   SET ALU "A OR B"

14   31   ACC = REG1

15   80   ACC = (ACC OR REG0) 

16   A0   COMPARE ACC WITH 0  

Check if Multiplier is zero

 

17   15   IF ZERO GOTO 35h (END)

18   C3       

If Multiplier is zero than END

 

19   90   SET FLAG "NO CARRY"

Decrement Multiplier till it is zero

 

1A   4F   SET ALU "A MINUS 1" 

1B   30   ACC = REG0

1C   50   ACC = ACC - 1  

1D   20   REG0 = ACC

1E   31   ACC = REG1

1F   50   ACC = ACC - 1 + CARRY    

20   21   REG1 = ACC

21   15   IF "CARRY" GOTO 25h

If Multiplier is greater than zero then GOTO 25

 

22   D2       

23   15   GOTO 35h (END)

else GOTO 35 (END)

 

24   03       

25   90   SET Carry to ZERO

Initially SET Carry to Zero

 

26   49   SET ALU to "1001"

ALU 74181 ready to make a Sum

 

27   32   ACC = REG2

28   64   ACC = ACC + REG4 + CARRY

29   24   REG2 = ACC

2A   33   ACC = REG3

2B   65   ACC = ACC + REG5 + CARRY 

2C   25   REG5 = ACC

2D   36   ACC = REG6

2E   50   ACC = ACC + ZERO + CARRY 

2F   26   REG6 = ACC

30   37   ACC = REG7

31   50   ACC = ACC + ZERO + CARRY 

32   27   REG7 = ACC

Execute cascaded 16-bit SUM with CARRY in Arithmetic Mode

 

33   19       

34   01   GOTO 19h 

Repeat Addition of Multiplicand

 

35   34   ACC = REG4

36   F7   PORT7 = ACC    

37   35   ACC = REG5

38   F8   PORT8 = ACC    

39   36   ACC = REG6

3A   F9   PORT9 = ACC    

3B   37   ACC = REG7

3C   FA   PORTA = ACC    

3D   1E       

3E   03   GOTO 3Eh (STOP)

Output 16-bit binary results on four led 4-bit port and STOP

DISCLAIMER & CREDIT: All data here reproduced are for educational and non-commercial purpose, following fair-use guidelines.

This is an INDIPENDENT AND UNOFFICIAL hobby site. Either Dr. Peter R. Rony or the Blacksburg group or Computer History Museum (Mountain View, CA) or other third-party DO NOT HAVE ANY ASSOTIATION with this work.

Author G.G. DOESN'T EARN ANYTHING FROM ADVERTISEMENT. This site is not in the business of making money. This site is visible thanks to the Free Web Hosting Tripod Service, so it is ad-supported: advertisement contents, costs and revenues are full managed by the service itself. Author does not have any involvement in them. The advertising links in the Site pages and in the pop-up windows are not Author's property. They can change and the Author is non-responsible about their contents and working. The Author is not responsible about the linked sites.
The information presented here is just that: INFORMATION. Use it at your own risk and for only non commercial purpose. The information here presented is believed to be technically correct and everything presented on this site is done so in good faith. Anyhow you (the reader) are responsible for anything that you might do as a result of reading this article. You assume complete and total responsibility for your actions! Author is not responsible for any misuse or damage coming from the reading and using this information.

Text and images from original typewritten Bugbooks I and II in 1974 are permission courtesy of Dr. Peter R. Rony, the original author and sole copyright owner of the Bugbooks I, II, IIA, III, V, and VI.

The background image on the header of each page of the site is "Sunset over western South America" photographed on 12 April 2011 by an Expedition 27 crew member on the International Space Station. (Image credit: NASA). On it I have merged titles and a my photo of TIL302 displays.

Texas Instruments data are Texas Instruments Copyright and reported by Courtesy of Texas Instruments.

 

TERM OF USE: With clear exception for texts and images which are not author's property, Gianluca G. freely authorizes you the downloading, printing and reproducing of APOLLO181 data, texts and images ONLY for non-commercial usage and ONLY if you give a clear reference to its source and project namewithout any right to resell or redistribute them or to compile or create derivative works.

Any rights not expressly granted herein are reserved.

 

Copyright (c) 2012 by Gianluca G. Italy