Hi,
These are very basic questions.
Each of them probably is already answered many thousand times in the internet.
You need to learn to
* do useful internet search,
* read documentation
* read through code examples
* view video tutorials
* and so on
...to find informations and solutions on your own, since a forum can't replace school.
And you need to learn good programming style.
In your current code the loop consists of 10 instructions, 50% of them is "goto".
Usually one wants to avoid "goto". One wants straight code (pieces, functions) from top to bottom. Unconditionsl branches.
(Conditional branches are only used where unavoidable, unconditional branches are allowed)
You currently do "conditional branching"
Instead consider to do:
* read input data (into registers, memory cells...)
* process the data (logically, mathematically...)
* output the processed data.
In your case: (pseudo code)
* declare some variables: current_state, previous_state, tmp_state, output_state ...
( for assembly this means: considervwhich registor (or memory cell) contains what informations
* read the pin state into current_state
* process it with the previous state into tmp_state
* process it further to get output_state (AND, OR, XOR, multiply, masking, shifting, inverting, ....)
* previous_state = current_state
* send output_state to the port
* restart the loop (unconditional branch)
Logic for detecting a rising edge is:
* Rising = current_state AND NOT previous state
In words: a rising edge is when it is currently HIGH AND it was NOT HIGH before
AND, OR reacts on HIGH. If you want to react on LOW you need to use NOT
Klaus