Here is my original .asm program, very simple:
ORG 0000H LJMP 0200H ORG 0003H LJMP 0100H
ORG 0100H P1=03H P2=04H RETI
ORG 0200H P1=00H P2=0FFH; SJMP $
Now, I have the following Keil C code: #include <reg51.H> #include <stdio.h>
void main(void) {
P1=0x06; P2=0x0a;
}
after compiling and linking, I saw the asm code:
in code address 0000H, it generates a LJMP 0447H
which means, in my computer, when the program starts from 0000H, its default jump to address in code is 0447H.
My questions are:
1) How to re-direct the jump address ? if I want the main program jump to 0200H instead of 0447H, how to write the code in keil C51 ?
2) How to arrange the INTER0 interruption jump to address? In .asm I can arrange it jump to 0100H, how to implement it in Keil C51 ?
3) I use AT89S51. before I use the P0, P1 ports, I need to initialize it as Input or Output at the beginning of the program, such like:
P0=01h P1=0ffh
do I need to do this in keil C51 ?
Thank you very much for your reply.
You don't. Nor should you be trying to. If assembly code is what you want to write, do it in assembly, not C.
For starters, that's not the main program that's jumping off from 0000H to 0447H --- it's the startup code.
I need to initialize it as Input or Output
No, that's not what those lines are doing. Please re-read your CPU's datasheet about what it means for a port to be pseudo-bidirectional.
See: www.8052.com/.../120176
See also: www.8052.com/.../120112