Professional Documents
Culture Documents
Ahmed
Mohamed
Student
#:7641341
LOAD ACCA
Source Code:
LDAA $(Variable)
LDX
#$0000
LDAB #$FF
INCREMENT B
LOOP INCB
INC X
INCB
INX
A<- (A-B)
N
O
SBA
A>B?
BHI
Y
HERE
BRA
LOOP
HERE
END
Precision Program:
3 The actual assembly syntax is BNE F6 , we dont need to because the assembler will
take care of this for us after the first loop through the code.
4 Precision refers to the amount of bytes per word we are going to be adding.
5 In our program the limitation is the risk of overwriting data to there our maximum
precision would be 082F-081F - C = 0010 -1 = A precision of 15.
6 The relationship is one to one, for example if our required precision is 3 our loop will
run 3 times.
7 Our augend is located in from locations 080D080F, and our Addend is located
081D-081F, both numbers are stored is BIG ENDIANS.
8 The program gets this from register B this information is manually specified by the
user in memory location 0830.
9 The instructions that affect the carry flag of the CCR are ADCA, ADCB and the CLC
all are able to affect the carry flag. The loop will run through 6 instructions before it
branches off. After the first addition the program will either set off a carry or not
next around the program will add the next significant byte of the second with
previously generated carry to accumulator a. And after the last addition of the last
two bytes the program will either set off a carry or not and then the instruction
ADCB will add #$00 to B along with the carry and put it in the least MSB of the
result. If CMPB #$00 were added before the BNE instruction the program would not
work because the carry would be overwritten in the condition code register and the
whole flow of our program would be different.
10 The program cannot add signed numbers because overflow will be not taken into
account and we would have to add an overflow detection source code in our
program depending on the overflow detection we could sign extend our result from
there.