MPMC Simple Lab Programs


For ASIST Students

PROGRAM: Ascending  Operation for a given Numbers

Address  Opcode    Mnemonics Operands
0A1A:0000 B8190A         MOV       AX,0A19 
0A1A:0003 8ED8           MOV       DS,AX 
0A1A:0005 8A0E0200       MOV       CL,BYTE PTR [0002] 
0A1A:0009 8B360000       MOV       SI,WORD PTR [0000] 
0A1A:000D 8A2E0300       MOV       CH,BYTE PTR [0003] 
0A1A:0011 8A04           MOV       AL,BYTE PTR [SI] 
0A1A:0013 46             INC       SI 
0A1A:0014 8A1C           MOV       BL,BYTE PTR [SI] 
0A1A:0016 38D8           CMP       AL,BL 
0A1A:0018 7608           JBE       0022 
0A1A:001A 86C3           XCHG      BL,AL 
0A1A:0000 B8190A         MOV       AX,0A19 
0A1A:0003 8ED8           MOV       DS,AX 
0A1A:0005 8A0E0200       MOV       CL,BYTE PTR [0002] 
0A1A:0009 8B360000       MOV       SI,WORD PTR [0000] 
0A1A:000D 8A2E0300       MOV       CH,BYTE PTR [0003] 
0A1A:0011 8A04           MOV       AL,BYTE PTR [SI] 
0A1A:0013 46             INC       SI 
0A1A:0014 8A1C           MOV       BL,BYTE PTR [SI] 
0A1A:0016 38D8           CMP       AL,BL 
0A1A:0018 7608           JBE       0022 
0A1A:001A 86C3           XCHG      BL,AL 
0A1A:001C 4E             DEC       SI 
0A1A:001D 8804           MOV       BYTE PTR [SI],AL 
0A1A:001F 46             INC       SI 
0A1A:0020 881C           MOV       BYTE PTR [SI],BL 
0A1A:0022 FECD           DEC       CH 
0A1A:0024 75EB           JNZ       0011 
0A1A:0026 FEC9           DEC       CL 
0A1A:0028 75DF           JNZ       0009 
0A1A:002A CC             INT       3 

Results:
inputs:
0A19:6000  05 04 03 02 01
output:
0A19:6000  01 02 03 04 05



PROGRAM: Descending Operation for a given Numbers

Address   Opcode       Mnemonics  Operands
0A1A:0000 B8190A         MOV       AX,0A19 
0A1A:0003 8ED8           MOV       DS,AX 
0A1A:0005 8A0E0200       MOV       CL,BYTE PTR [0002] 
0A1A:0009 8B360000       MOV       SI,WORD PTR [0000] 
0A1A:000D 8A2E0300       MOV       CH,BYTE PTR [0003] 
0A1A:0011 8A04           MOV       AL,BYTE PTR [SI] 
0A1A:0013 46             INC       SI 
0A1A:0014 8A1C           MOV       BL,BYTE PTR [SI] 
0A1A:0016 38D8           CMP       AL,BL 
0A1A:0018 7308           JNB       0022 
0A1A:001A 86C3           XCHG      BL,AL 
0A1A:001C 4E             DEC       SI 
0A1A:001D 8804           MOV       BYTE PTR [SI],AL 
0A1A:001F 46             INC       SI 
0A1A:0020 881C           MOV       BYTE PTR [SI],BL 
0A1A:0022 FECD           DEC       CH 
0A1A:0024 75EB           JNZ       0011 
0A1A:0026 FEC9           DEC       CL 
0A1A:0028 75DF           JNZ       0009 
0A1A:002A CC             INT       3 

Results:
inputs:
0A19:6000  01 02 03 04 05
output:
0A19:6000  05 04 03 02 01



  
Program: Factorial of a Given Number

Address  Opcode    Mnemonics Operands

0A1A:0000 B8190A         MOV       AX,0A19 
0A1A:0003 8ED8           MOV       DS,AX 
0A1A:0005 8A0E0000       MOV       CL,BYTE PTR [0000] 
0A1A:0009 B001           MOV       AL,01 
0A1A:000B F6E1           MUL       CL 
0A1A:000D FEC9           DEC       CL 
0A1A:000F 75FA           JNZ       000B 
0A1A:0011 CC             INT       3 
0A1A:0012 8BC3           MOV       AX,BX 
0A1A:0014 6605D6010000   ADD       EAX,000001D6 
0A1A:001A 662EA39C12     MOV       DWORD PTR CS:[129C],EAX 

Result:
inputs:

0A19:6000  05

output:
 AX = 0078  BX = 0000  CX = 0000  DX = 0000  SP = 0000  BP = 0000
 SI = 0000  DI = 0000  DS = 0A19  ES = 0A09  SS = 0A19  CS = 0A1A
 IP = 0011  FL = 3246

PROGRAM: Fibonacci  for a given Number

Address  Opcode    Mnemonics Operands

0A0C:0000 B80B0A         MOV       AX,0A0B 
0A0C:0003 8ED8           MOV       DS,AX 
0A0C:0005 8A0E0600       MOV       CL,BYTE PTR [0006] 
0A0C:0009 8B360400       MOV       SI,WORD PTR [0004] 
0A0C:000D A10000         MOV       AX,WORD PTR [0000] 
0A0C:0010 8B1E0200       MOV       BX,WORD PTR [0002] 
0A0C:0014 8804           MOV       BYTE PTR [SI],AL 
0A0C:0016 46             INC       SI 
0A0C:0017 881C           MOV       BYTE PTR [SI],BL 
0A0C:0019 02C3           ADD       AL,BL 
0A0C:001B 86C3           XCHG      BL,AL 
0A0C:001D FEC9           DEC       CL 
0A0C:001F 75F5           JNZ       0016 
0A0C:0021 CC             INT       3 


Result:

Input:

0A0B:6000  01 02 03 05 08 0D

output:

 AX = 000D  BX = 0015  CX = 0000  DX = 0000  SP = 0000  BP = 0000
 SI = 6005  DI = 0000  DS = 0A0B  ES = 09FB  SS = 0A0B  CS = 0A0C
 IP = 0021  FL = 3246


  
PROGRAM: Largest Number in a Given Sequence of Numbers


Address  Opcode    Mnemonics Operands

0A0C:0000 B80B0A         MOV       AX,0A0B 
0A0C:0003 8ED8           MOV       DS,AX 
0A0C:0005 8B360000       MOV       SI,WORD PTR [0000] 
0A0C:0009 8A0E0200       MOV       CL,BYTE PTR [0002] 
0A0C:000D 8A04           MOV       AL,BYTE PTR [SI] 
0A0C:000F 46             INC       SI 
0A0C:0010 8A1C           MOV       BL,BYTE PTR [SI] 
0A0C:0012 38D8           CMP       AL,BL 
0A0C:0014 7302           JNB       0018 
0A0C:0016 86C3           XCHG      BL,AL 
0A0C:0018 FEC9           DEC       CL 
0A0C:001A 75F3           JNZ       000F 
0A0C:001C CC             INT       3 


Result:

input:

0A0B:6000  09 05 07 01 03 04

output:

 AX = 0A09  BX = 0004  CX = 0000  DX = 0000  SP = 0000  BP = 0000
 SI = 6005  DI = 0000  DS = 0A0B  ES = 09FB  SS = 0A0B  CS = 0A0C
 IP = 001C  FL = 3246


 PROGRAM: Smallest number in a given sequence.

Address   Opcode       Mnemonics  Operands

0A1B:0000 B81A0A         MOV       AX,0A1A 
0A1B:0003 8ED8           MOV       DS,AX 
0A1B:0005 8B360000       MOV       SI,WORD PTR [0000] 
0A1B:0009 8A0E0200       MOV       CL,BYTE PTR [0002] 
0A1B:000D 8A04           MOV       AL,BYTE PTR [SI] 
0A1B:000F 46             INC       SI 
0A1B:0010 8A1C           MOV       BL,BYTE PTR [SI] 
0A1B:0012 38D8           CMP       AL,BL 
0A1B:0014 7602           JBE       0018 
0A1B:0016 86C3           XCHG      BL,AL 
0A1B:0018 FEC9           DEC       CL 
0A1B:001A 75F3           JNZ       000F 
0A1B:001C CC             INT       3 



Result:

Input:

0A1A:6000  02 03 04 01 05 06

Output:

 AX = 0A01  BX = 0006  CX = 0000  DX = 0000  SP = 0000  BP = 0000
 SI = 6005  DI = 0000  DS = 0A1A  ES = 0A0A  SS = 0A1A  CS = 0A1B
 IP = 001C  FL = 3247



 PROGRAM: Sum of Cubes of a given sequence of Numbers


Address  Opcode    Mnemonics Operands

0A1A:0000 B8190A         MOV       AX,0A19 
0A1A:0003 8ED8           MOV       DS,AX 
0A1A:0005 8B360000       MOV       SI,WORD PTR [0000] 
0A1A:0009 8A0E0200       MOV       CL,BYTE PTR [0002] 
0A1A:000D 8A04           MOV       AL,BYTE PTR [SI] 
0A1A:000F 8AD0           MOV       DL,AL 
0A1A:0011 F6E0           MUL       AL 
0A1A:0013 F6E2           MUL       DL 
0A1A:0015 02D8           ADD       BL,AL 
0A1A:0017 46             INC       SI 
0A1A:0018 FEC9           DEC       CL 
0A1A:001A 75F1           JNZ       000D 
0A1A:001C CC             INT       3 

Result:

Input:

0A19:6000  01 02 03 04 05

Output:

 AX = 007D  BX = 00E1  CX = 0000  DX = 0005  SP = 0000  BP = 0000
 SI = 6005  DI = 0000  DS = 0A19  ES = 0A09  SS = 0A19  CS = 0A1A
 IP = 001C  FL = 3246

  
PROGRAM: sum of  N natural numbers

Address  Opcode    Mnemonics Operands

0A1A:0000 B8190A         MOV       AX,0A19 
0A1A:0003 8ED8           MOV       DS,AX 
0A1A:0005 8B360000       MOV       SI,WORD PTR [0000] 
0A1A:0009 8A0E0200       MOV       CL,BYTE PTR [0002] 
0A1A:000D 8A04           MOV       AL,BYTE PTR [SI] 
0A1A:000F 02D8           ADD       BL,AL 
0A1A:0011 46             INC       SI 
0A1A:0012 FEC9           DEC       CL 
0A1A:0014 75F7           JNZ       000D 
0A1A:0016 CC             INT       3 


Result:

input:

0A19:6000  01 02 03 04 05

output:

 AX = 0A05  BX = 000F  CX = 0000  DX = 0000  SP = 0000  BP = 0000
 SI = 6005  DI = 0000  DS = 0A19  ES = 0A09  SS = 0A19  CS = 0A1A
 IP = 0016  FL = 3246


 PROGRAM: Sum of squares of  N  natural numbers

Address  Opcode    Mnemonics Operands

0A1A:0000 B8190A         MOV       AX,0A19 
0A1A:0003 8ED8           MOV       DS,AX 
0A1A:0005 8A0E0200       MOV       CL,BYTE PTR [0002] 
0A1A:0009 8B360000       MOV       SI,WORD PTR [0000] 
0A1A:000D 8A04           MOV       AL,BYTE PTR [SI] 
0A1A:000F F6E0           MUL       AL 
0A1A:0011 02D8           ADD       BL,AL 
0A1A:0013 46             INC       SI 
0A1A:0014 FEC9           DEC       CL 
0A1A:0016 75F5           JNZ       000D 
0A1A:0018 CC             INT       3 

Result:

input:

0A19:6000  01 02 03 04 05

output:

 AX = 0019  BX = 0037  CX = 0000  DX = 0000  SP = 0000  BP = 0000
 SI = 6005  DI = 0000  DS = 0A19  ES = 0A09  SS = 0A19  CS = 0A1A
 IP = 0018  FL = 3246



  
PROGRAM: Addition Operation for a given numbers

Address  Opcode    Mnemonics Operands

0A1A:0000 B8190A         MOV       AX,0A19 
0A1A:0003 8ED8           MOV       DS,AX 
0A1A:0005 A10000         MOV       AX,WORD PTR [0000] 
0A1A:0008 8B1E0200       MOV       BX,WORD PTR [0002] 
0A1A:000C 93             ADD      AX,BX 
0A1A:000D CC             INT       3 


Result:

Input:

0A19:6000  34 12 12 34

output:

AX = 4556  BX = 1234  CX = 0000  DX = 0000  SP = 0000  BP = 0000
 SI = 0000  DI = 0000  DS = 0A19  ES = 0A09  SS = 0A19  CS = 0A1A
 IP = 000D  FL = 3202



  


PROGRAM: Decrement Operation

Address  Opcode       Mnemonics     Operands
0A1A:0000 B8190A         MOV       AX,0A19
0A1A:0003 8ED8           MOV       DS,AX 
0A1A:0005 A10000         MOV       AX,WORD PTR[6000] 
0A1A:0008 48             DEC       AX 
0A1A:0009 CC             INT       3 



Results:

input:0A19:6000  12 34

Output:

 AX = 1233 BX = 0000 CX = 0000 DX = 0000 SP = 0000 BP = 0000
 SI = 0000 DI = 0000 DS = 0A19 ES = 0A09 SS = 0A19 CS = 0A1A
 IP = 0009 FL = 3206
    


  

PROGRAM: Multiplication  Operation for a given Numbers

Address  Opcode    Mnemonics Operands

0A1A:0000 B8190A         MOV       AX,0A19 
0A1A:0003 8ED8           MOV       DS,AX 
0A1A:0005 A10000         MOV       AX,WORD PTR [0000] 
0A1A:0008 8B1E0200       MOV       BX,WORD PTR [0002] 
0A1A:000C F7E3           DIV       BX 
0A1A:000E CC             INT       3 


Result:

input:

0A19:6000  00 04 00 02

output:

AX = 0002  BX = 0002  CX = 0000  DX = 0000  SP = 0000  BP = 0000
SI = 0000  DI = 0000  DS = 0A19  ES = 0A09  SS = 0A19  CS = 0A1A
IP = 000E  FL = 3202


 PROGRAM: Exchange of given Numbers


Address  Opcode    Mnemonics Operands

0A1B:0000 B81A0A         MOV       AX,0A1A 
0A1B:0003 8ED8           MOV       DS,AX 
0A1B:0005 A10000         MOV       AX,WORD PTR [0000] 
0A1B:0008 8B1E0200       MOV       BX,WORD PTR [0002] 
0A1B:000C 93             XCHG      AX,BX 
0A1B:000D CC             INT       3 


Result:

input:
0A1A:6000  12 34 34 56

output:
AX = 3456  BX = 1234  CX = 0000  DX = 0000  SP = 0000  BP = 0000
SI = 0000  DI = 0000  DS = 0A1A  ES = 0A0A  SS = 0A1A  CS = 0A1B
IP = 000D  FL = 3202


 PROGRAM: Increment operation for a given number


Address  Opcode    Mnemonics Operands

0A1A:0000 B8190A         MOV       AX,0A19 
0A1A:0003 8ED8           MOV       DS,AX 
0A1A:0005 A10000         MOV       AX,WORD PTR [0000] 
0A1A:0008 40             INC       AX 
0A1A:0009 CC             INT       3 

Result:

Input:
0A19:6000  12 34

Output:
AX = 1235  BX = 0000  CX = 0000  DX = 0000  SP = 0000  BP = 0000
SI = 0000  DI = 0000  DS = 0A19  ES = 0A09  SS = 0A19  CS = 0A1A
IP = 0009  FL = 3206  



  

PROGRAM: Multiplication  Operation for a given Numbers

Address  Opcode    Mnemonics Operands

0A1A:0000 B8190A         MOV       AX,0A19 
0A1A:0003 8ED8           MOV       DS,AX 
0A1A:0005 A10000         MOV       AX,WORD PTR [0000] 
0A1A:0008 8B1E0200       MOV       BX,WORD PTR [0002] 
0A1A:000C F7E3           MUL       BX 
0A1A:000E CC             INT       3 


Result:

input:

0A19:6000  00 01 00 02

output:

AX = 0002  BX = 0002  CX = 0000  DX = 0000  SP = 0000  BP = 0000
SI = 0000  DI = 0000  DS = 0A19  ES = 0A09  SS = 0A19  CS = 0A1A
IP = 000E  FL = 3202


  
PROGRAM: Subtraction  Operation for a given Numbers

Address  Opcode    Mnemonics Operands

0A1A:0000 B8190A         MOV       AX,0A19 
0A1A:0003 8ED8           MOV       DS,AX 
0A1A:0005 A10000         MOV       AX,WORD PTR [0000] 
0A1A:0008 8B1E0200       MOV       BX,WORD PTR [0002] 
0A1A:000C 2BC3           SUB       AX,BX 
0A1A:000E CC             INT       3 


Result:

input:

0A19:6000  34 56 12 34

output:

AX = 2222  BX = 1234  CX = 0000  DX = 0000  SP = 0000  BP = 0000
SI = 0000   DI = 0000  DS = 0A19   ES = 0A09  SS = 0A19  CS = 0A1A
IP = 000E  FL = 3206



0 comments: