MOV Instruction MOV destination source copy source to
- Slides: 42
MOV Instruction MOV destination, source ; copy source to dest. MOV A, #55 H MOV R 0, A ; load value 55 H into reg. A ; copy contents of A into R 0 ; (now A=R 0=55 H) MOV R 1, A ; copy contents of A into R 1 ; (now A=R 0=R 1=55 H) MOV R 2, A ; copy contents of A into R 2 ; (now A=R 0=R 1=R 2=55 H) MOV R 3, #95 H ; load value 95 H into R 3 ; (now R 3=95 H) MOV A, R 3 ; copy contents of R 3 into A ; now A=R 3=95 H
Notes on Programming • Value (proceeded with #) can be loaded directly to registers A, B, or R 0 – R 7 – MOV R 5, #0 F 9 H • If values 0 to F moved into an 8 -bit register, the rest assumed all zeros – MOV A, #5 • A too large value causes an error – MOV A, #7 F 2 H
ADD Instruction • ADD A, source ; ADD the source ; operand ; to the accumulator • MOV A, #25 H ; load 25 H into A MOV R 2, #34 H ; load 34 H into R 2 ADD A, R 2 ; add R 2 to accumulator ; (A = A + R 2)
ADD Instruction and PSW
ADD Instruction and PSW
ADD Instruction and PSW
Structure of Assembly Language ORG MOV MOV ADD 0 H ; start (origin) at location 0 R 5, #25 H ; load 25 H into R 5 R 7, #34 H ; load 34 H into R 7 A, #0 ; load 0 into A A, R 5 ; add contents of R 5 to A ; now A = A + R 5 ADD A, R 7 ; add contents of R 7 to A ; now A = A + R 7 ADD A, #12 H ; add to A value 12 H ; now A = A + 12 H HERE: SJMP HERE ; stay in this loop END ; end of asm source file
Data Types & Directives DATA 1: DATA 2: DATA 3: DATA 4: DATA 6: ORG 500 H DB 28 ; DECIMAL (1 C in Hex) DB 00110101 B ; BINARY (35 in Hex) DB 39 H ; HEX ORG 510 H DB “ 2591” ; ASCII NUMBERS ORG 518 H DB “My name is Joe” ; ASCII CHARACTERS
Access RAM Locations Using Register Names
Access RAM Locations Using Addresses
Switch Register Banks
Pushing onto Stack
Popping from Stack
Stack & Bank 1 Conflict
Stack & Bank 1 Conflict
Arithmetic Instructions and Programs
Outlines • Range of numbers in 8051 unsigned data • Addition & subtraction instructions for unsigned data • BCD system of data representation • Packed and unpacked BCD data • Addition & subtraction on BCD data • Range of numbers in 8051 signed data • Signed data arithmetic instructions • Carry & overflow problems & corrections
Addition of Unsigned Numbers • ADD A, source ; A = A + source
Addition of Individual Bytes
ADDC & Addition of 16 -bit Numbers + 1 3 C 3 B 78 E 7 8 D 74
BCD Number System • Unpacked BCD: 1 byte • Packed BCD: 4 bits
Adding BCD Numbers & DA Instruction MOV ADD DA + + A, #17 H A, #28 H A, #47 H B, #25 H A, B A HEX 29 18 41 6 47 ; A=47 H first BCD operand ; B=25 second BCD operand ; hex (binary) addition (A=6 CH) ; adjust for BCD addition (A=72 H) BCD 0010 + 0001 0100 + 0100 1001 1000 0001 0110 0111 AC=1
Example
Subtraction of Unsigned Numbers • SUBB A, source ; A = A – source – CY • SUBB when CY = 0 – Take 2’s complement of subtraend (source) – Add it to minuend – Invert carry
Example (Positive Result)
Example (Negative Result)
SUBB When CY = 1 • For multibyte numbers
Multiplication of Unsigned Numbers • MUL ; A B, place 16 -bit result in B and A AB MOV MUL A, #25 H B, #65 H AB ; load 25 H to reg. A ; load 65 H in reg. B ; 25 H * 65 H = E 99 where ; B = 0 EH and A = 99 H Table 6 -1: Unsigned Multiplication Summary (MUL AB) Multiplication Operand 1 Operand 2 Result byte A B A=low byte, B=high byte
Division of Unsigned Numbers • DIV AB MOV DIV ; divide A by B A, #95 H B, #10 H AB ; load 95 into A ; load 10 into B ; now A = 09 (quotient) and ; B = 05 (remainder) Table 6 -2: Unsigned Division Summary (DIV AB) Division Numerator Denominator Quotient Remainder byte / byte A B B A
Example ( 1 of 2 )
Example ( 2 of 2 )
Signed 8 -bit Operands • Convert to 2’s complement – Write magnitude of number in 8 -bit binary (no sign) – Invert each bit – Add 1 to it
Example
Example
Example
Byte-sized Signed Numbers Ranges Decimal -128 -127 -126 …. -2 -1 0 +1 +2 … +127 Binary Hex 1000 0000 80 1000 0001 81 1000 0010 82 …………. . 1111 1110 FE 1111 FF 0000 00 0001 01 0000 0010 02 …………. . . 0111 1111 7 F
Overflow in Signed Number Operations
When Is the OV Flag Set? • Either: there is a carry from D 6 to D 7 but no carry out of D 7 (CY = 0) • Or: there is a carry from D 7 out (CY = 1) but no carry from D 6 to D 7
Example
Example
Example
- Mov destination source
- Data movement instructions in microprocessor
- Data movement instructions in microprocessor
- Anl instruction in 8051
- Source transmitter transmission system receiver destination
- Shortest path from source to destination in weighted graph
- Information source transmitter channel receiver destination
- Data destination
- Individualized instruction vs differentiated instruction
- Direct instruction vs indirect instruction
- Slave trade triangle
- Many roads lead to the same destination
- O/d matrix
- Narrow synoynm
- Destination of letter memo and email
- Destination success math
- Mock video
- Destination imagination 2001
- Intermediate transit point
- Destination imagination 2001
- Five friends decided on going to world destination
- Trusted officer of odysseus
- Destination mars
- Destination nec
- Place/location/destination plan a
- Match destination formatting excel
- The destination fitness bhopal
- Finally, it has arrived
- Apa yang dimaksud dengan source dalam komunikasi data
- Wildcard mask explained
- Methods of origin and destination study
- Factors influencing destination image
- Destination governance
- Many roads lead to the same destination
- Destination reader bookmark
- Your favourite holiday
- The ultimate destination
- Fob destination adalah
- Fob destination point adalah
- Destination america
- What color means "motorist services guidance".
- Le bonheur est une trajectoire et non pas une destination
- Tourism marketing ppt