I am a freshman studying computer science. In computer engineering we are working on a Zilog Z80 8-bit microprocessor (1MHz) and a set of components that need to be manually connected using a breadboard and cables.

The connecting part doesn't worry me, but I do have questions concerning the Assembly program that I need to write to get my programm working (LED running light, with manual input for behaviour and frequency).

I have already read the manual and know the set of instructions that can be used (only the bare necessities). For a start, I am not trying to get the cleanest, best looking code possible; but not to worry, I'll prettify it later on, since I like clean and efficient code.

For the moment, the program seems to run well in the simulator, so the syntax seems to be alright. Still, I am not sure how to progress with certain logical problems.

The exercise has the following specifications:

1. Start address RAM: E000h
2. Input port 1: 03h
3. Output port 1: 05h
4. I/O-mapping for ports
5. Circuits are automatically open (1) so LED are LOW-active (0)
6. Input 2,3,4 changes LED movement behaviour
7. Input 5,6 changes LED blinking frequency

I have set the start address using `ORG E000h` and initialized the stackpointer using `MOV SP,FFFFh`. For the input (three different types of blinking/running, as well as two different frequencies, equaling five buttons in total) I have created different labels.

My problem at the moment is that I am not quite sure how to get my physical input right - IIRC, I'd need to specify a bit pattern by using XOR with everything being 1 but the desired input, so that I can use the information in my program.

But even though I do know the way it is supposed to work (at least I think that I know), I cannot quite wrap my head around the software implementation. Also, I have problems with conditions: Pressing one switch changes blinking frequency to 1/4 Hz, while pressing the other changes it to 4Hz. In higher-level languages I'd just use IF/ELSE here, but I don't know how to do it in this case - sadly, the manual only includes basic operations so I am at a loss.

Therefore, I thought I'd try my luck and ask the community for help.

For those interested, I'll post my code. It is very basic, as I already mentioned, but I just need it to get the job done for the time being. Since I am not a fan of huge chunks of clumsily formatted code, I have posted the file [here](https://drive.google.com/file/d/1buqxWMz1ESaEzzWqnOgOQJpdmTYB1Nuw/view?usp=sharing). The file is a \*.txt hosted through GoogleDrive.

Thank you for your time and have a nice day!

[EDIT] added specific code in post, according to input by user Ruud Helderman

[EDIT] updated code in \*.txt-file - now simpler and more efficient

[EDIT] used HTML-formatting to highlight directives in post

Specific code snippet:

```
blink:       ;function: all LED blinking, activated via input[2]
MOV A,FFh
OUT 05h,A     ;all LED out
CALL pause1   ;frequency 1/4Hz, activated via input[5]
MOV A,00h
OUT 05h,A     ;all LED on
CALL pause1
JP blink      ;jump back to begin of function

```

The above function changes LED behavior (in this case: blinking) and also frequency using different specific physical switches on an input switch board with eight switches total (1 to 8, inactivate state = 1; switches 2 to 6 are used). I know that getting input should be a piece of cake - it should just be a matter of using XOR with bit patterns of 0 and exactly one 1.

While trying to find a solution for my problem I came upon different approaches online, such as using `TEST` to check for bits on specific locations. Still, my instruction manual has no mention of any such directive and the assignment itself doesn't mention it either.

I am quite aware that this is probably a trivial question, and maybe I am just stuck in a mental loop that I created myself by overthinking, but at the moment I don't know how to get to were I need to be (even though I can see the castle on the horizon - thanks Kafka!).

Any help is greatly appreciated.