Krolyxon
Commit c48ef97

Branches

Tags

Refs →

bench51examplesserial_hello.asm

43 lines · 984 B · x86_64 Assembly

1; UART: 9600 baud at 11.0592 MHz (timer 1, mode 2, TH1 = FDh).
2; Prints a greeting, then echoes everything typed in the Serial panel
3; (Tab to the Serial panel in debug mode, type, press Enter).
4
5 ORG 0000h
6 LJMP main
7
8 ORG 0030h
9main: MOV TMOD,#20h ; timer 1: mode 2 (8-bit auto-reload)
10 MOV TH1,#0FDh
11 SETB TR1
12 MOV SCON,#50h ; serial mode 1, receiver enabled
13 MOV DPTR,#msg
14 ACALL puts
15echo: ACALL getc
16 ACALL putc
17 CJNE A,#0Dh,echo ; after CR, also send LF
18 MOV A,#0Ah
19 ACALL putc
20 SJMP echo
21
22; Send the zero-terminated string at DPTR.
23puts: CLR A
24 MOVC A,@A+DPTR
25 JZ done
26 ACALL putc
27 INC DPTR
28 SJMP puts
29done: RET
30
31putc: MOV SBUF,A
32wait: JNB TI,wait
33 CLR TI
34 RET
35
36getc: JNB RI,getc
37 MOV A,SBUF
38 CLR RI
39 RET
40
41msg: DB "Hello from the 8051!", 0Dh, 0Ah, "Type something: ", 0
42
43 END