Micro-controller Programming Problem - Assembly

In summary, the conversation is about a program that loops two lit LEDs through eight LEDs on a board. The program is already written but there are questions about the use of cblock and endc, and why the init subroutine continues to loop. Cblock is used to declare a block of memory for constants and endc is used to end the constant block. The issue with the init subroutine may be due to improper code or accidental jumping.
  • #1
crono1009
15
0

Homework Statement



I am writing a program to loop (rotate) two lit LEDs through eight LEDs on my board.
For Example:
11000000 01100000 00110000 00011000 00001100 00000110 00000011

Where the ones are lit LEDs and the zeros are non-lit LEDs.

It is supposed to loop forever.

Homework Equations



N/A

The Attempt at a Solution



The program is in the text file attached. The program was pretty much already written for me. We had to take the tutorial code the looped one LED and allow it to loop two while also created a initialization subroutine.

This program worked the first time I built it though I recently built it again with no changes and it does not work, whilst simulating it loops through the Init subroutine forever.

My Questions:
What is cblock?, it isn't in the datasheet for my pic.
What does endc do? also not in the datasheet.
Why does my init subroutine continue to loop?

I'm very new to assembly programming, though I do have a background in VHDL, Verilog, C++, MATLAB, and JAVA.

Thank you.

EDIT: I found that the reason why it was continuously looping through the Init subroutine was because I forgot to add "goto Start" after org 0, though now it only flashes the LEDs once and then they turn off indefinitely.

Now it works, feel free to delete this post.
 

Attachments

  • Rotate.txt
    2 KB · Views: 500
Last edited:
Physics news on Phys.org
  • #2


Hello,

I am a scientist and I would be happy to help you with your questions about your program.

Firstly, cblock stands for "constant block" and it is used to declare a block of memory locations that will be used for constants. These constants can be accessed throughout the program and can be used to store important values or addresses.

Endc, on the other hand, is used to end the constant block and return to the main program.

As for your init subroutine, it is possible that there is an issue with the code that is causing it to continuously loop. I would suggest double checking your code and making sure that all necessary variables and registers are properly initialized. Also, make sure that your program is not accidentally jumping back to the init subroutine after the first loop.

I hope this helps and good luck with your program!
 
  • #3


First of all, great job on successfully completing the program and troubleshooting the issue on your own! Now, let's address your questions.

1. "What is cblock?" - cblock stands for "constant block" and it is used to define a block of memory locations that will hold constants or variables. In your program, it is used to define the memory locations for storing the LED patterns.

2. "What does endc do?" - endc simply marks the end of a constant block.

3. "Why does my init subroutine continue to loop?" - As you have discovered, the issue was due to the missing "goto Start" statement. This statement is necessary to ensure that the program jumps back to the beginning of the loop after completing the initialization subroutine. Without it, the program will continuously loop through the initialization subroutine, never reaching the main loop.

Overall, great job on your program and keep up the good work in your assembly programming journey!
 

1. What is assembly language?

Assembly language is a low-level programming language that is specific to a certain type of micro-controller. It is a symbolic representation of machine code, making it easier for humans to read and write.

2. What is a micro-controller?

A micro-controller is a small computer on a single integrated circuit that is designed to control specific hardware functions. It is commonly used in embedded systems, such as appliances, automobiles, and industrial machinery.

3. What are the advantages of using assembly language for micro-controller programming?

Assembly language allows for precise control over hardware components and can result in faster and more efficient code than high-level languages. It also allows for direct access to memory and registers, making it useful for real-time applications.

4. What are some common challenges in micro-controller programming with assembly language?

One of the main challenges is the steep learning curve, as assembly language requires a strong understanding of the underlying hardware architecture. It also requires more lines of code compared to high-level languages, making it more time-consuming to write and debug.

5. Can assembly language be used for all micro-controllers?

No, assembly language is specific to a certain type of micro-controller and may not be compatible with others. It is important to check the datasheet of the micro-controller to determine which assembly language is supported.

Similar threads

  • Sticky
  • Programming and Computer Science
Replies
13
Views
4K
  • Electrical Engineering
Replies
2
Views
2K
Replies
6
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
3K
Back
Top