# Dividing numbers by a fixed value

If you would like us to help you with the concept of dividing numbers by a fixed value, get in touch with us. Our programming experts provide both tutoring and assignment writing services for tasks related to this topic.

## Assignment

Write an MC6800 program that adds up all numbers divisible by 11 between two limits,
e.g., from 15 to 400
• Your program must use at least one loop
• Your program should store the sum in memory location \$300; check the result after running the program
• Include all necessary global and local comments
• For this program, you may not use numbers for any addresses except in an ORG directive (use labels instead for other addresses)
• Be sure to run your program and check the results
• The name of your program should be your last name (or its first eight letters)
• Submit your program file (with extension .X68) along with representative results as paper copies in the class on or before the due date.

#### Solution

##### program.X68

ORG \$400

START: ; first instruction of program

LEA FIRST,A0

MOVE.L (A0),D1 ; read first limit in D1

LEA LAST,A0

MOVE.L (A0),D2 ; read last limit in D2

MOVE.L #0,D3 ; D3 will contain the sum, initialize to 0

MOVE.L #16,D4 ; D4 is always 16

LOOP:

MOVE.L D1,D0 ; put current number in D0 for division

DIVU #11,D0 ; divide by 11

LSR.L D4,D0 ; put the remainder at lower 16 bits by shifting to the right

CMP.W #0,D0 ; see if the remainder is zero

BNE NEXT ; if not, is not divisible by 11, go to next

NEXT:

ADD.L #1,D1 ; go to next number

CMP.L D2,D1 ; compare current number with upper limit

BLE LOOP ; continue while we don’t go above the upper limit

MOVE.L D3,(A0) ; save sum in the result address

SIMHALT ; halt simulator

FIRST: DC.L 15 ; lower limit

LAST: DC.L 400 ; upper limit