0% found this document useful (0 votes)
720 views43 pages

12th Computer Science: Maharashtra Board

Uploaded by

suyog.gambhire
Copyright
© © All Rights Reserved
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)
720 views43 pages

12th Computer Science: Maharashtra Board

Uploaded by

suyog.gambhire
Copyright
© © All Rights Reserved
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/ 43

ALP

12th Computer Science


Maharashtra Board
Write Assembly Language Program (ALP) to add two hexadecimal numbers 12 H
and 7A H. Store sum to memory location C000 H.

Solution :

Mnemonics Comments

MVI A, 12 H A=12 H
ADI 7A H A=A + 7A H => 12 H + 7AH
STA C000 H C000H= 8C H
HTL. STOP MPU
Write an ALP to add two 16 bit numbers. The first number stored at memory
location C030 H and C031 H and the second number stored at C032 H and
C033 H. Store 16 bit result at memory location C034 H and C035 H
C030 H 10 H
Solution :
C031 H 20 H
Mnemonics Comments C032 H 20 H
LHLD C030 H HL = 1020 H
C033 H 10 H
XCHG DE = 1020 H
LHLD C032 H HL = 2010 H C034 H 30 H
DAD D HL = HL + DE => 2010 H + 1020 H = 3030 H C035 H 30 H
SHLD C034 H [C034 H] = L(30) , [C035 H] = H (30)
HLT Stop MPU
Write an ALP to find 1’s complement of 8 bit number stored in
memory location C000 H. Store result at memory location C001 H
Solution :

Mnemonics Comments
LDA C000 H. [C000 H]= 02 H , A=02 H
CMA. [A]=FD H
STA C001 H. [C001] =A (FD H)
HLT. Stop MPU
Write an ALP to find 1’s complement of 16 bit number stored at
memory location C000 H and C001 H and stored result at memory
location C002 H and C003 H.

Solution : C000 H 01 H

C001 H 02 H
Mnemonics Comments
LHLD C000 H. [HL]=0102 H C002 H FE H
MOV A, H. [A]=01 H C003 H FD H
CMA [A] = FE H
MOV H, A [H]=FE H
MOV A, L [A]=02 H
CMA [A] = FD H
MOV L, A [L]= FD H
SHLD C002 H [C002 H] = FE FD H
HLT Stop MPU
Write an ALP to find 2’s complement of 8 bit number stored in
memory location C000 H. Store result at memory location C001 H.

Solution :

Mnemonics Comments
LDA C000 H [A]=02 H
CMA [A]=FD H
INR A [A] = FE H
STA C001 H [C001 H]=FE H
HLT [C001 H]=FE H
Write an ALP to find 2’s complement of 16 bit number stored at
memory location C000 H and C001 H and stored result at memory
location C002 H and C003 H.

Solution : C000 H 01 H

C001 H 02 H
Mnemonics Comments
LHLD C000 H [HL]=0102 H C002 H FE H
MOV A, H [A]=01 H
CMA [A] = FE H C003 H FE H
MOV H, A H=A => [H]=FE H
MOV A, L [A]=02 H
CMA [A] = FD H
MOV L, A [L]=FD H
INX H HL=HL+1 = FEFD H + 1 = FEFE H
SHLD C002 H [C002 H]=H (FE H) , [C003 H]=L (FE H)
HLT Stop MPU
Interchange Digits

[A]=01 H​
01 H => 00000001
RRC => 10000000
RRC => 01000000
RRC => 00100000
RRC => 00010000
[A]=10 H
A hex number is stored at location AB00 H. Write an ALP to interchange its
digits. And the new number is to be stored at AB01 H. Add original number with
new number and store result at location ABCD H.
Solution : AB00 H 01 H

AB01 H 10 H
Mnemonics Comments
LXI H, AB00 H [HL]=AB00 H , [AB00 H]=01 H AB02 H ------
MOV A, M [A]=01 H
RRC Rotate Right ABCD H 11 H
RRC Rotate Right
RRC Rotate Right
RRC Rotate Right, [A] = 10 H
INX H [HL]=AB01 H
MOV M, A [[HL]]=10 H => [AB01 H]=10 H
DCX H [HL]=AB00 H => [AB00 H] => 01 H
ADD M A=A+M=> 10 H + 01 H = 11 H
STA ABCD H ABCD H =A => [ABCD H ] =11 H
HLT STOP MPU
Separate Nibble of a number :
12 H = > After Nibble separation result should be : 01 H and 02H

12 H. = 0001 0010
^ 0F H. = 0000 1111
---------------------
02 H = 0000 0010

12 H. = 0001 0010
^ F0 H. = 1111 0000
---------------------
10 H = 0001 0000

Rotate Right or left 4 time

01 H
Write an ALP to separate Nibble of a number stored at memory locations 2000 H.
add separated nibble and store result at 2001 H.

Solution :

Mnemonics Comments
LXI H, 2000 H [HL]=2000 H, [2000 H] = H
MOV A, M [A]=12 H
ANI 0F H A=A+0F H => 02 H
MOV B, A [B]=02 H, [A]=02H
MOV A, M. [A]=12 H
ANI F0 H A=A+F0H => 10 H
RRC Rotate Right
RRC Rotate Right
RRC Rotate Right
RRC Rotate Right , [A]=01 H
ADD B A=A+B => 03 H
INX H [HL]=2001 H
MOV M, A [HL]=2001H , [2000 H] =03 H
HLT STOP MPU
Write an ALP to add two 8 bits hex numbers stored at memory locations
C000 H and C001 H. Store the two byte result from memory locations C002 H
onwards.

Solution 1:

Mnemonics Comments
MVI C, 00 H [C]= 00H
LXI H, C000 H. [HL] = C000 H, [C000 H]=0
MOV A, M [A] = 04 H
INX H [HL]=C001 H, [C001 H]=02 H
ADD M A=A+M= 01+02 =06 H
JNC SKIP Cy=0 then jump to SKIP
INR C [C]=01 H
SKIP:INX H [HL]=C002 H
MOV M, A [[HL]](M)=06H
INX H [HL]=C003 H
MOV M, C [[HL]](M)=00H
HLT STOP MPU
2. Arithmetic Group :
20. DAA : [DECIMAL ADJUST ACCUMULATOR]

Addressing: Implied addressing


Group: Arithmetic group
Bytes: 1 byte
Flag: All

Comment:
The eight bit number in the accumulator is adjusted to form two four-bit Binary coded Decimal digits by this
instruction. It can be done by following process:

LSB=Least Significant Bits. MSB= Most Significant Bits

1) If the value of the LSB of the A (A3 - A0) is > 9 or if the AC flag is set =1, 6 (06) is added to LSB of A
2) If the value of MSB of the A (A7 - A4) is > 9 or if the Cy =1, 6 (60) is added to the MSB of A
3) If both 4 LSBs and 4 MSBs of A are > 9 or flags Ac=1 and Cy=1 are set respectively then 66 add to
the accumulator content.
1. LSB > 9 or AC =1 then 6 are added to LSB
2. MSB > 9 or Cy =1 then 6 are added to MSB
3. LSB > 9 and MSB >9 and AC=1 and Cy=1 then 66 to A
2. Arithmetic Group :

[ Note : This instruction must always follow an addition instruction for two BCD numbers. It
can not be used to adjust results after subtraction.]

Example:

Add 12BCD to 39BCD


39 BCD = 0 0 1 1 1 0 0 1
+12CD = 0 0 0 1 0 0 1 0
------ -----------------------
51BCD = 0 0 0 1 0 0 1 0 = 4BH

The binary sum is 4B H.


But BCD sum is 51 To adjust result add 6 to lower nibble
2. Arithmetic Group :

4B = 0 1 0 0 1 0 1 1
+06 = 0 0 0 0 0 1 1 0
--------------------------------
51 = 0 1 0 1 0 0 0 1

Thus [A] = 51 i.e. contents are adjusted to BCD values.


Write an ALP to add two BCD numbers stored at memory locations AB00 H and AB01
H. Store the BCD result from memory locations AB02 H onwards starting with LSB.

Solution :

Mnemonics Comments
MVI C, 00 H. [C]=00 H
LXI H, AB00 H [HL]=AB00 H, [AB00 H]=39 (BCD)
MOV A, M [A]=39 (BCD)
INX H [HL]=AB01 H, [AB01 H]=12 (BCD)
ADD M A=A+M=39+12 =4B H
DAA A=4B+06 = 51(BCD)
JNC SKIP Jump if not carry to SKIP
INR C [C]=01 H
SKIP : INX H. [HL]=AB02 H
MOV M, A M=51 (BCD) => [AB02 H]=51 (BCD)
INX H [HL]=AB03 H
MOV M, C M=00H (BCD) => [AB02 H]=00h (BCD)
HLT
Write an ALP to rotate the content of memory location D000 H towards left
by one bit position and add original content with rotated number and store
the result from D001 H onwards.

Solution :
[A]=01 H​ => 0000 0001
Mnemonics Comments RLC => 000 00010
MVI C, 00 H [C]=00H [A] =>02 H
LXI H, D000 H. [HL]=D000 H,[D000 H]= 01 H => M=01 H
MOV A, M. [A]=01 H
RLC Rotate left by 1 bit , [A]=02 H
ADD M A=A+M => 02+ 01 = 03 H, Cy=00 H
JNC SKIP Jump if not carry to SKIP
INR C [C] = 01 H
SKIP : INX H [HL]=D001 H
MOV M, A M=03 H =>[HL] =D001 H, [D001 H]=>03 H
INX H [HL]=D002 H
MOV M, C M=00 H =>[HL] =D002 H, [D002 H]=>00 H
HLT Stop MPU
Check if hex number is even or odd :
● If the last digit of a binary number is 1, the number is odd
● If the last digit of a binary number is 0, the number is even.
● Eg.1 45 H => 0100 0101 ---> Odd number
● Eg.2 32 H => 0011 0010 ---> Even number

● How to check in instruction ?


● 45 H => 01000101
● RRC => 1010 0010 Cy = 1
● If Cy=1 => Odd Number
● If Cy=0 => Even Number
A hex number stored at memory location C000 H. Write an ALP to check
whether the number is even or not. If it's even then store FF H in C001 H
otherwise store 00 H.

Solution :

Mnemonics Comments
MVI E, FF H [E]=FF H
LXI H, C000 H [HL]=C000 H,[C000 H]=45 H
MOV A, M [A]=45 H
RRC Rotate right by 1 bit , [A]=A2 H
JNC SKIP Jump if no carry, Cy=00 H
MVI E, 00 H [E]=00 H
SKIP:INX H [HL]=C001 H
MOV M, E M=FF H =>[HL]=C001 H, [C001 H] = FF H
HLT Stop MPU
What is Palindrome number ?

● A palindrome number is a number that remains the same when digits are
reversed.
● For example, the number 12321 is a palindrome number, but 1451 is not
a palindrome number.
● Number 12321 , after reverse is 12321 => After reverse it's same that's
why it's palindrome
Write an ALP to clear register B if the number at memory 20F9 H is
palindrome otherwise store FF H in register B.

Solution :

Mnemonics Comments
MVI B, 00 H [B]=00 H [Consider number is palindrome that's why register B cleared ]
LXI H, 20F9 H [HL]=20F9 H,[20F9 H]=33 H
MOV A, M [A]=33 H
RRC Rotate right by 1 bit
RRC Rotate right by 1 bit
RRC Rotate right by 1 bit
RRC Rotate right by 1 bit , [A]=33 H
CMP M A and M are equal then Z=1
JZ SKIP Jump if Z flag set
MVI B, FF H [B]= FF H. if Z flag is not set
SKIP:HLT Stop MPU
Write an ALP to subtract the number stored in memory location 3601 H from
the number stored in memory location 3600 H. Store the positive result /
absolute difference at location 3602 H.

Solution :

Mnemonics Comments
LXI H, 3600 H [HL] = 3600 H, [3600 H] = 32 H
MOV A, M. [A] = 32 H
INX H. [HL]=3601 H,[3601 H] = 33 H
SUB M A=A-M= 32-33=01 H , Sign Flag=1
JP SKIP Jump if Positive to SKIP
MOV A, M [A]=33 H
DCX H [HL]=3600 H,[3601 H] = 32 H
SUB M A=A-M= 33-32=01 H
SKIP:STA 3602 H. [3602 H]=01 H
HLT Stop MPU
Write an ALP to fill the memory location 4500 H to 4504 with
Hexadecimal numbers 09 H to 0D H respectively.

Solution :

Mnemonics Comments
MVI B, 05 H. [B]=05 H
MVI A, 09 H [A]=09 H
LXI H, 4500 H [HL]=4500 H
UP:MOV M, A M=A => [HL]=4500 H,[4500 H]=09 H
INR A [A]=0A H
INX H [HL]=4501 H
DCR B [B]=04 H , Z=0
JNZ UP Jump if not zero to UP
HLT Stop MPU
Write an ALP to fill 20 consecutive memory location starting from
2501 H onwards with data AA H.

Solution :

Mnemonics Comments
MVI B, 14 H. [B]= 14 H
MVI A, AA H [A]=AA H
LXI H, 2501 H [HL]=2501 H
UP:MOV M, A M=AA H => [HL]=2501 H, [2501 H]= AA H
INX H [HL]=2502 H
DCR B [B]=13 H
JNZ UP Jump to UP if B is not Zero
HLT Stop MPU
20. Write an ALP to fill the memory locations from AB00 H an
onwards with hexadecimal number 00 H to 0F H.

Solution :

Mnemonics Comments
MVI B, 10 H [B]= 10 H
MVI A, 00 H [A]= 00 H
LXI H, AB00 H [HL]=AB00 H
UP:MOV M, A M= 00 H= > [HL]=AB00 H, [AB00 H]=00H
INR A [A]=01 H
INX H [HL]=AB01 H
DCR B [B]=0F H
JNZ UP Jump to UP if B is not Zero
HLT Stop MPU
22. Write an ALP to fill memory block from 2000 H to 2009 with data
BB H and 44 H alternately.

Solution 1: Note :
[A] = BB H
Mnemonics Comments BB H => 1011 1011
MVI B, 0A H [B]=0A H After CMA=> 0100 0100
MVI A, BB H [A] = BB H [A]= 44 H
LXI H, 2000 H [HL]=2000 H
UP :MOV M, A. M=BBH Complement of BB H is 44H
CMA [A]=44 H and complement of 44 H is BB
INX H [HL]=2001 H H
DCR B [B]=09 H
JNZ UP Jump to UP if B is not Zero
HLT Stop MPU
There is a block of memory from 2501 H to 250A H. Write an ALP
replace odd numbers with data FF H in given block.

Solution : Note :
[A]=01 H​
Mnemonics Comments 01 H => 0000 0001
MVI B, 0A H [B]=0A H RRC => 10000 000 and CY=1
LXI H, 2501 H. [HL]=2501 H ,let [2501 H]=01 H After rotation Cy is set
UP :MOV A, M [A]=01 H
RRC Rotate right by one bit, Cy=1
JNC SKIP Jump if carry is not set to SKIP
MVI M, FF H M=FF H => [HL]=2501 H ,[2501 H]=FF H
SKIP : INX H [HL]=2502 H, Let [2502 H]=02 H
DCR B [B]=09 H
JNZ UP Jump to UP if B is not Zero
HLT Stop MPU
24. There is a block of memory from 2501 H to 250A. Write an ALP
replace even numbers with data FF H in given block.

Solution :

Mnemonics Comments
MVI B, 0A H [B]=0A H
LXI H, 2501 H. [HL]=2501 H ,let [2501 H]=01 H
UP :MOV A, M [A]=01 H
RRC Rotate right by one bit, Cy=1
JC SKIP Jump if carry is set to SKIP
MVI M, FF H M=FF H => [HL]=2501 H ,[2501 H]=FF H
SKIP : INX H [HL]=2502 H, Let [2502 H]=02 H
DCR B [B]=09 H
JNZ UP Jump to UP if B is not Zero
HLT Stop MPU
A 8 bit hexadecimal number stored at memory location C000 H. Write
an ALP to count numbers of zeros in it and store count in memory
location C001 H.

Solution :

Mnemonics Comments
MVI B, 08 H [B]=08 H
MVI C, 00 H. [C]=00 H
LXI H, C000 H. [HL]=C000 H,[C000 H]=01 H
MOV A, M [A]=01 H
UP : RRC Rotate right by 1 bit
JC SKIP. Jump to SKIP if Carry is set
INR C [C]=01 H
SKIP:DCR B [B]=07 H
JNZ UP Jump to UP if register B is not zero
INX H [HL]=C001 H
MOV M, C M=07 H,
HLT Stop MPU
Write an ALP to increment the content of alternate memory location each by
2 from 1051 H to 1060 H
1051 H 01 H
1052 H 02 H

Solution : 1053 H 03 H
1054 H 04 H
1055 H 05 H
Mnemonics Comments
1056 H 06 H
MVI B, 10 H [B]=10 H
1057 H 07 H
LXI H, 1051 H [HL]=1051 H,[1051 H]=01 H 1058 H 08 H
UP: INR M M= 02 H 1059 H 09 H
INR M M= 03 H 105A H 0A H
INX H [HL]=1052 H,[1053 H]=02 H 105B H 0B H

INX H [HL]=1053 H,[1053 H]=03 H 105C H 0C H

DCR B [B]=0F H 105D H 0D H

DCR B [B]=0E H 105E H 0E H

JNZ UP Jump to UP if register B is not zero 105F H 0F H

HLT Stop MPU 1060 H 10 H


Write an ALP to double (multiply by 2) the content of block from D001 H to
D00A H and store the double content at same memory location.
D001 H 01 H
Solution : D002 H 02 H
D003 H 03 H
Mnemonics Comments
D004 H 04 H
MVI B, 0A H [B]=0A H
LXI H, D001 H [HL]=D001 H ,[D001 H]=01 H D005 H 05 H

UP:MOV A, M. [A]=01 H D006 H 06 H


ADD M A=A+M=01+01 =02 H D007 H 07 H
MOV M, A M=02 H=>[HL]=D001 H ,[D001 H]=02 H D008 H 08 H
INX H [HL]=D002 H ,[D002 H]=02 H D009 H 09 H
DCR B [B]=09 H
D00A H 0AH
JNZ UP Jump to UP if register B is zero
HLT Stop MPU
Write an Assembly Language Program to find absolute difference of two hex
numbers stored in memory locations 5000H and 5001H. Store the result at
5002H.
Label Mnemonics Comments
LXI H, 5000 H Set H-L pointer to 5000 H
MOV A, M Move 1st no. in Accumulator
INX H Increment H-L pair
SUB M Subtract 2nd no. form 1st no.
JP GO If positive result, jump to GO
MOV A , M Move 2nd no . in ACC
DCX H Decrement H-L pair
SUB M Subtract1st no. From 2nd no.
GO STA 5002 H Store result in 5002 H
HLT Stop
Write an Assembly Language Program to find largest number in a block of memory
starting from 7000 H. The length of the block is stored at 6FFF H. Store the result
at the end of the block.

Label Mnemonics Comments


LXI H, 6FFF H Set H-L pair to 6FFF H
MOV C, M Set counter
MVI A, 00 H Set largest A= 00 H
BACK INX H Increment H-L pair
CMP M Compare no in memory with no in ACC
JNC AHEAD If no in ACC is larger, jump to AHEAD
MOV A, M Move larger no in ACC
AHEAD DCR C Decrement counter
JNZ BACK Repeat if counter ≠ 0
INX H Increment H-L pair
MOV M, A Store largest number at the end of block
HLT Stop
A block of data is stored in memory locations starting from 3001 H. The length of the
block is at 3000 H. Write an Assembly Language Program that searches for the first
occurrence of data AO H in given block. Store the address of this occurrence in HL
pair. If the number is not found then HL pair should contain 0000 H

Label Mnemonics Comments


LXI H, 3000 H ; Set H-L pair to 3000 H
MOV C, M ; Set counter
MVI A, AO H ; Move AO H to A
BACK INX H ; Increment H-L pair
CMP M ; Check if memory contains AO H
JZ END ; If yes ,then found
MOV A, M ; Move larger no in A
AHEAD DCR C ; Decrement counter
JNZ BACK ; Repeat if counter # 0
LXI H, 0000 H ; Set H-L pair to 0000 H
END HLT ; Stop
Write a Assembly Language Program to find sum of ten hex numbers stored in consecutive
memory locations starting from 4000 H. Store the two byte result at the end of the block beginning
with lower byte.
Label Mnemonics Comments

MVI C, 0A H ; Set counter to 0A H


MVI A,00H ; Initialise A
MOV B, A ; Initialise reg. B
BACK LXI H, 4000 H ; Set H-L pair to 4000 H
ADD M ; Add contents of memory with A
JNC AHEAD ; If no carry, jump AHEAD
INR B ; Add carry to MSB of sum
AHEAD INX H ; Increment H-L pair
DCR C ; Decrement counter
JNZ BACK ; Repeat if counter # 0
MOV M, A ; Store LSB of Sum
INX H ; Increment H-L pair
MOV A, B ; Move contents of B to accumulator
HLT ; Stop
Write a n Assembly Language Program for 8 bit number stored in memory
location BABA H. Separate the two nibbles and multiply it. Store the result
in memory location DADAH.
LXI H, BABA ; Load HL reg. pair with BABA H
MOV A, M ; move memory content to reg. A.
ANI OFH ; Logically AND OFH with accumulator
MOV B, A ; Move reg. A data to reg. B
MOV A, M ; move memory content to accumulator
ANI FOH ; Logically AND FOH with accumulator
RRC ; Rotate accumulator right by 1 bit
RRC ; Rotate accumulator right by 1 bit
RRC ; Rotate accumulator right by 1 bit
RRC ; Rotate accumulator right by 1 bit
MOV C, A ; move reg. A data to reg. C
INX H ; Increment HL reg. Pair by 1
MOV M,B ; move reg. B data to memory
INX H ; Increment HL reg. Pair by 1
MOV M, C ; move reg. C data to memory
SUB A ; Clear accumulator
ADD B ; Add reg. B data with accumulator
DCR C ; Decrement Reg. C databy1
JNZ ; Jump if not zero jump on specify label
STA DAD A ; Store accumulator data to DAD AH m.L.
HLT ; Stop
A block of data is stored from memory location D001H to D005H. copy the contents
of block to another block starting from 2501H.

LX1 H, D001H ; load HL reg. pair with D001H


LXI B, 2501H ; load BC reg. pair with 2501H
MVID , 05H ; move 05 data to reg . D
X MOV A, M ; move memory content to acc.
SATX B ; store BC reg. pair content to acc.
INX H ; Increment HL reg. pair by 1
INX B ; Increment BC reg. pair by 1
INR B ; Increment reg. B content by 1
DCR D ; Decrement D reg. content by 1
JNZ X ; Jump if not zero to specify label
HLT ; Stop up
Write a program to subtract 3 Byte integer in register EHL from another 3 Byte integer in
BCD. The result should be placed in BCD register keeping theintegersin
EHL undisturbed.
STC ; set carry flag
cmc ; complement carry flag
MOV A , D ; move reg . D content to acc .
SUB L ; subtract reg. L content from acc. coil
SATX B ; store BC reg. pair content to acc.
INXH ; Increment HL reg. pair by 1
INX B ; Increment BC reg. pair by 1
INR B ; Increment reg. B content by 1
DCR D ; Decrement D reg. content by 1
JNZ X ; Jump if not zero to specify label
HLT ; Stop up
A block of data is stored in memory location from 3330H. Length of block is stored
at 2FFFH. Write a program to find 2's compliment of each data in a Block and store the
result from memory location 4100H.

LXI D,4100 H ; Load DE reg. pair with 4100 H m.L.


LXI H, 2FFFH ; Load HL reg. pair with 8FFFH m.L.
MOV C, m ; Move memory content to reg. C.
INX H ; Increment HL reg. Pair by 1 m.L.
MOV A, m ; move memory content to accumulator
CMA ; complement accumulator content
INR A ; Increment reg. A content by 1
STAX D ; Store acc. Content to DE reg.
INX H ; Increment HL reg. Pair by 1 m.L.
INX D ; Increment DE reg pair by 1 m.L.
DCR C ; Decrement C reg. Content by 1.
JNZ Jump if not zero jump to specify
HLT Stop up
A block of data is stored from memory location C001H and length is stored in C000H.
Write a program to find the sum of series and store the sum in CO50H and
CO51H
MVI A, 00H ; move 00H data to reg. A
MVI B 00H ; complement carry flag
LXI H, C000H ; Load HL reg. Pair to C000H
MOV C,M ; move memory content torque
INX H ; Increment HL reg. By 1
ADD m ; Add memory content with ac content
JNC ; Jump if not carry jump to specific label
INRB ; Increment reg. B content by 1
INX H ; Increment HL reg. Pair by 1 m.L.
DCR C ; Decrement reg. C content by1
JNZ ; Jump if not zero jump on specific label
STA CO50H ; Store acc. Content at label content
MOV A, B ; move reg. B content to reg. A
STA CO51H ; Store acc. Content to C051 m.L.
HLT ; Stop up
Write a program that divides two 1 byte hex number where the dividend is stored in
4060H and divisor in 406H stored the quotient and remainder in next two
consecutive memory location respectively.

MVI B, 00H ; move 00H data to reg. B


LXIH, 4060H ; load HL reg. pair with 4060 mL.
MOV A , M ; move memory content to acc .
INX H ; Increment HL reg. pair by 1
CMP M ; compare memory content with acc.
JNC ; Jump if carry jump on specify
SUB M ; subtract memory content from acc. content
INR B ; Increment B reg. Content by 1
JMP ; Jump unconditional to specify
INX H ; Increment HL reg. pair to
MOV M,B ; move reg . B content to
INX H ; Increment HL reg. pair by
MOV M,A ; move reg. A content to acc.
HLT ; Stop up

You might also like