Assembly in school

Questions about programming languages and debugging
Post Reply
User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Assembly in school

Post by ayu »

K so i made the last test in assembly yesterday, and since i have had some problems with my head ache it didn't go very well...so i MAY recieve a new test to show my Assembly skills and get the higher grade.... so now i need some help from someone skilled in Assembly =/

the test (if made) will be how to change in a program that lights up the LED's in PORTB on the microprocessor experiment table from LED 0 to 7 (it lights then up one at a time) so that it first lights all the 8 lights and then goes backwards and shuts them off. And apparently it's harder then i imagine it to be because my teacher gave me some "tip vibes" that it's kinda hard =/

So....could anyone help me out so that i can train? ^^
"The best place to hide a tree, is in a forest"

pseudo_opcode
cyber messiah
cyber messiah
Posts: 1201
Joined: 30 Apr 2006, 16:00
17
Location: 127.0.0.1

Post by pseudo_opcode »

what processor?
can you give me the instruction set, the interrupts and every thing i would need to know?

User avatar
isapiens
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 533
Joined: 05 May 2006, 16:00
17
Location: Turn around

Post by isapiens »

i am a bit confused with your assignment. Are you just trying to light up 7 different leds in a succession?

I took a class this year on microcontrollers so i got the basics. I might be able to help if understood the project more clearly.

So you got a portB which is 8bits right? so you can connect 8 leds from 0-7.

So if you write 1111 1111 to the address of portB you would light them all up [i dont remember when leds light up, its either high or low]

then if you want to wait before turning the first one off you could wright a loop that would just waste time. For ex.: You put a rather big number in the accumulator and start decrementing. Then you could just wright 1111 1110 to the PortB address to turn off the next light.

This might be totaly not what you want. I only took this class for a semester. There is obviously 5000 other ways to do it. You can use the real-time clock to change the PORTC output after a specific period of time.
I got the example in the book.
Fluoridation is the most monstrously conceived and dangerous communist plot we have ever had to face.

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Post by ayu »

Well the only thing i know from here (at home) is that the practise board is of the type HC11-LS and the Processor is a 2 Mhz MC68Hc11A1FN
"The best place to hide a tree, is in a forest"

User avatar
isapiens
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 533
Joined: 05 May 2006, 16:00
17
Location: Turn around

Post by isapiens »

we used hc11 too, Motorola but some other model, but basically they are the same. Do you have a book with examples cuz i think thats a rather basic project.

Actually just start searching the examples on internet. They are not that easy to find but there are some out there. I finished my final project like that lol

I had a thread about it here somewhere but nobody responded. Basically i ended up creating a square wave generator and then used "circular buffer" to create a sine wave out of that square wave. It was freaken complicated and i wouldn't be able to do it if you asked me to do it right now lol.

I will try to help if you need anything else, but maybe there is someone more experienced with assembly then i am.
cheers
Fluoridation is the most monstrously conceived and dangerous communist plot we have ever had to face.

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Post by ayu »

yeah i have the program here

Code: Select all

PORTB       EQU     $1004
                 ORG    $6000
                 CLRA
                 SEC
L0              ROLA
                 STAA   PORTB
                 JSR     F500MS
                 BRA    L0
F500MS      LDY    #58822
F500_1       DEY
                 NOP
                 NOP
                 NOP
                 NOP
                 NOP
                 BNE     F500_1
                 RTS
   
Now this code is the original code that would just light the 8 LED's up from PB0 to PB7, my assignement till be to make it go back and forth.

Now you could imagine that "hey this is easy, just reverse the process". But it doesn't seem to be that simple. Since it loops with jumping left at "BRA L0" nothing stops it (i assume). So i would have to make it stop there and then add the reversed code to make it go back and then do a JSR PORTB to make it start over again. My problem is that i don't really know how to make it stop going left. If this was C++ i could do it =P but things has gotten a little more advanced now =]


EDIT: it seems that PHPNUKE text editor fucks up the code...but read it slowly ^^


EDIT: I imagine that i could edit the code like this

Code: Select all

PORTB       EQU     $1004
                 ORG    $6000
                 CLRA
                 SEC
START        LDX     #7
LD             DEX
L0              ROLA
                 STAA   PORTB
                 JSR     F500MS
                 BNE     LD
                 JSR     BACK
*
BACK        LDX     #7
LA             DEX
L1             RORA
                STAA   PORTB
                JSR      F500MS
                BNE     LA
                JSR     START
                
*
F500MS      LDY    #58822
F500_1       DEY
                 NOP
                 NOP
                 NOP
                 NOP
                 NOP
                 BNE     F500_1
                 RTS
"The best place to hide a tree, is in a forest"

User avatar
isapiens
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 533
Joined: 05 May 2006, 16:00
17
Location: Turn around

Post by isapiens »

check out this web site

http://xoomer.alice.it/lorgler/sw-e.htm


There is a simulator if you dont have the board, but i have never used it before. For me personally it is very hard to code when i dont have the board to implement along the way.

He has bunch of links to other websites that have examples.

Honestly there was another website that was much more useful, but i cant seem to find it right now. They are all home owned web sites by people who just enjoy this stuff so it is not that easy to find their websites.

Now about the problem:

I am not sure because i don't grasp entirely the stuff about carries and rollovers, but the way you did was exactly how i would tackle this problem. Just a loop that decrements 7 times. Now it sucks that you don't have the board cuz there might be some errors that you wouldn't expect to be there by just looking at the code unless you are god.
Fluoridation is the most monstrously conceived and dangerous communist plot we have ever had to face.

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Post by ayu »

isapiens wrote:check out this web site

http://xoomer.alice.it/lorgler/sw-e.htm


There is a simulator if you dont have the board, but i have never used it before. For me personally it is very hard to code when i dont have the board to implement along the way.

He has bunch of links to other websites that have examples.

Honestly there was another website that was much more useful, but i cant seem to find it right now. They are all home owned web sites by people who just enjoy this stuff so it is not that easy to find their websites.

Now about the problem:

I am not sure because i don't grasp entirely the stuff about carries and rollovers, but the way you did was exactly how i would tackle this problem. Just a loop that decrements 7 times. Now it sucks that you don't have the board cuz there might be some errors that you wouldn't expect to be there by just looking at the code unless you are god.
I tried the programs at that site, thanks man. But i can't seem to assemblate my code with the program :/ any tip? or maybe there is something on the site i missed? ^^
"The best place to hide a tree, is in a forest"

User avatar
isapiens
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 533
Joined: 05 May 2006, 16:00
17
Location: Turn around

Post by isapiens »

ye i am a retard, thats not a simulator. grr it clearly says there you need a board lol.

Ok, we need someone who actually knows assembly better then us and who can check the code. I am pretty sure you are doing it right, it just you might be missing a pound sign or smth that we dont notice but is wrong.

common smart people, cough up the knowledge.
Fluoridation is the most monstrously conceived and dangerous communist plot we have ever had to face.

Post Reply