Monday, May 30, 2016

8051 Program - shift a 16 bit iram value 4 bits left

; Description:
; R0 Points To A 16 Bit Location To Shift 4 Bits Left. Acc Contains
; The Value To OR In The Low 4 Bits.
;
;
; Entry Requirements:
; R0 Pointing To A 16 Bit Location In Internal RAM
; Acc With Low 4 Bits To OR In (Top 4 Bits Don't Matter)
;
; On Exit:
; Acc Contains Value Of Low 8 Bits Of 16 Bit Value
;
; Affected:
; PSW.CY, PSW.Z, PSW.P, Acc
;
; Stack:
; 1 Bytes, Not Including Space Used By Called Routines
;
; Comments:
; None
UTIL_SHIFT4L:
push acc ; Save Acc
mov a,@r0 ; Get High Byte
anl a,#00fh ; Keep Only Bits 8..11
swap a ; Move Bits 8..11 To 12..15
mov @r0,a ; Store Back
inc r0 ; Point To Low Byte
mov a,@r0 ; Get Low Byte
swap a ; Swap Bits 0..3 And 4..7
mov @r0,a ; Store Back
anl a,#00fh ; Keep Only Bits 4..7
dec r0 ; Points To High Byte
orl a,@r0 ; OR In Bits 4..7 With 8.11
mov @r0,a ; Store Back
inc r0 ; Point To Low Byte
mov a,@r0 ; Get Low Byte
anl a,#0f0h ; Clear Bits 4..7
mov @r0,a ; Store Back
pop acc ; Recover Value To OR In
orl a,@r0 ; Update Bits 0..3
mov @r0,a ; Store Back
ret ; Return To Caller


Source: Assorted Utilities, John C. Wren 11/23/96



Related topics:
8051 Program - increment 16bit in iram   |   8051 Program - compare dptr to 16bit iram value   |   8051 Program - compare dptr to ba   |   8051 Program - load dptr from (dptr) rom   |   8051 Program - load dptr from (dptr) xram   |   8051 Program - store r6r7 to dptr xram   |   8051 Program - exchange r0r1 and dptr   |   8051 Program - exchange r6r7 and dptr   |   8051 Program - memory subroutines   |   8051 Program - math subroutines   |   8051 Program - conversion subroutines

List of topics: 8051

No comments:

Post a Comment