MC Manual Updated
MC Manual Updated
Before Execution:
20: 11 22 33 44 55 66 77
40: 00 00 00 00 00 00 00
After Execution:
20: 11 22 33 44 55 66 77
40: 11 22 33 44 55 00 00
org 0000h
mov dptr,#2000h
mov r0,#50h
mov r1,#20h
mov r2,#05h
rep:movx a,@dptr
push dph
push dpl
mov dph,r1
mov dpl,r0
movx @dptr,a
inc dptr
mov r1,dph
mov r0,dpl
pop dpl
pop dph
inc dptr
djnz r2,rep
end
Before Execution:
X:2000: 11 22 33 44 55 66 77
X:2050: 00 00 00 00 00 00 00
After Execution:
X:2000: 11 22 33 44 55 66 77
X:2050: 11 22 33 44 55 00 00
Before Execution:
After Execution:
Registers: r0=45h, r1=55h, r2=00h
20: 10 20 30 40 50
40: 11 22 33 44 55
Org 0000h
mov r0,#10h
mov dptr,#0000h
mov r2,#06h
repeat: movx a,@dptr
xch a,@r0
movx @dptr,a
inc r0
inc dptr
djnz r2,repeat
end
Before Execution:
After Execution:
Registers: r0=16h, r2=00h, dptr=0006h
I:10: 10 20 30 40 50
X:0000: 11 22 33 44 55
org 0h
mov r0,#34h // Number 1
mov r1,#35h // Number 2
clr c
mov a,@r0
mov r2,a
mov a,@r1
add a,r2
mov r5,a
clr a
addc a,#00h
mov r6,a
end
Before Execution
R0 R1 R5 R6
34 35 xx xx
After Execution
R0 R1 R5 R6
34 35 69 00
org 0h
mov r0,#34h // Number 1
mov r1,#35h // Number 2
clr c
mov a,@r0
mov r2,a
mov a,@r1
subb a,r2
mov r5,a
clr a
addc a,#00h
mov r6,a
end
Before Execution
R0 R1 R5 R6
34 35 xx xx
After Execution
R0 R1 R5 R6
34 35 69 00
org 0h
mov a,30h
mov b,31h
mul ab
mov 32h,a
mov 33h,b
end
Output:
Before Execution:
30h: 05 06 00 00
After Execution:
30: 05 06 1E 00
org 0h
mov r2,#0fh
mov r3,#05h
mov a,r3
cjne a,#00h,proceed
sjmp last
proceed: mov a,r2
mov b,r3
div ab
mov r4,a
mov r5,b
last: lcall 0003h
end
Before Execution:
R2= 0f,r3=05,r4=xx,r5=xx
After Execution:
R2= 0f, r3=05, r4=05,r5=00
Register Window after Execution:
9. Write an ALP to separate positive and negative in a given array.
org 0h
mov r0,#30h
mov r1,#40h
mov r2,#05h
mov b,r2
rep: mov a,@r0
jb acc.7,skip
mov @r1,a
inc r1
skip: inc r0
djnz r2,rep
mov r1,#50h
mov r0,#30h
rep1: mov a,@r0
jnb acc.7,skip1
mov @r1,a
inc r1
skip1: inc r0
djnz b,rep1
sjmp $
end
30h: 56 89 9A 22 11 30h: 56 89 9A 22 11
40h: 00 00 00 00 00 40h: 56 22 11 00 00
50h: 00 00 00 00 00 50h: 89 9A 00 00 00
30h: 56 89 9A 22 11 30h: 56 89 9A 22 11
40h: 00 00 00 00 00 40h: 56 9A 22 00 00
50h: 00 00 00 00 00 50h: 89 11 00 00 00
Before Execution:
30: 11 06 05 23 54
After Execution:
30: 05 06 11 23 54 30: 54 23 11 06 05
end
Before Execution:
20: 11 05 38 FE 01
40: 00
After Execution:
i. For largest ii. For Smallest
20: 11 05 38 FE 01 20: 11 05 38 FE 01
40: FE 40:01
Counters
13. Write an ALP for Decimal UP-Counter. (Ex: Count from 05 to 55)
org 0h
rpt: mov r6,#05h
nxt: lcall delay
mov a, r6
add a, #01
DA A
mov r6,a
cjne r6, #56h, nxt
sjmp rpt
delay: mov r2, #0ffh
rep2: mov r3, #0ffh
rep1: mov r4, #0ffh
rep: djnz r4,rep
djnz r3, rep1
djnz r2, rep2
ret
end
.
55
14. Write an ALP for Decimal DOWN-Counter. (Ex: Count from 50 to 10)
org 0h
rpt: mov r6,#50h
nxt: lcall delay
mov a,r6
add a,#99h
DA A
mov r6,a
cjne r6,#09h,nxt
sjmp rpt
delay: mov r2,#0ffh
rep2: mov r3,#0ffh
rep1: mov r4,#0ffh
rep: djnz r4,rep
djnz r3,rep1
djnz r2,rep2
ret
end
Output: I: 0x06
50
.
10
15. Write an ALP for Hexadecimal UP-Counter. (Ex: Count from 11h to
AAh)
org 0h
rpt: mov r6,#11h
nxt: lcall delay
inc r6
cjne r6,#0ABh, nxt
sjmp rpt
delay: mov r2,#0ffh
rep2: mov r3,#0ffh
rep1: mov r4,#0ffh
rep: djnz r4,rep
djnz r3,rep1
djnz r2,rep2
ret
end
Output: I: 0x06
11
.
AA
16. Write an ALP for Hexadecimal DOWN-Counter. (Ex: Count from AAh
to 55h
org 0h
rpt: mov r6,#0AAh
nxt: lcall delay
dec r6
cjne r6,#54h, nxt
sjmp rpt
delay: mov r2,#0ffh
rep2: mov r3,#0ffh
rep1: mov r4,#0ffh
rep: djnz r4,rep
djnz r3,rep1
djnz r2, rep2
ret
end
Output: I: 0x06
AA
.
55