-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_echo.asm
More file actions
44 lines (33 loc) · 1.01 KB
/
test_echo.asm
File metadata and controls
44 lines (33 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
; CP/M Echo Test Program
; Echoes characters typed on the console
; Press Ctrl+C (0x03) to exit
org 0100h ; CP/M programs start at 0x0100
start:
; Print welcome message
lxi d, welcome
mvi c, 9 ; BDOS function 9: Print string
call 5 ; Call BDOS
loop:
; Read character from console
mvi c, 1 ; BDOS function 1: Console input
call 5 ; Call BDOS
; Check for Ctrl+C (exit)
cpi 3 ; Compare with 0x03
jz exit ; Jump to exit if equal
; Echo the character
mov e, a ; Move character to E register
mvi c, 2 ; BDOS function 2: Console output
call 5 ; Call BDOS
jmp loop ; Repeat
exit:
; Print goodbye message
lxi d, goodbye
mvi c, 9 ; BDOS function 9: Print string
call 5 ; Call BDOS
ret ; Return to CP/M (or halt for now)
welcome:
db 13, 10, 'CP/M Echo Test', 13, 10
db 'Type characters (Ctrl+C to exit)', 13, 10, '$'
goodbye:
db 13, 10, 'Goodbye!', 13, 10, '$'
end