(labelPrefix string)
| 155 | } |
| 156 | |
| 157 | func routine_pollKeyboard(labelPrefix string) []asm.Instruction { |
| 158 | instructions := asm.Instructions{} |
| 159 | instructions.Add(asm.DEFLABEL{labelPrefix}) |
| 160 | |
| 161 | // push retun address |
| 162 | instructions.Add( |
| 163 | asm.DATA{asm.REG2, asm.SYMBOL{"CALL-RETURN-ADDRESS"}}, |
| 164 | asm.STORE{asm.REG2, asm.REG3}, |
| 165 | ) |
| 166 | |
| 167 | instructions.Add( |
| 168 | asm.DATA{asm.REG2, asm.NUMBER{0x000F}}, //select keyboard keyboard |
| 169 | asm.OUT{asm.ADDRESS_MODE, asm.REG2}, |
| 170 | ) |
| 171 | |
| 172 | instructions.Add( |
| 173 | asm.DEFLABEL{labelPrefix + "-STARTLOOP"}, |
| 174 | asm.IN{asm.DATA_MODE, asm.REG3}, // request key from keyboard adapter |
| 175 | asm.AND{asm.REG3, asm.REG3}, // check if value is zero |
| 176 | asm.JMPF{[]string{"Z"}, asm.LABEL{labelPrefix + "-STARTLOOP"}}, // if it is - keep polling |
| 177 | |
| 178 | asm.DEFLABEL{labelPrefix + "-ENDLOOP"}, //otherwise |
| 179 | asm.DATA{asm.REG0, asm.SYMBOL{"KEYCODE-REGISTER"}}, |
| 180 | asm.STORE{asm.REG0, asm.REG3}, //store key in here |
| 181 | |
| 182 | // deselect keyboard |
| 183 | asm.XOR{asm.REG2, asm.REG2}, |
| 184 | asm.OUT{asm.ADDRESS_MODE, asm.REG2}, |
| 185 | ) |
| 186 | |
| 187 | // return to callee |
| 188 | instructions.Add( |
| 189 | asm.CLF{}, |
| 190 | asm.DATA{asm.REG3, asm.SYMBOL{"CALL-RETURN-ADDRESS"}}, |
| 191 | asm.LOAD{asm.REG3, asm.REG3}, |
| 192 | asm.JR{asm.REG3}, |
| 193 | ) |
| 194 | |
| 195 | return instructions.Get() |
| 196 | } |
| 197 | |
| 198 | func resetLinex() []asm.Instruction { |
| 199 | instructions := asm.Instructions{} |
no test coverage detected