| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,52 @@ |
| 1 |
+; Author: Pawel Jablonski |
|
| 2 |
+; E-mail: pj@xirx.net |
|
| 3 |
+; WWW: xirx.net |
|
| 4 |
+; GIT: git.xirx.net |
|
| 5 |
+; |
|
| 6 |
+; License: You can use this code however you like |
|
| 7 |
+; but leave information about the original author. |
|
| 8 |
+; Code is free for non-commercial and commercial use. |
|
| 9 |
+ |
|
| 10 |
+include io.asm |
|
| 11 |
+ |
|
| 12 |
+; No arguments |
|
| 13 |
+; Return: |
|
| 14 |
+; A - received data |
|
| 15 |
+external .xRS232Receive: |
|
| 16 |
+ call .xRS232IsRxDataReady |
|
| 17 |
+ ; Wait until rs232 rx buffer has not data |
|
| 18 |
+ cmp 0, A |
|
| 19 |
+ je .xRS232Receive |
|
| 20 |
+ ; Set rs232 rx register |
|
| 21 |
+ mov 7, A |
|
| 22 |
+ call .xIOSetRegister |
|
| 23 |
+ ; Read rs232 rx register |
|
| 24 |
+ call .xIORead |
|
| 25 |
+ ret |
|
| 26 |
+ |
|
| 27 |
+; Arguments: |
|
| 28 |
+; A - data to send |
|
| 29 |
+; No return |
|
| 30 |
+external .xRS232Send: |
|
| 31 |
+ push A |
|
| 32 |
+ ; Set rs232 tx register |
|
| 33 |
+ mov 8, A |
|
| 34 |
+ call .xIOSetRegister |
|
| 35 |
+ pop A |
|
| 36 |
+ ; Write rs232 tx register |
|
| 37 |
+ call .xIOWrite |
|
| 38 |
+ ret |
|
| 39 |
+ |
|
| 40 |
+; No arguments |
|
| 41 |
+; Return: |
|
| 42 |
+; A - status (0 - empty, 1 - ready to read) |
|
| 43 |
+external .xRS232IsRxDataReady: |
|
| 44 |
+ ; Get rs232 rx interrupt bit |
|
| 45 |
+ in A |
|
| 46 |
+ and 0b01000000, A |
|
| 47 |
+ cmp 0, A |
|
| 48 |
+ jne .xRS232IsRxDataReady_ready |
|
| 49 |
+ ret |
|
| 50 |
+.xRS232IsRxDataReady_ready: |
|
| 51 |
+ mov 1, A |
|
| 52 |
+ ret |