0% found this document useful (0 votes)
39 views6 pages

Hey Princess: 8086 Programs

The document describes an 8086 assembly language program that finds the smallest element in an array. It uses three registers: BX points to the starting memory address of the array, CX counts the number of elements, and AX holds each element to compare it to the current smallest. The program increments through the array, using CMP and JC instructions to update the smallest element in AX. Once complete, it stores the final smallest element in memory location 1200.

Uploaded by

Prabhu
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views6 pages

Hey Princess: 8086 Programs

The document describes an 8086 assembly language program that finds the smallest element in an array. It uses three registers: BX points to the starting memory address of the array, CX counts the number of elements, and AX holds each element to compare it to the current smallest. The program increments through the array, using CMP and JC instructions to update the smallest element in AX. Once complete, it stores the final smallest element in memory location 1200.

Uploaded by

Prabhu
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Hey Princess

8086 Programs

Sunday 9 October 2011

Smallest Element 792163

Sunday 9 October 2011

Registers Used in this program

AX BX CX
BX holds the address of the starting element of the array of elements CX is the count register again to store the total number of elements AX is used for doing all the comparisons etc.

Sunday 9 October 2011

Program Code

Line 1: moves 0003H to CX register Line 2: moves 1100 to BX register Line 3: moves the data stored at 1100 to AX register Line4 and Line 5: increment BX to point to next memory address Line 6: compare AX and the value stored in the memory address present in BX which means now it compares 7 and 9 what cmp actually does is it just subtracts 7 from 9.. ie. 7 - 9 and if the answer is negative Carry ag (CF) is set to 1 which means 7 is less than 9

1100

0003H

now if we did cmp 9, 7 then since the answer wouldnt have been negatve CF would be 0 only

AX BX CX

1100 1102

7 9

Sunday 9 October 2011

Program Code
which means the next instruction jc (jump if carry) wouldnt do the jumping... instead it would just move 7 into the AX register as given in line 8. remember we have to nd the smallest element and we keep the smallest elemnt in AX so now since we have carry jc jumps to NEXT line 9: here we jut decrement CX and go back to loop 1

1100

0003H

AX BX CX

1100 1102

7 9

Sunday 9 October 2011

Program Code
once the smallest elemnt has been found it is moved to 1200 in line 11 in our example the smallest is 7 so now 7 is in memory location 1200 :)

1100

0003H

1100 1102

AX BX CX

7 9

Sunday 9 October 2011

You might also like