Hey Guys!
I need help!
I want an assembly instruction for those c-commands:
DDRH |= 0x80;
and
PORTH ^=0x80;
Aim is to switch the light off an on! I am a rookie yes
THX!!
Solved! Go to Solution.
A = A -+ 0x80 will toggle bit7 of A. Will it make LED connected to PORTH on or off I don't know, it depends on initial state of PORTH, also on the circuit.
There is a S12 opcode for setting a bit in memory:
BSET DDRH #$80
To toggle bit 7 you could implement the following sequence:
LDAA #$80
ADDA PORTH
STAA PORTH
Can you also explain me the following code:
ADDA PORTH
why do you this?
Fundamental Boolean algebra: A + B equals A UNION B equals A OR B
Why? To be smarter than average, probably :-). ADD isn't faster than EOR, so this trick is as useless as this one
LDAA PORTH ;// PORTH ^= 0x80
SUBA #$80
STAA PORTH
Your successor will like it..., or maybe not
When you make -> A= A- $80 than you become the led light off or?
I mean this explanation also above!
THX!!!
A = A -+ 0x80 will toggle bit7 of A. Will it make LED connected to PORTH on or off I don't know, it depends on initial state of PORTH, also on the circuit.
Okay THX!!!!
Here is the whole code:
include <stdio.h>
#include <mc912d128.h>
void delay1ms(void) {
asm("ldy #2666"); //2666 in Y-Register laden
asm("dbne y,."); // Decrement, bis Y=0 ist /
//3cyc x 125ns x 2666 = 0,99975ms
}
void wait(int duration)
{
while(duration--)
delay1ms();
}
void main(void) {
asm("LDAA #$80"); //DDRH |= 0x80;
asm("STAA $002B");
while(1){
asm("LDAA #$80"); //PORTH ^=0x80;
asm("ADDA $0029");
asm("STAA $0029");
wait(1000);
}
}
Program is ICC12!
THX to all of you for helping hands!
I have no S12... so the code don't work!