Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

in help in Keil uVision3 & ASM

Status
Not open for further replies.

thefalcon

New Member
hi all

can any one help me plz to compile the following code in Keil for AT89C51.

Code:
ORG 0000H    
                                                                                
AJMP MAIN				; go to main program
ORG 0003H

INT0OK: 
	MOV P0,#00H			; INT0 ISR routine for choosing the
	JB 07H,INT00OK		; segment of display were we can 
	RETI				; change it
INT00OK: 
	AJMP INT0
	ORG 0013H
	JB 07H,INT1OK		; INT1 ISR routine for change the
	CPL 02H				; the segment           or
	RETI				; or change the counter for up or
INT1OK: 
	PUSH A				; down countering
	MOV P0,#00H
	MOV A,R5
	CJNE A,#00H,DD9
	AJMP CHSEG0
DD9: 
	CJNE A,#01H,DD10
	AJMP CHSEG1
DD10: 
	CJNE A,#02H,DD11
	AJMP CHSEG2
DD11: 
	CJNE A,#03H,DD12
	AJMP CHSEG3
DD12: 
	MOV R5,#00H
	RETI

ORG 0080H

MAIN: 
	MOV IE,#85H				; start the main program
	MOV TMOD,#25H			; timer 1=timer , timer0= counter
	MOV DPTR,#0500H                                                   
	MOV P3,#0FFH			; p3 as input
	MOV R3,#00H
	MOV R4,#00H
	MOV R5,#00H
	MOV R0,#00H
	MOV R1,#00H
	MOV R2,#00H
	MOV P2,#11111110B
	CLR 02H
	CLR 07H
	CLR 03H
	SETB TR0				; start timer 0 to sense  for varying
	MOV B,TL0				; of input
MAIN2: 
	PUSH B
	MOV A,R0
	MOV B,R3				; compare number with memory
	CJNE A,B,S3
	MOV A,R1
	MOV B,R4
	CJNE A,B,S3
	CLR P2.1
	JMP S4
S3: 
	SETB P2.1
S4: 
	POP B
	MOV A,P3
	JNB ACC.1,CHANGE		; sense for counter or change
	CLR 07H
	SETB P2.6
	MOV R5,#00H
	AJMP COUNTER
CHANGE: 
	MOV P2,#11111110B		; start change display  program
	CLR P2.6
	SETB 07H
	MOV A,R5
	CJNE A,#00H,DD1
	AJMP DISSEG0
DD1: 
	CJNE A,#01H,DD2
	AJMP DISSEG1
DD2: 
	CJNE A,#02H,DD3
	AJMP DISSEG2
DD3: 
	CJNE A,#03H,DD13
	AJMP DISSEG3
DD13: 
	AJMP DISNUMBER
CHSEG0: 
	MOV A,R3
	ANL A,#00001111B
	CJNE A,#09H,DD4
	MOV A,R3
	ANL A,#11110000B
	MOV R3,A
	POP A
	ACALL DELAY
	RETI
DD4: 
	INC R3
	POP A
	ACALL DELAY
	RETI
CHSEG1: 
	MOV A,R3
	ANL A,#11110000B
	CJNE A,#90H,DD5
	MOV A,R3
	ANL A,#00001111B
	MOV R3,A
	ACALL DELAY
	POP A
	RETI
DD5: 
	MOV A,R3
	ADD A,#10H
	MOV R3,A
	ACALL DELAY
	POP A
	RETI
CHSEG2: 
	MOV A,R4
	ANL A,#00001111B
	CJNE A,#09H,DD6
	MOV A,R4
	ANL A,#11110000B
	MOV R4,A
	POP A
	ACALL DELAY
	RETI
DD6: 
	INC R4
	POP A
	ACALL DELAY
	RETI
CHSEG3: 
	MOV A,R4
	ANL A,#11110000B
	CJNE A,#90H,DD7
	MOV A,R4
	ANL A,#00001111B
	MOV R4,A
	POP A
	ACALL DELAY
	RETI
DD7: 
	MOV A,R4
	ADD A,#10H
	MOV R4,A
	POP A
	ACALL DELAY
	RETI
DISSEG0: 
	MOV A,R3				; display segment 0
	ANL A,#0FH
	MOVC A,@A+DPTR
	MOV P0,#00H
	MOV P1,A
	SETB P0.3
	AJMP MAIN2
DISSEG1: 
	MOV A,R3				; display segment 1
	ANL A,#11110000B
	SWAP A
	MOV P0,#00H
	MOVC A,@A+DPTR
	MOV P1,A
	SETB P0.2
	AJMP MAIN2
DISSEG2: 
	MOV A,R4				; display segment 2
	ANL A,#0FH
	MOV P0,#00H
	MOVC A,@A+DPTR
	MOV P1,A
	SETB P0.1
	AJMP MAIN2
DISSEG3: 
	MOV A,R4				; display segment 3
	ANL A,#0F0H
	SWAP A
	MOV P0,#00H
	MOVC A,@A+DPTR
	MOV P1,A
	SETB P0.0
	AJMP MAIN2
INT0: 
	PUSH A					; int0 for choosing segment number
	ACALL DELAY
	MOV A,R5
	CJNE A,#03H,DD8
	MOV R5,#00H
	POP A
	RETI
DD8: 
	ACALL DELAY
	INC R5
	POP A
	RETI
COUNTER: 
	ACALL DISPLAY			; start counter program
AGIN: 
	MOV A,B
	CJNE A,TL0,S
	ACALL DISPLAY
	AJMP MAIN2
S: 
	ACALL CUNTER
	MOV B,TL0
	ACALL DISPLAY
	AJMP MAIN2
CUNTER: 
	JNB 02H,UC
	SETB P2.3
	MOV A,R0
	ANL A,#0FH
	CJNE A,#00H,Y1
	MOV A,R0
	ANL A,#11110000B
	CJNE A,#00H,Y2
	MOV R0,#99H
	MOV A,R1
	ANL A,#00001111B
	CJNE A,#00H,Y3
	MOV A,R1
	ANL A,#11110000B
	CJNE A,#00H,Y4
	MOV R1,#99H
	CLR P2.3
	DEC R2
	RET
Y1: 
	DEC R0
	RET
Y2: 
	SWAP A
	DEC A
	SWAP A
	ADD A,#09H
	MOV R0,A
	RET
Y3: 
	DEC R1
	RET
Y4: 
	SWAP A
	DEC A
	SWAP A
	ADD A,#09H
	MOV R1,A
	MOV R0,#00H
	RET
UC: 
	SETB P2.2
	MOV A,R0
	ANL A,#00001111B
	CJNE A,#09H,X1
	MOV A,R0
	ANL A,#11110000B
	CJNE A,#90H,X2
	MOV A,R1
	ANL A,#00001111B
	CJNE A,#09H,X3
	MOV A,R1
	ANL A,#11110000B
	CJNE A,#90H,X4
	SETB P2.1
	INC R2
	MOV R0,#00H
	MOV R1,#00H
	CLR  P2.2
	RET
X1: 
	INC R0
	RET
X2: 
	SWAP A
	ADD A,#01
	SWAP A
	MOV R0,A
	RET
X3: 
	MOV R0,#00H
	INC R1
	RET
X4: 
	MOV R0,#00H
	SWAP A
	ADD A,#01H
	SWAP A
	MOV R1,A
	RET
DISPLAY: 
	CJNE R2,#00H,NDZ		; start display program
	AJMP DZ
NDZ: 
	MOV P0,#00H
	ACALL DELAY
	MOV A,R0
	ANL A,#00001111B
	MOVC A,@A+DPTR
	MOV P1,A
	SETB P0.3
	ACALL DELAY
	MOV A,R0
	ANL A,#11110000B
	SWAP A
	MOVC A,@A+DPTR
	MOV P0,#00H
	SETB P0.2
	MOV P1,A
	ACALL DELAY
	MOV A,R1
	ANL A,#00001111B
	MOVC A,@A+DPTR
	MOV P0,#00H
	MOV P1,A
	SETB P0.1
	ACALL DELAY
	MOV A,R1
	ANL A,#11110000B
	SWAP A
	MOVC A,@A+DPTR
	MOV P1,A
	MOV P0,#00H
	SETB P0.0
	ACALL DELAY
	RET
DZ: 
	MOV A,R1
	ANL A,#11110000B
	CJNE A,#00H,DZ1
	MOV A,R1
	ANL A,#00001111B
	CJNE A,#00H,DZ2
	MOV A,R0
	ANL A,#11110000B
	CJNE A,#00H,DZ3
DD: 
	MOV A,R0
	ANL A,#00001111B
	MOV P0,#00H
	MOVC A,@A+DPTR
	SETB P0.3
	MOV P1,A
	ACALL DELAY
	RET
DZ1: 
	SWAP A
	MOV P0,#00H
	MOVC A,@A+DPTR
	SETB P0.0
	MOV P1,A
	ACALL DELAY
	MOV A,R1
	ANL A,#00001111B
DZ2: 
	MOVC A,@A+DPTR
	MOV P0,#00H
	SETB P0.1
	MOV P1,A
	ACALL DELAY
	MOV A,R0
	ANL A,#11110000B
DZ3: 
	SWAP A
	MOVC A,@A+DPTR
	MOV P0,#00H
	SETB P0.2
	MOV P1,A
	ACALL DELAY
	JMP DD
DELAY: 
	SETB TR1				; start delay program
WAIT: 
	JNB TF1,WAIT			; use timer 1 for delay
	CLR TR1
	CLR TF1
	RET
	
	
ORG 0500H
BD: 
	14,D7,4C,87

END

it gives me many error's when i try to build Target!!!


test-5.asm(11): error A46: CODE-ADDRESS EXPECTED
test-5.asm(196): error A22: EXPRESSION TYPE DOES NOT MATCH INSTRUCTION
test-5.asm(387): error A9: SYNTAX ERROR
.........
..........


many thanks
 
Code has many basic errors.
If the code is written by you, you can easily find the bugs if you observe properly and analyze the errors.
The first error is you are jumping to a label which does not exist.
 
hi srikanthsamaga
thanks for your respond.

actually, this not my code (i google it) and i do still beginner in ASM, thats why i'm looking for help from guys prof. in this.

i really need to run this example, then will do some modifications to meet my requirements.

thanks
 
If you have googled it, then first study the code, and understand what it does, then you will get the bugs.
Simply asking for help without any inputs from you is not possible.
 
Dear srikanthsamaga

i do study ASM, but it's require months to be good in it. and i need to do this project urgently, dude...
anyways, thanks for your help and time, man.

any serious help here in this forum???
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top