Hi can someone please help with the explanation of this code below, more importantly how does the uC 'see' the Sqrs: line at the end of the code
I am interested in something similar in a project i am currently doing whereby the input data of a PORT is compared to certain values and the the result stored in a register.
What function does PC have in the code?
org 0 ljmp Main
Main:
mov P3, #0xFF ; Port 3 is an input
loop: mov a, P3
anl a, #0x0F ; Clear bits 7..4 of A
lcall sqrt
mov P1, a
sjmp loop
sqrt: inc a
movc a, @a + PC
ret
Sqrs: db 0,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3
Jack; You need to do a topic search on the forum site for the C51 "Bible" links. They fully describe the operation of the 8051 type devices. The PC is the Program Counter so you are doing indirect addressing PC relative. There is more to the code but you need to review the "Bible". Bradford
here are the links to "the bible" Chapter 1 - 80C51 Family Architecture: Chapter 1 - 80C51 Family Architecture: www.nxp.com/.../80C51_FAM_ARCH_1.pdf Chapter 2 - 80C51 Family Programmer's Guide and Instruction Set: www.nxp.com/.../80C51_FAM_PROG_GUIDE_1.pdf Chapter 3 - 80C51 Family Hardware Description: www.nxp.com/.../80C51_FAM_HARDWARE_1.pdf