This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Pls assist to clarify if this C51 code is accurate?!

Hi All
Based on the following assemble code, I wrote a program with the same function in C51 code. However, my program seems to be inaccurate because I failed to collect data after its operation.(This means the complier passes, but I do not obtain the reslut that I have expected!)
If anyone could kindly point out the inaccuracy of my program--C51 code, I will be very grateful to you guys.

N.B. :
The assemble code shown below is correct,you do not have to check them anymore. Please simply review through C51 code. Thanks a lot :)

[assemble code start]

X EQU 30H
Y EQU 31H
EX EQU 32H
EY EQU 33H
XBUFFER EQU 34H
YBUFFER EQU 35H
DBUF EQU 36H

MOV X,#01
MOV Y,#01
MOV EX,#20
MOV EY,#80
MOV DBUF,#FFH
CALL DDRAMWR_BW_BLOCK
.
.
.
;--------------------------------------------
DDRAMWR_BW_BLOCK:
PUSH 1
PUSH 2
PUSH 3
PUSH 4

CLR C
MOV A,EX
SUBB A,X
INC A
MOV XBUFFER,A
CLR C
MOV A,EY
SUBB A,Y
INC A
MOV YBUFFER,A

MOV A,Y
DEC A
MOV B,#20
MUL AB

CLR C

ADD A,X
CJNE A,#00H,BW62_BLK
DEC B

BW62_BLK: DEC A
MOV R1,A
MOV A,B
ADDC A,#0
MOV R2,A
CLR C

BW22_BLK: MOV R3,XBUFFER
BW12_BLK:
MOV A,DBUF
CPL A
CALL DATA_WR

BW52_BLK: INC R1

MOV A,R1
DEC A
CJNE A,#255,BW32_BLK

MOV R1,#0
INC R2
CLR C
BW32_BLK: DJNZ R3,BW12_BLK

CLR C
MOV A,#20
SUBB A,XBUFFER
ADD A,R1
MOV R1,A
MOV A,R2
ADDC A,#0
MOV R2,A
DJNZ YBUFFER,BW22_BLK

POP 4
POP 3
POP 2
POP 1

RET

;--------------------------------------

DATA_WR: ;Write data to MEM thru 1352
PUSH DPL
PUSH DPH
; CLR C
MOV DPL,R1
MOV DPH,R2
CLR P3.4 ;MEMCS#=0,
CLR P3.1
CLR P3.0
CLR P1.0 ;Ereset=0;
MOVX @DPTR,A
SETB P3.4 ;MEMCS#=1
POP DPH
POP DPL
RET
;--------------------------------------------[assemble code end]


[c51 code start]

unsigned char xdata * data Addr;
Show_bar(0x01,0x01,0x20,0x80,0xff);

//==================
void Show_bar(unsigned char x, unsigned char y,unsigned char ex, unsigned char ey,unsigned char DBUF)
{
unsigned char c,x1,y1,YHL,YH,YL,xbuffer,ybuffer;
CY=0;
c=CY;
xbuffer=(ex-x)+1;
ybuffer=(ey-y)+1;

YHL=(y-1)*0x14;
YH=(YHL&0xff00)>>8;
YL=(YHL&0x00ff);

c=0;
YL=YL+x;
if(YL=!0)
{
x1=YL--;
y1=YL+0;
}
else
{
YH--;
x1=YL--;
y1=YL+0;
}

loop1:
if(ybuffer!=0)
{
loop:
if(xbuffer!=0)
{
DBUF=~DBUF;

P3_4=0;
P3_1=0;
P3_0=0;
P1_0=0;
*Addr=DBUF;
P3_4=1;


x1++;
x1--;
if(x1!=255)
{
xbuffer--;
}
else
{
x1=0;
y1++;
c=0;
}
goto loop;
}
else
{
c=0;
x1=0x14-xbuffer+x1;
y1=y1+c+0;
}
ybuffer--;
goto loop1;
}
}
//=========================
[c51 code end]

0