0

I am translating some assembly code into C, and I need some help with a part of it:

    .equ UBRR_val = 12 ;UBRR sets baud, 12 = 19200baud at 4 MHz
    .def char = r17 ; Register to hold a character

    .org 0x00 ; Execute this when reset button is pushed
    rjmp start

So I have translated it as follows:

    #define UBRR_val ((4UL/19200)-1) 
    #define char* = 17; 

    .org 0x00 ; Execute this when reset button is pushed
    rjmp start

But I can't figure out .org 0x00; I think the rjmp start directs to the main so no changes are needed

Anyone that can help with it?

  • Not what you asked, but your define for UBRR_val is wrong. You didnt include factor 16 or 8 in it (check MCUs datasheet to see exact formula, and how it is divided between high and low register). Also 4 MHz is 4000000. – Rok Tavčar Oct 26 at 6:17
1

The .org-directive set's the location counter, so essentially what they do here is telling the assembler that this code should be placed at 0x00 of the current section, which happens to be global 0x00 aswell and that address seems to be executed on reset on this particular CPU with this particular configuration.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.