1 / 15

Part II

Part II. The 8051 Assembly Language Stack, Bit Addressing, Arithmetic. A and B Registers. A and B can be accessed by direct mode as special function registers: B – address 0F0h A – address 0E0h - use “ACC” for direct mode. Address Modes.

emery-marsh
Download Presentation

Part II

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Part II The 8051 Assembly Language Stack, Bit Addressing, Arithmetic EE/CS-352: Embedded Microcontroller Systems

  2. A and B Registers • A and B can be accessed by direct mode as special function registers: • B – address 0F0h • A – address 0E0h - use “ACC” for direct mode EE/CS-352: Embedded Microcontroller Systems

  3. Address Modes Stack-oriented data transfer – another form of register indirect addressing, but using SP mov sp, #0x40 push 0x55 pop 0x0F0 Note: can only specify RAM or SFRs in direct mode to push or pop. Therefore, to push/pop the accumulator cannot use a: push 0E0h push a EE/CS-352: Embedded Microcontroller Systems

  4. pop Stacks push stack pointer stack EE/CS-352: Embedded Microcontroller Systems

  5. Address Modes Exchange Instructions – two way data transfer XCH a, 0x30 ; a  M[30] XCH a, R0 ; a  R0 XCH a, @R0 ; a  M[R0] XCHD a, @R0 ; exchange “digit” a[7..4] a[3..0] R0[7..4] R0[3..0] Only 4 bits exchanged EE/CS-352: Embedded Microcontroller Systems

  6. Bit-Oriented Data Transfer • SFRs with addresses ending in 0 or 8 are bit-addressable. (80, 88, 90, 98, etc) • Carry flag (C) (bit 7 in the PSW) is used as a single-bit accumulator • RAM bits in addresses 20-2F are bit addressable EE/CS-352: Embedded Microcontroller Systems

  7. Bit Addressable Memory 2F 2E 2D 2C 2B 2A 29 28 20h – 2Fh (16 locations X 8-bits = 128 bits) 27 26 25 24 23 22 21 20 EE/CS-352: Embedded Microcontroller Systems

  8. SFRs that are Bit Addressable SFRs with addresses of multiples of 0 and 8 are bit addressable. EE/CS-352: Embedded Microcontroller Systems

  9. Data Processing Instructions Arithmetic Instructions Logic Instructions EE/CS-352: Embedded Microcontroller Systems

  10. Arithmetic Instructions • Add • Subtract • Increment • Decrement • Multiply • Divide • Decimal adjust EE/CS-352: Embedded Microcontroller Systems

  11. Arithmetic Instructions EE/CS-352: Embedded Microcontroller Systems

  12. ADD Instructions These instructions affect 3 bits in PSW: C = 1 if result of add is greater than FF AC = 1 if there is a carry out of bit 3 OV = 1 if there is a carry out of bit 7, but not from bit 6, or visa versa EE/CS-352: Embedded Microcontroller Systems

  13. Instructions that Affect PSW bits EE/CS-352: Embedded Microcontroller Systems

  14. mov a, #0x3F add a, #0xD3 What is the value of the C, AC, OV flags after the second instruction is executed? ADD Examples EE/CS-352: Embedded Microcontroller Systems

  15. Signed Addition and Overflow 2’s complement: 0000 0000 00 0 … 0111 1111 7F 127 1000 0000 80 -128 … 1111 1111 FF -1 EE/CS-352: Embedded Microcontroller Systems

More Related