0% found this document useful (0 votes)
55 views4 pages

Muhammad Zawir B. Gulam EP091941 Section 3B

The document describes a program that finds the largest element in an array and stores it in memory location 0x10. It includes a flowchart showing the program logic, the assembly code to iterate through the array and compare elements to find the largest, and the defined array with initialized values. A screen capture is also requested to show the array contents and largest element found.

Uploaded by

zawir gulam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
55 views4 pages

Muhammad Zawir B. Gulam EP091941 Section 3B

The document describes a program that finds the largest element in an array and stores it in memory location 0x10. It includes a flowchart showing the program logic, the assembly code to iterate through the array and compare elements to find the largest, and the defined array with initialized values. A screen capture is also requested to show the array contents and largest element found.

Uploaded by

zawir gulam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 4

Muhammad Zawir B.

Gulam
EP091941 Section 3B
Software Assignment

Write a program to find out the largest element in an array. The array is stored in the program
memory. Store the largest element in data memory of location 0x10. 

The array is defined by:


array db 0x00,0x01,0x30,0x03,0x04,0x05,0x06,0x07,0x08,0x09
db 0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,0x13
db 0x1A,0x1B,0x1C,0x3D,0x3E,0x4F,0x40,0x1F,0xF2,0xE3
db 0x2A,0x1B,0xDC,0xED,0xFE,0x1F,0x20,0x17,0x72,0x23
db 0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D
db 0x1E,0x1F

Your submission MUST include a flowchart, the .asm source code and the screen capture of
the array and the largest element found.

Flowchart:

START

n = D’52’
i = 0x40
array_max = 0x10

i < array_max ?
NO
END

YES
NO
new I > array_max END

YES

New I = array_max
Muhammad Zawir B. Gulam
EP091941 Section 3B

i+1=i

Source Code
#include <p18F4550.inc>

n equ D'52'
i set 0x40
array_max set 0x10

org 0x00
goto start
org 0x08
retfie
org 0x18
retfie
start clrf i,A
tblrd*
movff TABLAT,array_max
movlw upper array
movwf TBLPTRU, A
movlw high array
movwf TBLPTRH, A
movlw low array
movwf TBLPTRL, A
loop movlw n
cpfslt i, A
bra done
bra check
check tblrd*+
movf TABLAT, W, A
cpfsgt array_max, A
bra change
bra new_i
change movwf array_max, A
new_i incf i,F,A
goto loop
array db 0x00,0x01,0x30,0x03,0x04,0x05,0x06,0x07,0x08,0x09
db 0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,0x13
db 0x1A,0x1B,0x1C,0x3D,0x3E,0x4F,0x40,0x1F,0xF2,0xE3
db 0x2A,0x1B,0xDC,0xED,0xFE,0x1F,0x20,0x17,0x72,0x23
db 0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D
db 0x1E,0x1F
Muhammad Zawir B. Gulam
EP091941 Section 3B

done nop
end

Screen Capture Of The Array And The Largest Element Found.


Before:

After:
Muhammad Zawir B. Gulam
EP091941 Section 3B

You might also like