Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/01/06 03:43
Modified:
  09/01/06 03:53

Read: times


 
#123483 - Newbie need help
New to 8052 programming. Understand the basics of memory map in 8052. Recently I downloaded a program for AT89S52 and it works fine. But when looking at the source code, it has some conflict with my understanding of memory usage in 8052. May be it was just my misunderstanding of the memory map, or the use of some assembly directives. Here is the code:

org 0000h
ajmp boot
org 00013h
ajmp INT

org 030h
boot:
CODE_BASE EQU 0031h
STACK_START EQU 85h ; Note 1
;
; some EQU, BIT, DATA here
; including
start_H data 0eh ; Note 2
start_M data 0fh

org CODE_BASE
;
; some coding here
;
ljmp start

INT:
; INT coding here
; some subroutine here
start:
mov sp,#STACK_START ; Note 3
; rest of the coding
; including
mov r0,#0a8h
mov @r0,current_time ; Note 4
;
end

Bearing in mind that the program works, I have a few questions:

1. The STACK_START is 85h in Note 1 and was actually used in Note 3. Given that it has lots of nested subroutines, it should have demaged some of the SFR. But the program works fine. Why?

2. The start_H is 0eh in Note 2. If register bank 1 (in particular R6) is used, then it has problem. Am I right?

3. Again in Note 4, SFR was overwriten. It should work.

4. I tried to change the STACK_START to 030h. But then it didn't work.

5. Some other program use CODE_BASE 000h. Will it overwrite registers?

6. Will using "db" to define variable better than using "data".?

Please help.

List of 11 messages in thread
TopicAuthorDate
Newbie need help            01/01/70 00:00      
   8052 Magic            01/01/70 00:00      
      stack overlay on SFR            01/01/70 00:00      
         You are missing...            01/01/70 00:00      
            Same address, different circuits            01/01/70 00:00      
               Confused?!            01/01/70 00:00      
   peculiarities            01/01/70 00:00      
      link            01/01/70 00:00      
   Thanks.            01/01/70 00:00      
      8051 vs 8052            01/01/70 00:00      
         understatement of the year            01/01/70 00:00      

Back to Subject List