UMBC | CMSC 391 -- Programming Microcontrollers |
Boolean | Mnemonic | Example |
---|---|---|
AND | ANL | 11001100 11010000 ------------ 11000000 |
OR | ORL | 11001100 11010000 ------------ 11011100 |
XOR | XRL | 11001100 11010000 ------------ 00011100 |
NOT | CPL | 11001100 ------------ 00110011 |
Mnemonic | Operation | Value | Becomes | Carry |
---|---|---|---|---|
RL | Rotate Left | 00001001 | 00010010 | |
RLC | Rotate Left with Carry | 00001001 | 00010010 | 0 |
RR | Rotate Right | 00001001 | 10000100 | |
RRC | Rotate Right with Carry | 00001001 | 00000100 | 1 |
SWAP | Exchange the low and high nibbles | 11110000 | 00001111 |
Note: A slash ("/") preceding the operand in the assembly language indicates that the logical complement of the addressed bit is used as the source value, but the source bit itself is not affected.
2000: .org 0x2000 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Equates ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2000: .equ bank0, 00000000h 2000: .equ bank1, 00001000b 2000: .equ bank2, 00010000b 2000: .equ bank3, 00011000b ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Code ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; begin: 2000: A2 00 mov C, 00h ; clear the carry flag 2002: 92 7F mov 7Fh, C ; mov the carry into ; byte 2Fh see p.141 ;; ;; The next three instructions do the same ;; exact thing. ;; 2004: 92 AF mov EA, C ; IE.EA gets the carry ; see p.328 2006: 92 AF mov IE.7, C 2008: 43 A8 80 orl IE, #80h ; ;; ;; end of string is null or high bit turned on ;; ;; We are in external memory because of .org 2000h ;; so we have to use indirect and the A register. ;; 200B: 90 20 2B mov DPTR, #nr 200E: E0 movx A,@DPTR 200F: 54 80 anl A, #80h ; If not EOS, A is ; zero ;; ;; Just a "bit" more ;; 2011: D2 D4 setb RS1 ; setb PSW.RS1 ; This is an error 2013: D2 D4 setb PSW.4 ;; ;; change register banks ;; ;; Each instruction is 1 byte, 1 cycle ;; Total: 2 bytes, 2 cycles 2015: D2 D3 setb RS0 2017: D2 D4 setb RS1 ; 11 -- gives bank 3 ;; Total 2 bytes, 1 cycle, but lousy style 2019: 43 D0 18 orl PSW, #00011000b ;; same thing, but better style because it ;; it is more obvious what you are trying ;; to do. 201C: 43 D0 18 orl PSW, #bank3 ;; Dumb but doable -- 3 bytes, 3 cycles 201F: D3 setb C ; 1 byte, 1 cycle 2020: 92 D3 mov RS0, C ; 2 bytes, 2 cycles ;; Toggle between bank 3 and bank 1 2022: B2 D3 cpl RS0 ;; ;; If we can set it, we can clear it 2024: C2 D3 clr RS0 ;; The last item is a point that is not really clear ;; in the documentation. The only difference is ;; the slash in the front of the addressed bit. ;; At run time, the bit is complemented and used ;; in the OR operation, but the bit itself is not ;; changed. 2026: A0 7F orl C, /7Fh 2028: 72 7F orl C, 7Fh 202A: 22 ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Data ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 202B: C1 nr: .db 'A' + 80h