📄 serial.asm
字号:
.include "serial.h" .module serial_asm .area code (REL);---------------------------------------------------------;; serial port & timer initialisationserial_init: mov th1, #baud_const mov tl1, #baud_const orl tmod, #0x20 ;set timer #1 for 8 bit auto-reload mov pcon, #0x80 ;configure built-in uart mov scon, #0x52 setb tr1 ;start the baud rate timer ret;---------------------------------------------------------;; Paulmon routines;cin: jnb ri, cin clr ri mov a, sbuf retspace: mov a, #0x20cout: jnb ti, cout clr ti ;clr ti before the mov to sbuf! mov sbuf, a retnewline2: ;print two newlines acall newlinenewline:push acc ;print one newline mov a, #13 acall cout mov a, #10 acall cout pop acc ret;a not so well documented feature of pstr is that you can print;multiple consecutive strings without needing to reload dptr;(which takes 3 bytes of code!)... this is useful for inserting;numbers or spaces between strings.pstr: push accpstr1: clr a movc a, @a+dptr inc dptr jz pstr2 mov c, acc.7 anl a, #0x7F acall cout jc pstr2 sjmp pstr1pstr2: pop acc retphex16: push acc mov a, dph acall phex mov a, dpl acall phex pop acc ret; Highly code efficient resursive call phex contributed; by Alexander B. Alexandrov <abalex@cbr.spb.ru>phex:phex8: acall phex_bphex_b: swap a ;SWAP A will be twice => A unchangedphex1: push acc anl a, #15 add a, #0x90 ; acc is 0x9X, where X is hex digit da a ; if A to F, C=1 and lower four bits are 0..5 addc a, #0x40 da a acall cout pop acc ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -