Im having problems understanding branches. I don't really know how to use it, but I gave it a shot, shown below in code.
PROGRAM
-----------------------------------------------------------------------------------------------------------------------------------
Note that the PEP/8 instruction set does not provide a multiply instruction, so solution will implement multiplication as repeated addition. In Java, the program would look like this:
int x = 7; // multiplicand
int y = 5; // multiplier (loop limit)
int z = 0; // accumulator (product)
int i = 1; // counter
while (i<=y) {
z = z + x; // add multiplicand to accumulator
i = i + 1; // increment counter
}
CODE
LDA 0X0007,i
sta 0x0037,d; store in x
lda 0x0005,i
sta 0x0039,d; store in y
lda 0x0000,i;
sta 0x003B,d; store in z
lda 0x0001,i
sta 0x003D,d; store in i
LDA 0x0039,d; load y
CPA 0x003D,d; Y with I
BRGE 0x0036,i; START BRANCH
LDA 0x003B,d ; z
ADDA 0x0037,d; x
STA 0x003B,d ; z
LDA 0x003D,d ; i
ADDA 0x0001,i; i+1
STA 0x003D,d ; i
BR 0x001B,i; BRANCH BACK
STOP
.word 0x0000; x
.word 0x0000; y
.word 0x0000; z
.word 0x0000; i
.end