Assembly language

Is there any one assembly expert and write programs for microcontroller?

I have to ask some things related to how to write program for microcontroller. I have concepts of assembly language and some how know of microcontroller.

Ask your questions and someone might be able to help you.

which one you talking about z-80 based 6502 based or 68000 based these chip instructions are industry standard n 100s of different versions ticking for last 20 plus years in coffee makers to washing machines to car electronics etc, you need to specify, i hate kasoti threads

i am a student of computer science BS(CS). Mine uncle has a shop of electronics in which he makes the flashing lights of the front of Hino buses. Lights blinks with different ways. he use a program which he buy from Lahore. And burn the Atmel 89c2051 with that program. First i want to understand the program. then want to make changes according to him for a new design. i have learn assembly in last semester. i have the program file and hex converter and a elecronics simulator software.

Post the code.

I have worked with Microchip's microcontrollers. I don't like Atmel.

$mod51

ORG 00H

MOV R1,#05

MOV P1,#0FFH

MAIN: MOV P1,#0000000z1B

ACALL DELAY

MOV P1,#10000111B

ACALL DELAY

DJNZ R1,MAIN

MOV R1,#05

MOV P1,#0FFH

WAQAS:

MOV P1,#00000111B

ACALL DELAY

MOV P1,#01000111B

ACALL DELAY

DJNZ R1,WAQAS

MOV R1,#05

NIGHT:

MOV P1,#00000111B

ACALL DELAY

MOV P1,#00100111B

ACALL DELAY

DJNZ R1,NIGHT

MOV R1,#05

NIXHT:

MOV P1,#00000111B

ACALL DELAY

MOV P1,#00010111B

ACALL DELAY

DJNZ R1,NIXHT

MOV R1,#05

NIXHT1:

MOV P1,#00000111B

ACALL DELAY

MOV P1,#00001111B

ACALL DELAY

DJNZ R1,NIXHT1

MOV R1,#05

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

MOV P1,#11111111B

FLOP:

MOV P1,#01111111B

ACALL DELAY

MOV P1,#11111111B

ACALL DELAY

DJNZ R1,FLOP

MOV R1,#05

FLAP:

MOV P1,#10111111B

ACALL DELAY

MOV P1,#11111111B

ACALL DELAY

DJNZ R1,FLAP

MOV R1,#05

FLOA:

MOV P1,#11011111B

ACALL DELAY

MOV P1,#11111111B

ACALL DELAY

DJNZ R1,FLOA

MOV R1,#05

FLOX:

MOV P1,#11101111B

ACALL DELAY

MOV P1,#11111111B

ACALL DELAY

DJNZ R1,FLOX

MOV R1,#05

FLOX1:

MOV P1,#11110111B

ACALL DELAY

MOV P1,#11111111B

ACALL DELAY

DJNZ R1,FLOX1

MOV R1,#05

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

FLIP:

MOV P1,#00001111B

ACALL DELAY

MOV P1,#00010111B

ACALL DELAY

MOV P1,#00100111B

ACALL DELAY

MOV P1,#01000111B

ACALL DELAY

MOV P1,#10000111B

ACALL DELAY

DJNZ R1,FLIP

MOV R1,#05

SHAD:

MOV P1,#10000111B

ACALL DELAY

MOV P1,#01000111B

ACALL DELAY

MOV P1,#00100111B

ACALL DELAY

MOV P1,#00010111B

ACALL DELAY

MOV P1,#00001111B

ACALL DELAY

DJNZ R1,SHAD

MOV R1,#05

FAXRT:

MOV P1,#00001111B

ACALL DELAY

MOV P1,#00011111B

ACALL DELAY

MOV P1,#00111111B

ACALL DELAY

MOV P1,#01111111B

ACALL DELAY

MOV P1,#11111111B

ACALL DELAY

MOV P1,#00000111B

ACALL DELAY

DJNZ R1,FAXRT

MOV R1,#05

FAXRE:

MOV P1,#00001111B

ACALL DELAY

MOV P1,#10001111B

ACALL DELAY

MOV P1,#11001111B

ACALL DELAY

MOV P1,#11101111B

ACALL DELAY

MOV P1,#11110111B

ACALL DELAY

MOV P1,#11111111B

ACALL DELAY

DJNZ R1,FAXRE

MOV R1,#05

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

FASRT:

MOV P1,#11111111B

ACALL DELAY

ACALL DELAY

MOV P1,#00000111B

ACALL DELAY

ACALL DELAY

DJNZ R1,FASRT

MOV R1,#05

XAIN: MOV P1,#00000111B

ACALL DELAY

MOV P1,#10000111B

ACALL DELAY

DJNZ R1,XAIN

MOV R1,#05

MOV P1,#0FFH

XAQAS:

MOV P1,#00000111B

ACALL DELAY

MOV P1,#01000111B

ACALL DELAY

DJNZ R1,XAQAS

MOV R1,#05

XIGHT:

MOV P1,#00000111B

ACALL DELAY

MOV P1,#00100111B

ACALL DELAY

DJNZ R1,XIGHT

MOV R1,#05

XIGHT1:

MOV P1,#00000111B

ACALL DELAY

MOV P1,#00010111B

ACALL DELAY

DJNZ R1,XIGHT1

MOV R1,#05

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

XIXHT:

MOV P1,#00000111B

ACALL DELAY

MOV P1,#00001111B

ACALL DELAY

DJNZ R1,XIXHT

MOV R1,#05

XLOP:

MOV P1,#01111111B

ACALL DELAY

MOV P1,#11111111B

ACALL DELAY

DJNZ R1,XLOP

MOV R1,#05

XLAP:

MOV P1,#10111111B

ACALL DELAY

MOV P1,#11111111B

ACALL DELAY

DJNZ R1,XLAP

MOV R1,#05

XLOA:

MOV P1,#11011111B

ACALL DELAY

MOV P1,#11111111B

ACALL DELAY

DJNZ R1,XLOA

MOV R1,#05

XLOX:

MOV P1,#11101111B

ACALL DELAY

MOV P1,#11111111B

ACALL DELAY

DJNZ R1,XLOX

MOV R1,#05

XLOX1:

MOV P1,#11110111B

ACALL DELAY

MOV P1,#11111111B

ACALL DELAY

DJNZ R1,XLOX1

MOV R1,#05

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

XLIP:

MOV P1,#00001111B

ACALL DELAY

MOV P1,#00010111B

ACALL DELAY

MOV P1,#00100111B

ACALL DELAY

MOV P1,#01000111B

ACALL DELAY

MOV P1,#10000111B

ACALL DELAY

DJNZ R1,XLIP

MOV R1,#05

XHAD:

MOV P1,#10000111B

ACALL DELAY

MOV P1,#01000111B

ACALL DELAY

MOV P1,#00100111B

ACALL DELAY

MOV P1,#00010111B

ACALL DELAY

MOV P1,#00001111B

ACALL DELAY

DJNZ R1,XHAD

MOV R1,#05

XAXRT:

MOV P1,#00000111B

ACALL DELAY

MOV P1,#00001111B

ACALL DELAY

MOV P1,#00011111B

ACALL DELAY

MOV P1,#00111111B

ACALL DELAY

MOV P1,#01111111B

ACALL DELAY

MOV P1,#11111111B

ACALL DELAY

DJNZ R1,XAXRT

MOV R1,#05

XAXRE:

MOV P1,#00000111B

ACALL DELAY

MOV P1,#10000111B

ACALL DELAY

MOV P1,#11000111B

ACALL DELAY

MOV P1,#11100111B

ACALL DELAY

MOV P1,#11110111B

ACALL DELAY

MOV P1,#11111111B

ACALL DELAY

DJNZ R1,XAXRE

MOV R1,#05

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

XASRT:

MOV P1,#11111111B

ACALL DELAY

ACALL DELAY

MOV P1,#00000111B

ACALL DELAY

ACALL DELAY

DJNZ R1,XASRT

MOV R1,#05

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

LJMP MAIN

DELAY:

JNB P3.2,DELAY1

JNB P3.3,DELAY2

JNB P3.4,DELAY3

JB P3.2,DELAY1

JB P3.3,DELAY1

JB P3.4,DELAY1

DELAY1:

MOV R0,#007

FWLL: MOV R2,#100

HWLL: MOV R3,#100

DJNZ R3,$

DJNZ R2,HWLL

DJNZ R0,FWLL

RET

DELAY2:

MOV R0,#020

FZLL: MOV R2,#100

HZLL: MOV R3,#100

DJNZ R3,$

DJNZ R2,HZLL

DJNZ R0,FZLL

RET

DELAY3:

MOV R0,#040

FALL: MOV R2,#100

HALL: MOV R3,#100

DJNZ R3,$

DJNZ R2,HALL

DJNZ R0,FALL

RET

END

There are only few instruction you need to learn if you want to understand the this code

-MOV instruction is only used with immediate addressing here, R1 is register P1 is port, there are 8 registers and 3 ports i think

-ACALL calls routine unconditionaly

-RET returns from a subroutine

-DJNZ decrement and jump if not zero

DJNZ R1,LABEL

decrements R1 and will jump to LABEL until R1 is not zero

DJNZ R1,$ ($ is current code address)

this one with $ is used to create delay i think

-JB

JB P3.2,DELAY1

jumps to the label if the bit P3.2 is set

-JNB

similiar to JB, jump if the bit is not set

LJMP

long jump to the specified address, there are no restriction on the address here like other kind of jmps

PS:I have done 8051 programming way back in college so some of things written may not be completely accurate.

thanks.much informative. i am still trying to understand this program.