📄 tx8_1.asm
字号:
asr A
asr A
asr A
and A,0Fh ; Mask off nibble
index TX8_1_HEX_STR ; Get Hex value
call TX8_1_PutChar ; Write data to screen
pop A ; Restore value
and A,0Fh ; Mask off lower nibble
index TX8_1_HEX_STR ; Get Hex value
call TX8_1_PutChar ; Write data to screen
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: TX8_1_PutSHexInt
;
; DESCRIPTION:
; Print an Int in Hex (four characters) to UART Tx
;
; ARGUMENTS:
; Pointer to string
; A => ASB of Int
; X => MSB of Int
;
; RETURNS:
; none.
;
; SIDE EFFECTS:
; The A and X registers may be modified by this or future implementations
; of this function. The same is true for all RAM page pointer registers in
; the Large Memory Model. When necessary, it is the calling function's
; responsibility to perserve their values across calls to fastcall16
; functions.
;
TX8_1_PutSHexInt:
_TX8_1_PutSHexInt:
RAM_PROLOGUE RAM_USE_CLASS_1
swap A,X
call TX8_1_PutSHexByte ; Print MSB
mov A,X ; Move LSB into position
call TX8_1_PutSHexByte ; Print LSB
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: TX8_1_PutChar
;
; DESCRIPTION:
; Send character out through UART TX port.
;
;
; ARGUMENTS:
; A has Character to send to UART Tx Port
;
; RETURNS:
; none
;
; SIDE EFFECTS:
; The A and X registers may be modified by this or future implementations
; of this function. The same is true for all RAM page pointer registers in
; the Large Memory Model. When necessary, it is the calling function's
; responsibility to perserve their values across calls to fastcall16
; functions.
;
macro InLinePutChar( Source )
.BufEmptyWaitLoop:
tst REG[TX8_1_CONTROL_REG], TX8_1_TX_BUFFER_EMPTY ; Check Tx Status
jz .BufEmptyWaitLoop
mov REG[TX8_1_TX_BUFFER_REG], @Source ; Write data to Tx Port
endm
TX8_1_PutChar:
_TX8_1_PutChar:
RAM_PROLOGUE RAM_USE_CLASS_1
InLinePutChar A
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
;-----------------------------------------------
; High Level TX functions
;-----------------------------------------------
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: TX8_1_PutString
;
; DESCRIPTION:
; Send String out through UART TX port.
;
;
; ARGUMENTS:
; Pointer to String
; A has MSB of string address
; X has LSB of string address
;
; RETURNS:
; none
;
; SIDE EFFECTS:
; The A and X registers may be modified by this or future implementations
; of this function. The same is true for all RAM page pointer registers in
; the Large Memory Model. When necessary, it is the calling function's
; responsibility to perserve their values across calls to fastcall16
; functions.
;
; Currently only the page pointer registers listed below are modified:
; IDX_PP
;
TX8_1_PutString:
_TX8_1_PutString:
RAM_PROLOGUE RAM_USE_CLASS_3
RAM_SETPAGE_IDX A
.PutStringLoop:
mov A,[X] ; Get value pointed to by X
jz End_PutString ; Check for end of string
call TX8_1_PutChar ; Send character to Tx port
inc X ; Advance pointer to next character
jmp .PutStringLoop ; Get next character
End_PutString:
RAM_EPILOGUE RAM_USE_CLASS_3
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: TX8_1_Write
;
; DESCRIPTION:
; Send String of length X to serial port
;
;
; ARGUMENTS:
; Pointer to String
; [SP-5] Count of characters to send
; [SP-4] has MSB of string address
; [SP-3] has LSB of string address
;
; RETURNS:
; none
;
; SIDE EFFECTS:
; The A and X registers may be modified by this or future implementations
; of this function. The same is true for all RAM page pointer registers in
; the Large Memory Model. When necessary, it is the calling function's
; responsibility to perserve their values across calls to fastcall16
; functions.
;
; Currently only the page pointer registers listed below are modified:
; IDX_PP
;
CNT_LEN: equ -5 ; Length of data to send
STR_MSB: equ -4 ; MSB pointer of string
STR_LSB: equ -3 ; LSB pointer of string
TX8_1_Write:
_TX8_1_Write:
RAM_PROLOGUE RAM_USE_CLASS_3
RAM_SETPAGE_IDX2STK
mov X, SP
.NextByteLoop:
mov A,[X+CNT_LEN] ; Get length of string to send
jz .End_Write
dec [X+CNT_LEN] ; Decrement counter
IF SYSTEM_LARGE_MEMORY_MODEL
mov A, [X+STR_MSB] ; Load pointer to char to send
ENDIF
mov X,[X+STR_LSB] ; Get character to send
RAM_SETPAGE_IDX A ; switch index pages
mov A,[X]
InlinePutChar A ; Send character to UART
mov X, SP
RAM_SETPAGE_IDX2STK
inc [X+STR_LSB]
jmp .NextByteLoop
.End_Write:
RAM_EPILOGUE RAM_USE_CLASS_3
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: TX8_1_CWrite
;
; WARNING WARNING NOT COMPLETE
;
; DESCRIPTION:
; Send String of length X to serial port
;
; ARGUMENTS:
; Pointer to String
; [SP-6] MSB of Count of character to send
; [SP-5] LSB of Count of character to send
; [SP-4] has MSB of string address
; [SP-3] has LSB of string address
;
; RETURNS:
; none
;
; SIDE EFFECTS:
; The A and X registers may be modified by this or future implementations
; of this function. The same is true for all RAM page pointer registers in
; the Large Memory Model. When necessary, it is the calling function's
; responsibility to perserve their values across calls to fastcall16
; functions.
;
CLEN_MSB: equ -6 ; MSB Length of data to send
CLEN_LSB: equ -5 ; LSB Length of data to send
CSTR_MSB: equ -4 ; MSB pointer of string
CSTR_LSB: equ -3 ; LSB pointer of string
TX8_1_CWrite:
_TX8_1_CWrite:
RAM_PROLOGUE RAM_USE_CLASS_2
mov X,SP
.CW_Loop:
; Check for zero counter
cmp [X+CLEN_MSB],0x00
jnz .CW_WRITEIT
cmp [X+CLEN_LSB],0x00
jz .End_CWrite ; Leave if done
.CW_WRITEIT: ; Save pointers
push X
mov A,[X+CSTR_MSB]
mov X,[X+CSTR_LSB]
romx ; Get character from ROM
InLinePutChar A
pop X
add [X+CSTR_LSB],1 ; Increment the string pointer
adc [X+CSTR_MSB],0
; Dec the counter
sub [X+CLEN_LSB],0x01
sbb [X+CLEN_MSB],0x00
jmp .CW_Loop
.End_CWrite:
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: TX8_1_CPutString
;
; DESCRIPTION:
; Send String out through UART TX port.
;
;
; ARGUMENTS:
; Pointer to String
; A has MSB of string address
; X has LSB of string address
;
; RETURNS:
; none
;
; SIDE EFFECTS:
; The A and X registers may be modified by this or future implementations
; of this function. The same is true for all RAM page pointer registers in
; the Large Memory Model. When necessary, it is the calling function's
; responsibility to perserve their values across calls to fastcall16
; functions.
;
TX8_1_CPutString:
_TX8_1_CPutString:
RAM_PROLOGUE RAM_USE_CLASS_1
push A ; Store ROM pointer
push X
romx ; Get character from ROM
jz .End_CPutString
call TX8_1_PutChar ; Print character
pop X
pop A
inc X ; Inc LSB of pointer
jnc TX8_1_CPutString ; Check for carry
inc A ; Inc MSB of pointer
jmp TX8_1_CPutString
.End_CPutString:
add SP, -2
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: TX8_1_PutCRLF
;
; DESCRIPTION:
; Send a CR and LF
;
; ARGUMENTS:
; none.
;
; RETURNS:
; none.
;
; SIDE EFFECTS:
; The A and X registers may be modified by this or future implementations
; of this function. The same is true for all RAM page pointer registers in
; the Large Memory Model. When necessary, it is the calling function's
; responsibility to perserve their values across calls to fastcall16
; functions.
;
TX8_1_PutCRLF:
_TX8_1_PutCRLF:
RAM_PROLOGUE RAM_USE_CLASS_1
mov A,0x0D ; Send CR
call TX8_1_PutChar
mov A,0x0A ; Send LF
call TX8_1_PutChar
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
; End of File TX8_1.asm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -