-3

I have the code on the left given and i am asked what is stored in the addresses from 0H...15H. I found it very easy all the answers till 0AH came. I have no clue where the '0D' or '08' or 'FE' are coming from. here is the Code:

    WERT equ 127
    org 0               
MOV SP,#0FH
CLR A
MOV PSW,#0FFH
ADDC    A,#WERT
ACALL   UP
SJMP    $
UP:
PUSH    ACC
PUSH    PSW
POP PSW
POP ACC
RET

END

What is in the addresses of the Physical Memory stored from 00h to 15H? I answered all the ones till 0AH i have no clue how there can be a 80H.

Screenshot

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Endrit Demaj
  • 134
  • 6
  • links dont do us any good here, need to post the problem in the question so that all the information is on this website and not elsewhere that may end up in broken links. – old_timer Jul 05 '16 at 15:21
  • i have put the code in text. hope you can hep me now. Sorry my english is not at it best. – Endrit Demaj Jul 05 '16 at 15:38
  • @WeatherVane 8051 stack grows up. Also it's Harvard architecture so code and data have different address spaces, so no overlap. – Jester Jul 05 '16 at 15:57
  • @Jester thanks, I thought it was some trick code at first. After that distraction I can see there must be two bytes for each `push` and `pop` followed by the `22` for `RET`. – Weather Vane Jul 05 '16 at 16:07

1 Answers1

2

How did you figure out the first few bytes? I assume you have consulted an instruction set reference. So what problem did you run into with the values you ask about?

The opcode for ACALL is 11, the absolute address of UP is 0D, so that's how you get 11 0D.

Similarly, the opcode for SJMP is 80 and it jumps back to itself using a relative offset of -2 which is FE in hex. (The offset applies to the already incremented program counter.)

Jester
  • 56,577
  • 4
  • 81
  • 125
  • Many thanks for your answer. i have a table here in front of me where all of the bytes are written into it, and we can take it in our exam. Im using the "MCU 8051 IDE to see if my results are correct. The answer u have given me helped but where do i get the absolute address of UP ? i have no clue on this. Im sorry im just a beginner in this section so please dont laugh at me "Haha". Many thanks again. – Endrit Demaj Jul 05 '16 at 15:50
  • You don't know it at first, so emit a placeholder `XX` and continue assembling. Once you get to the `UP` you will know the address and can go back to fill it in. – Jester Jul 05 '16 at 15:54
  • 1
    OMG im feeling so dumb, so so i started the first PUSH and noticed the address `0D` where `UP` has absolutely to point to push to work. anyway many thanks im sitting here for about hours trying to figure it out. Thank you SIR – Endrit Demaj Jul 05 '16 at 17:00