Skip to content

Instantly share code, notes, and snippets.

@navin-mohan
Last active April 12, 2018 06:33
Show Gist options
  • Save navin-mohan/84dcc040b8f2d92d73bee4746494d73d to your computer and use it in GitHub Desktop.
Save navin-mohan/84dcc040b8f2d92d73bee4746494d73d to your computer and use it in GitHub Desktop.
8051
ORG 0000
CLR C
MOV DPTR,#0100
MOVX A,@DPTR
MOV R0,A
INC DPTR
MOVX A,@DPTR
ADD A,R0
INC DPTR
MOVX @DPTR,A
MOV A,#00H
ADDC A,#00H
INC DPTR
MOVX @DPTR,A
ORG 0000
MOV DPTR,#0100
MOVX A,@DPTR
MOV R0,A
INC DPTR
MOVX A,@DPTR
INC DPTR
MOV R1,A
MOV A,R0
MOV R3,#0000
LOOP: SUBB A,R1
JC L1
INC R3
CJNE A,#0000, LOOP
L2: MOVX @DPTR,A
MOV A,R3
INC DPTR
MOVX @DPTR,A
JMP END
L1: ADD A,R1
JMP L2
END: JMP END
ORG 0000
MOV DPTR,#0100
MOVX A,@DPTR
MOV R0,A
INC DPTR
MOVX A,@DPTR
MOV B,A
MOV A,R0
DIV AB
INC DPTR
MOVX @DPTR,A
MOV A,B
INC DPTR
MOVX @DPTR,A
ORG 0000
MOV DPTR,#0100
MOVX A,@DPTR
MOV R0,A
INC DPTR
MOVX A,@DPTR
MOV R1,A
MOV R2,#0000
MOV A,#0000
L: ADD A,R1
MOV B,A
MOV A,R2
ADDC A,#0000
MOV R2,A
MOV A,B
DEC R0
CJNE R0,#0000,L
INC DPTR
MOV B,A
MOV A,R2
MOVX @DPTR,A
MOV A,B
INC DPTR
MOVX @DPTR,A
ORG 0000H
CLR C
MOV DPTR,#0110
MOVX A,@DPTR
MOV B,A
MOV DPTR,#0100
MOVX A,@DPTR
MUL AB
MOV DPTR,#0120
MOVX @DPTR,A
INC DPTR
MOV A,B
MOVX @DPTR,A
org 0000
mov dptr,#0100
movx A,@dptr
mov R0,A
mov R1,#0
mov R3,#8
l:clr C
dec R3
rlc A
mov R2,A
mov A,R1
rrc A
mov R1,A
mov A,R2
cjne R3,#0000,l
mov A,R0
xrl A,R1
inc dptr
movx @dptr,A
ORG 0000
MOV DPTR,#0100
MOVX A,@DPTR
MOV R0,A
INC DPTR
MOVX A,@DPTR
MOV R1,A
MOV A,R0
SUBB A,R1
MOV R0,A
MOV A,#00H
ADDC A,#00H
INC DPTR
MOVX @DPTR,A
MOV A,R0
CLR C
SUBB A,#1
XRL A,#255
INC DPTR
MOVX @DPTR,A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment