s v i e t k a n u r u .t k
MULTIPLICATION OF TWO 8 -- BIT NUMBERS
AIM:
To perform multiplication of two 8 -- bit numbers using 8051 instruction set.
ALGORITHM:
1.
Get the data in A -- reg.2.
Get the value to be multiplied in B -- reg.3.
Multiply the two data4.
The higher order of the result is in B -- reg.5.
The lower order of the result is in A -- reg.6.
Store the results.
PROGRAM:
ORG 4100CLR CMOV A,#data1MOV B,#data2MUL ABMOV DPTR,#4500MOVX @DPTR,AINC DPTR MOV A,BMOVX @DPTR,AHERE: SJMP HERE
MVI E, 00 : Quotient = 0
LHLD 2200H : Get dividend
LDA 2300 : Get divisor
MOV B, A : Storedivisor
MVI C, 08 : Count = 8
NEXT: DAD H : Dividend = Dividend x 2
MOV A, E
RLC
MOV E, A : Quotient = Quotient x 2
MOV A, H
SUB B : Is most significant byte of Dividend > divisor
JC SKIP : No, go to Next step
MOV H, A : Yes, subtract divisor
INR E : and Quotient = Quotient + 1
SKIP:DCR C : Count = Count - 1
JNZ NEXT : Is count =0 repeat
MOV A, E
STA 2401H : Store Quotient
Mov A, H
STA 2410H : Store remainder
HLT
Lhld 2000h
sphl
lhld 3000h
xchg
lxi h,0000h
lxi b,0000h
next: dad sp
jnc ahead
inx b
ahead: dcx d
mov a,e
ora d
jnz next
shld 2008h
mov l,c
mov h,b
shld 200ah
hlt
Signed numbers are "plus" and "minus" numbers.
MVI A, 30h MVI B 20h MUL A,B OUT port1 HLT
Positive signed numbers with have a + Positive integers will not.
mul is used for unsigned multiplication whereas imul is used for signed multiplication. Algorithm for both are same, which is as follows:when operand is a byte:AX = AL * operand.when operand is a word:(DX AX) = AX * operand.But, the difference is that mul instruction multiplies only unsigned numbers whereas imul instruction does the same for signed numbers.
Signed numbers are used for:TemperatureMoney, Accounting, or EconomyMath Problems
its cuz ur ugly........
ADD B in a microprocessor means to add the contents of the accumulator to the B register and store the result in the accumulator. Flags are set according to the result - Z if zero, C if an unsigned carry occurred, AC if a BCD carry occurred, N if the result is signed negative, O if the parity is odd, OV if a signed overflow occurred. Note that not every microprocessor has every flag listed.
The range for signed numbers is -128 to +127. The range for signed numbers is 0 to 255.
rules of operation sign of numbers
i'm so sorry... i don't know also...
Whenever a computer program uses integers - for example, in a game, to store a player's score, but also for many other situations - this will internally be stored as a binary number. This number may be signed or unsigned. Some programming languages, such as Java, only use signed numbers. In other cases, the programmer may decide to use either signed or unsigned numbers, depending on his needs.
39