Sunday, 22 December 2013

8051 development board Exp.10 74ls164 74hc164 Serial in parallel out assembly code tutorial

org 00h
jmp start
org 0080h
mov scon,#00000000b ;set UART to MODE0 scon = serial control
start:
mov dptr,#table ;set data pointer to the TABLE
loop:clr a ;clear ACC
movc a,@a+dptr ;get data from TABLE
cjne a,#03,a1 ;
jmp start ;
a1: cpl a ;reverse the data  0000 0011 ->  1111 1100
mov 30h,a ;store ACC at 30H = 1111 1100
mov sbuf,30h ;
loop1:jbc ti,loop2 ; ti is a flag set when a byte is received or transmitted
jmp loop1 ;
loop2: call delay ;
inc dptr ;
jmp loop
DELAY: ;
MOV R5,#255
D3:MOV R2,#255
D4: DJNZ R2,D4
DJNZ R5,D3
RET

table:

db 01h,02h,04h,08h ;left shift
db 10h, 20h,40h,80h
db 01h,02h,04h,08h
db 10h, 20h,40h,80h
db 80h,40h,20h,10h ;right shift
db 08h, 04h,02h,01h
db 80h,40h,20h,10h
db 08h, 04h,02h,01h
db 00h,0ffh,00h,0ffh ;
db 03h
END

No comments:

Post a Comment