Cs 401 P Code

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

[ org 0x0100]

Jmp start

Vuid : db 2,1,0,2,0,1,0,2,1

Biggest : db 0

Smallest : db 0

Product : db 0

Start :

Initialize registers

Mon si , vuid

Mov cx , 9

Find the largest digit

Mov al , [si]

Mov bl , al

Inc si

Dec cx

Find largest :

Cmp bl , [si ]

Digit

Jae not – largest

Mov bl , [si ]

Not _ largest :

Inc si

Loop find _ largest

Store the largest digit

Mov [ biggest ] , bl

Reset registers for finding the smallest digit


Mov si , vuid

Mov cx , 9

Find the smallest digit

Mov al , [si ]

Mov bl , al

Inc si

Dec cx

Find smallest

Cmp bl , [ si ]

Smallest digit

Jbe not smallest

Mov bl , [si ]

Not smallest :

Inc si

Loop find smallest

Store the smallest digit

Mov [smallest ] , bl

Calculate the product of the largest and smallest digits

Mov al , [ biggest ]

Mov bl , [ smallest ]

Imu1 ax , bx

Mov [ product ] , al

Exit the program

Mov ax , 0x4c00

Int 0x21

You might also like