MDL Optimizer VSCode integration. Optimize code.

This commit is contained in:
boykovra 2024-08-29 11:23:11 +03:00
parent 5c34c5659f
commit 5fb3ff48fa
15 changed files with 425 additions and 457 deletions

View File

@ -1,185 +1,203 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "make ESPSET (sjasmplus)",
"type": "shell",
"command": "sjasmplus",
"args": [
"--sld=espset.sld",
"--sym=espset.labels",
"--raw=espset.exe",
"--fullpath",
"espset.asm"
],
"problemMatcher": {
"owner": "sjasmplus",
"fileLocation": "autoDetect",
"pattern": {
"regexp": "^(.*)\\((\\d+)\\):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"severity": 3,
"message": 4
}
},
"group": {
"kind": "build",
"isDefault": false
}
},
"version": "2.0.0",
"tasks": [
{
"label": "make WTERM (sjasmplus)",
"type": "shell",
"command": "sjasmplus",
"args": [
"--sld=wterm.sld",
"--sym=wterm.labels",
"--raw=wterm.exe",
"--fullpath",
"wterm.asm"
],
"problemMatcher": {
"owner": "sjasmplus",
"fileLocation": "autoDetect",
"pattern": {
"regexp": "^(.*)\\((\\d+)\\):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"severity": 3,
"message": 4
}
},
"group": {
"kind": "build",
"isDefault": false
}
},
"label": "make ESPSET (sjasmplus)",
"type": "shell",
"command": "sjasmplus",
"args": [
"--sld=espset.sld",
"--sym=espset.labels",
"--raw=espset.exe",
"--fullpath",
"espset.asm"
],
"problemMatcher": {
"owner": "sjasmplus",
"fileLocation": "autoDetect",
"pattern": {
"regexp": "^(.*)\\((\\d+)\\):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"severity": 3,
"message": 4
}
},
"group": {
"kind": "build",
"isDefault": false
}
},
{
"label": "make ISA-TEST (sjasmplus)",
"type": "shell",
"command": "sjasmplus",
"args": [
"--sld=isa-test.sld",
"--sym=isa-test.labels",
"--raw=isa-test.exe",
"--fullpath",
"isa-test.asm"
],
"problemMatcher": {
"owner": "sjasmplus",
"fileLocation": "autoDetect",
"pattern": {
"regexp": "^(.*)\\((\\d+)\\):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"severity": 3,
"message": 4
}
},
"group": {
"kind": "build",
"isDefault": false
}
},
{
"label": "make ESPLIB (sjasmplus)",
"type": "shell",
"command": "sjasmplus",
"args": [
"--sld=esplib.sld",
"--sym=esplib.labels",
"--raw=esplib.exe",
"--fullpath",
"esplib.asm"
],
"problemMatcher": {
"owner": "sjasmplus",
"fileLocation": "autoDetect",
"pattern": {
"regexp": "^(.*)\\((\\d+)\\):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"severity": 3,
"message": 4
}
},
"group": {
"kind": "build",
"isDefault": false
}
},
{
"label": "make WTFTP (sjasmplus)",
"type": "shell",
"command": "sjasmplus",
"args": [
"--sld=wtftp.sld",
"--sym=wtftp.labels",
"--raw=wtftp.exe",
"--fullpath",
"wtftp.asm"
],
"problemMatcher": {
"owner": "sjasmplus",
"fileLocation": "autoDetect",
"pattern": {
"regexp": "^(.*)\\((\\d+)\\):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"severity": 3,
"message": 4
}
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "make CMDTEST (sjasmplus)",
"type": "shell",
"command": "sjasmplus",
"args": [
"--sld=cmdtest.sld",
"--sym=cmdtest.labels",
"--raw=cmdtest.exe",
"--fullpath",
"cmdtest.asm"
],
"problemMatcher": {
"owner": "sjasmplus",
"fileLocation": "autoDetect",
"pattern": {
"regexp": "^(.*)\\((\\d+)\\):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"severity": 3,
"message": 4
}
},
"group": {
"kind": "build",
"isDefault": false
}
},
"label": "make WTERM (sjasmplus)",
"type": "shell",
"command": "sjasmplus",
"args": [
"--sld=wterm.sld",
"--sym=wterm.labels",
"--raw=wterm.exe",
"--fullpath",
"wterm.asm"
],
"problemMatcher": {
"owner": "sjasmplus",
"fileLocation": "autoDetect",
"pattern": {
"regexp": "^(.*)\\((\\d+)\\):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"severity": 3,
"message": 4
}
},
"group": {
"kind": "build",
"isDefault": false
}
},
{
"label": "start mame",
"type": "shell",
"command": "while true; do ./mame spectrum -window -debugger gdbstub -debug -debugger_port 12000 -verbose -resolution 512x384 ; sleep 2 ; done",
"options": {
"cwd": "${config:mame_dir}"
},
"problemMatcher": []
}
]
"label": "make ISA-TEST (sjasmplus)",
"type": "shell",
"command": "sjasmplus",
"args": [
"--sld=isa-test.sld",
"--sym=isa-test.labels",
"--raw=isa-test.exe",
"--fullpath",
"isa-test.asm"
],
"problemMatcher": {
"owner": "sjasmplus",
"fileLocation": "autoDetect",
"pattern": {
"regexp": "^(.*)\\((\\d+)\\):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"severity": 3,
"message": 4
}
},
"group": {
"kind": "build",
"isDefault": false
}
},
{
"label": "make ESPLIB (sjasmplus)",
"type": "shell",
"command": "sjasmplus",
"args": [
"--sld=esplib.sld",
"--sym=esplib.labels",
"--raw=esplib.exe",
"--fullpath",
"esplib.asm"
],
"problemMatcher": {
"owner": "sjasmplus",
"fileLocation": "autoDetect",
"pattern": {
"regexp": "^(.*)\\((\\d+)\\):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"severity": 3,
"message": 4
}
},
"group": {
"kind": "build",
"isDefault": false
}
},
{
"label": "make WTFTP (sjasmplus)",
"type": "shell",
"command": "sjasmplus",
"args": [
"--sld=wtftp.sld",
"--sym=wtftp.labels",
"--raw=wtftp.exe",
"--fullpath",
"wtftp.asm"
],
"problemMatcher": {
"owner": "sjasmplus",
"fileLocation": "autoDetect",
"pattern": {
"regexp": "^(.*)\\((\\d+)\\):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"severity": 3,
"message": 4
}
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "MDL for WTFTP",
"type": "shell",
"command": "java -jar ~/Soft/MDL/mdl.jar wtftp.asm -cpu z180 -po -dialect sjasmplus",
"group": "build",
"problemMatcher": {
"applyTo": "allDocuments",
"fileLocation": [
"autoDetect",
"${workspaceFolder}"
],
"pattern": [
{
"regexp": "^(\\w+): (.+) in (.+)#([0-9]+): (.+)$",
"file": 3,
"line": 4,
"severity": 1,
"message": 5,
"code": 2
}
]
},
"presentation": {
"echo": false,
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true,
"revealProblems": "onProblem"
}
},
{
"label": "MDL for WTERM",
"type": "shell",
"command": "java -jar ~/Soft/MDL/mdl.jar wterm.asm -cpu z180 -po -dialect sjasmplus",
"group": "build",
"problemMatcher": {
"applyTo": "allDocuments",
"fileLocation": [
"autoDetect",
"${workspaceFolder}"
],
"pattern": [
{
"regexp": "^(\\w+): (.+) in (.+)#([0-9]+): (.+)$",
"file": 3,
"line": 4,
"severity": 1,
"message": 5,
"code": 2
}
]
},
"presentation": {
"echo": false,
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true,
"revealProblems": "onProblem"
}
}
]
}

View File

@ -3,6 +3,8 @@
; By Roman Boykov. Copyright (c) 2024
; https://github.com/romychs
; ======================================================
IFNDEF _BUFFER
DEFINE _BUFFER
MODULE BUFFER
@ -186,4 +188,6 @@ SAVE_P1
ORG 0x5000
RX_BUFFER
ENDMODULE
ENDMODULE
ENDIF

View File

@ -56,12 +56,12 @@ START
MSG_CMDLINE
DB "\r\nCommandline:"Z
DB "\r\nCommandline:",0
MSG_CURPATH
DB "\r\nExePath:"Z
DB "\r\nExePath:",0
MSG_LINE_END
DB "\r\n"Z
DB "\r\n",0
ENDMODULE

View File

@ -3,6 +3,8 @@
; By Roman Boykov. Copyright (c) 2024
; https://github.com/romychs
; ======================================================
IFNDEF _DSS
DEFINE _DSS
ORG 0x0000
@ -187,8 +189,8 @@ REMAINS_IN_ZIP
_READ_FILE
OR A
JP Z, BAD_EXIT
PUSH DE
POP BC ; BC - bytes to read
LD B,D ; BC - bytes to read
LD C,E
PUSH HL
LD HL, (CUR_F_PTR) ; HL -> IN ZIP_FILE
@ -223,8 +225,8 @@ NO_OUT_OF_ZIP
; DE - реальное количество записанных байт
_WRITE_FILE
PUSH DE
POP BC
LD B, D
LD C, E
LD DE,OUT_FILE
PUSH BC
@ -304,9 +306,9 @@ _SCANKEY
_WAITKEY
XOR A
LD D, A
LD C, A
;LD C, A
LD E,65
LD A,65
LD A,E
JP NORM_EXIT
@ -361,16 +363,16 @@ _EXIT
JP _EXIT
CMD_LINE_TFTP_D
DB " tftp://tftp.server.ru:1024/file_in.asm c:\\tmp\\file_out.asm"Z
DB " tftp://tftp.server.ru:1024/file_in.asm c:\\tmp\\file_out.asm",0
CMD_LINE_TFTP_D1
DB " tftp://server.ru/file.src sss.dst"Z
DB " tftp://server.ru/file.src sss.dst",0
CMD_LINE_TFTP_U
DB " file_from.asm tftp://server.ru:9999/file_to.asm"Z
DB " file_from.asm tftp://server.ru:9999/file_to.asm",0
CMD_LINE_TFTP_U1
DB " file_up.txt"Z
DB " file_up.txt",0
IN_FILE
@ -381,4 +383,6 @@ IN_FILE_NAME
OUT_FILE
DS 1024,0
ALIGN 16384, 0
ALIGN 16384, 0
ENDIF

View File

@ -4,6 +4,9 @@
; https://github.com/romychs
; License: BSD 3-Clause
; ======================================================
IFNDEF _DSS_ERROR
DEFINE _DSS_ERROR
MODULE DSS_ERROR
ERR_MAX EQU 0x26
@ -12,7 +15,7 @@ ERR_MAX EQU 0x26
CHECK
RET NC
PRINT
EPRINT
PUSH AF
PRINT GET_ERR_MSG.MSG_DSS_ERROR
POP AF
@ -47,46 +50,46 @@ GET_ERR_MSG
RET
.MSG_DSS_ERROR
DB " Error: "Z
DB " Error: ",0
.MSG_E01 DB "Invalid function"Z
.MSG_E02 DB "Invalid drive number"Z
.MSG_E03 DB "File not found"Z
.MSG_E04 DB "Path not found"Z
.MSG_E05 DB "Invalid handle"Z
.MSG_E06 DB "Too many open files"Z
.MSG_E07 DB "File exist"Z
.MSG_E08 DB "File read only"Z
.MSG_E09 DB "Root overflow"Z
.MSG_E0A DB "No free space"Z
.MSG_E0B DB "Directory not empty"Z
.MSG_E0C DB "Attempt to remove current directory"Z
.MSG_E0D DB "Invalid media"Z
.MSG_E0E DB "Invalid operation"Z
.MSG_E0F DB "Directory exist"Z
.MSG_E10 DB "Invalid filename"Z
.MSG_E11 DB "Invalid EXE-file"Z
.MSG_E12 DB "Not supported EXE-file"Z
.MSG_E13 DB "Permission denied"Z
.MSG_E14 DB "Not ready"Z
.MSG_E15 DB "Seek error"Z
.MSG_E16 DB "Sector not found"Z
.MSG_E17 DB "CRC error"Z
.MSG_E18 DB "Write protect"Z
.MSG_E19 DB "Read error"Z
.MSG_E1A DB "Write error"Z
.MSG_E1B DB "Drive failure"Z
.MSG_E1C DB "Unknown error: 28"Z
.MSG_E1D DB "Unknown error: 29"Z
.MSG_E1E DB "No free memory"Z
.MSG_E1F DB "Invalid memory block"Z
.MSG_E20 DB "Unknown error: 32"Z
.MSG_E21 DB "Extended error: 33"Z
.MSG_E22 DB "Extended error: 34"Z
.MSG_E23 DB "Too many files"Z
.MSG_E24 DB "Too many or too nested folders (>1024)"Z
.MSG_E25 DB "User abort"Z
.MSG_E26 DB "Unknown error"Z
.MSG_E01 DB "Invalid function",0
.MSG_E02 DB "Invalid drive number",0
.MSG_E03 DB "File not found",0
.MSG_E04 DB "Path not found",0
.MSG_E05 DB "Invalid handle",0
.MSG_E06 DB "Too many open files",0
.MSG_E07 DB "File exist",0
.MSG_E08 DB "File read only",0
.MSG_E09 DB "Root overflow",0
.MSG_E0A DB "No free space",0
.MSG_E0B DB "Directory not empty",0
.MSG_E0C DB "Attempt to remove current directory",0
.MSG_E0D DB "Invalid media",0
.MSG_E0E DB "Invalid operation",0
.MSG_E0F DB "Directory exist",0
.MSG_E10 DB "Invalid filename",0
.MSG_E11 DB "Invalid EXE-file",0
.MSG_E12 DB "Not supported EXE-file",0
.MSG_E13 DB "Permission denied",0
.MSG_E14 DB "Not ready",0
.MSG_E15 DB "Seek error",0
.MSG_E16 DB "Sector not found",0
.MSG_E17 DB "CRC error",0
.MSG_E18 DB "Write protect",0
.MSG_E19 DB "Read error",0
.MSG_E1A DB "Write error",0
.MSG_E1B DB "Drive failure",0
.MSG_E1C DB "Unknown error: 28",0
.MSG_E1D DB "Unknown error: 29",0
.MSG_E1E DB "No free memory",0
.MSG_E1F DB "Invalid memory block",0
.MSG_E20 DB "Unknown error: 32",0
.MSG_E21 DB "Extended error: 33",0
.MSG_E22 DB "Extended error: 34",0
.MSG_E23 DB "Too many files",0
.MSG_E24 DB "Too many or too nested folders (>1024)",0
.MSG_E25 DB "User abort",0
.MSG_E26 DB "Unknown error",0
.ERR_OFFSETS
DW .MSG_E01,.MSG_E02,.MSG_E03,.MSG_E04,.MSG_E05,.MSG_E06,.MSG_E07,.MSG_E08
@ -96,4 +99,5 @@ GET_ERR_MSG
DW .MSG_E21,.MSG_E22,.MSG_E23,.MSG_E24,.MSG_E25,.MSG_E26
ENDMODULE
ENDIF

View File

@ -5,6 +5,9 @@
; License: BSD 3-Clause
; ======================================================
IFNDEF _ESP_LIB
DEFINE _ESP_LIB
INCLUDE "isa.asm"
INCLUDE "util.asm"
@ -132,8 +135,9 @@ UT_T_SLOT
CALL CHK_SCR
RET NZ
LD DE,0xAAAA
CALL CHK_SCR
RET
JP CHK_SCR
;CALL CHK_SCR
;RET
CHK_SCR
LD HL, REG_SCR
@ -152,20 +156,16 @@ UART_INIT
CALL ISA.ISA_OPEN
LD IX, PORT_UART_A
LD A, FCR_TR8 | FCR_FIFO ; Enable FIFO buffer, trigger to 14 byte
LD (IX+_FCR),A
LD (IX+_FCR),FCR_TR8 | FCR_FIFO ; Enable FIFO buffer, trigger to 14 byte
XOR A
LD (IX+_IER), A ; Disable interrupts
; Set 8bit word and Divisor for speed
LD A, LCR_DLAB | LCR_WL8
LD (IX+_LCR), A ; Enable Baud rate latch
LD A, DIVISOR
LD (IX+_DLL), A ; 8 - 115200
LD (IX+_LCR), LCR_DLAB | LCR_WL8 ; Enable Baud rate latch
LD (IX+_DLL), DIVISOR ; 8 - 115200
XOR A
LD (IX+_DLM), A
LD A, LCR_WL8 ; 8bit word, disable latch
LD (IX+_LCR), A
LD (IX+_LCR), LCR_WL8 ; 8bit word, disable latch
CALL ISA.ISA_CLOSE
POP IX,AF
@ -181,8 +181,9 @@ UART_INIT
UART_READ
CALL ISA.ISA_OPEN
LD A, (HL)
CALL ISA.ISA_CLOSE
RET
JP ISA.ISA_CLOSE
;CALL ISA.ISA_CLOSE
;RET
;ENDIF
; ------------------------------------------------------
; Write TL16C550 register
@ -192,8 +193,9 @@ UART_READ
UART_WRITE
CALL ISA.ISA_OPEN
LD (HL), E
CALL ISA.ISA_CLOSE
RET
JP ISA.ISA_CLOSE
;CALL ISA.ISA_CLOSE
;RET
;ENDIF
; ------------------------------------------------------
; Wait for transmitter ready
@ -203,8 +205,9 @@ UART_WRITE
UART_WAIT_TR
CALL ISA.ISA_OPEN
CALL UART_WAIT_TR_INT
CALL ISA.ISA_CLOSE
RET
JP ISA.ISA_CLOSE
;CALL ISA.ISA_CLOSE
;RET
;ENDIF
;
; Wait, without open/close ISA
@ -333,7 +336,8 @@ UART_EMPTY_RS
; ------------------------------------------------------
UART_WAIT_RS1
PUSH BC,HL
WAIT_MS+* LD BC,0x2000
WAIT_MS EQU $+1
LD BC,0x2000
JR UVR_NEXT
UART_WAIT_RS
PUSH BC,HL
@ -507,4 +511,6 @@ MSG_FAIL DB "FAIL", 0
RS_BUFF
;DS RS_BUFF_SIZE, 0
ENDMODULE
ENDMODULE
END

View File

@ -40,7 +40,7 @@ DEFAULT_TIMEOUT EQU 2000
; ------------------------------------------------------
EXE_HEADER
DB "EXE"
DB EXE_VERSION ; EXE Version
DB EXE_VERSION util.asm(418) ; EXE Version
DW 0x0080 ; Code offset
DW 0
DW 0 ; Primary loader size
@ -163,7 +163,7 @@ SET_DHCP_MODE
PUSH BC,DE
LD DE, WIFI.RS_BUFF
LD BC, DEFAULT_TIMEOUT
TRACELN MSG_SET_DHCP
TRACELN MSG_SET_DHCPutil.asm(418)
SEND_CMD CMD_SET_DHCP
POP DE,BC
RET

View File

@ -5,8 +5,8 @@
; License: BSD 3-Clause
; ======================================================
IFNDEF _ISA_ASM
DEFINE _ISA_ASM
IFNDEF _ISA
DEFINE _ISA
INCLUDE "sprinter.inc"
INCLUDE "util.asm"
@ -39,8 +39,8 @@ ISA_RESET
XOR A
OUT (C), A ; RESET=0 AEN=0
LD HL,100
CALL @UTIL.DELAY
RET
JP @UTIL.DELAY
;RET
; ------------------------------------------------------
; Open access to ISA ports as memory
@ -54,7 +54,8 @@ ISA_OPEN
LD BC, PORT_SYSTEM
LD A, 0x11
OUT (C), A
ISA_SLOT+* LD A,0x00
ISA_SLOT EQU $+1
LD A,0x00
SLA A
OR A, 0xD4 ; D4 - ISA1, D6 - ISA2
LD BC, PAGE3

View File

@ -62,7 +62,8 @@
; If current work mode is upload, go to label
MACRO IF_UPLOAD_GO lbl
LD A,(WORK_MODE)
CP WM_UPLOAD
;CP WM_UPLOAD
DEC A
JR Z,lbl
ENDM

View File

@ -29,24 +29,24 @@ OP_ERROR EQU '50'
BUILD_RRQ_PACKET
PUSH DE
LD DE,OP_RRQ ; opcode
CALL .BUILD_RW_PACKET
CALL BUILD_RW_PACKET
POP DE
RET
; ------------------------------------------------------
; Build packet for write file to TFTF-server
; ------------------------------------------------------
!BUILD_WRQ_PACKET
BUILD_WRQ_PACKET
PUSH DE
LD DE,OP_WRQ ; opcode
CALL .BUILD_RW_PACKET
CALL BUILD_RW_PACKET
POP DE
RET
; ------------------------------------------------------
; Build packet for write file or receive form TFTF-server
; ------------------------------------------------------
.BUILD_RW_PACKET
BUILD_RW_PACKET
LD HL,TFTP_BUFF
LD (HL), DE
INC HL
@ -72,7 +72,7 @@ BUILD_RRQ_PACKET
LD (HL),DE
INC HL
INC HL
LD DE,'t'
LD D, 0 ; DE = "/0t"
LD (HL),DE
INC HL
INC HL
@ -145,14 +145,14 @@ CHK_ERROR
; Defined TFTP Protocol Error messages
; ------------------------------------------------------
;MSG_TFTPE_0 DB "Not defined, see error message (if any)."Z
.MSG_TFTPE_1 DB "File not found."Z
.MSG_TFTPE_2 DB "Access violation."Z
.MSG_TFTPE_3 DB "Disk full or allocation exceeded."Z
.MSG_TFTPE_4 DB "Illegal TFTP operation."Z
.MSG_TFTPE_5 DB "Unknown transfer ID."Z
.MSG_TFTPE_6 DB "File already exists."Z
.MSG_TFTPE_7 DB "No such user."Z
;MSG_TFTPE_0 DB "Not defined, see error message (if any).",0
.MSG_TFTPE_1 DB "File not found.",0
.MSG_TFTPE_2 DB "Access violation.",0
.MSG_TFTPE_3 DB "Disk full or allocation exceeded.",0
.MSG_TFTPE_4 DB "Illegal TFTP operation.",0
.MSG_TFTPE_5 DB "Unknown transfer ID.",0
.MSG_TFTPE_6 DB "File already exists.",0
.MSG_TFTPE_7 DB "No such user.",0
; Table with error messages offsets
.TFTPE_T
@ -160,10 +160,10 @@ CHK_ERROR
DW .MSG_TFTPE_4,.MSG_TFTPE_5,.MSG_TFTPE_7,.MSG_TFTPE_7
.MSG_TFTP_ERR
DB "Protocol error: "Z
DB "Protocol error: ",0
.MSG_ERR_UPT
DB "Unknown TFTP packet received!"Z
DB "Unknown TFTP packet received!",0
; Buffer for UDP datagram with TFTP payload
TFTF_PACKET_LEN

View File

@ -5,10 +5,12 @@
; License: BSD 3-Clause
; ======================================================
IFNDEF _UTIL_ASM
DEFINE _UTIL_ASM
IFNDEF _UTIL
DEFINE _UTIL
MODULE UTIL
include "dss_error.asm"
; ------------------------------------------------------
; Small delay
@ -65,14 +67,14 @@ DELAY_100uS
; Inp: HL - pointer to string
; Out: BC - length of string
; ------------------------------------------------------
IFUSED STRLEN
;;IFUSED STRLEN
STRLEN
PUSH DE,HL,HL
LD BC,MAX_BUFF_SIZE
XOR A
CPIR
POP DE
SUB HL,DE ; llength of zero ended string
SBC HL,DE ; length of zero ended string
LD BC,HL
LD A, B
OR C
@ -81,14 +83,14 @@ STRLEN
.STRL_NCOR
POP HL,DE
RET
ENDIF
;ENDIF
; ------------------------------------------------------
; Compare strings
; Inp: HL, DE - pointers to asciiz strings to compare
; Out: CF=0 - equal, CF=1 - not equal
; ------------------------------------------------------
IFUSED STRCMP
;;IFUSED STRCMP
STRCMP
PUSH DE,HL
.STC_NEXT
@ -105,7 +107,7 @@ STRCMP
.STC_EQ
POP HL,DE
RET
ENDIF
;;ENDIF
@ -115,7 +117,7 @@ STRCMP
; BC - Number of chars to compare
; Out: ZF=0 - not equal, ZF=1 - equal
; ------------------------------------------------------
IFUSED STRNCMP
;IFUSED STRNCMP
STRNCMP
PUSH HL,DE,BC
.STRN_NXT
@ -134,7 +136,7 @@ STRNCMP
.STRN_NE
POP BC,DE,HL
RET
ENDIF
;ENDIF
; ------------------------------------------------------
; Checks whether a string (HL) starts with the strinf (DE)
@ -142,7 +144,7 @@ STRNCMP
; HL - points to string
; Out: ZF=0 - not equal, ZF=1 - equal
; ------------------------------------------------------
IFUSED STARTSWITH
;;IFUSED STARTSWITH
STARTSWITH
PUSH HL,DE
.STRW_NXT
@ -158,7 +160,7 @@ STARTSWITH
.STRW_END
POP DE,HL
RET
ENDIF
;;ENDIF
; ------------------------------------------------------
@ -166,7 +168,7 @@ STARTSWITH
; Inp: HL - pointer to string
; Out: HL - points to first non space symbol
; ------------------------------------------------------
IFUSED LTRIM
;;IFUSED LTRIM
LTRIM
LD A, (HL)
OR A
@ -175,14 +177,14 @@ LTRIM
RET P
INC HL
JR LTRIM
ENDIF
;;ENDIF
; ------------------------------------------------------
; Convert string to number
; Inp: DE - ptr to zero ended string
; Out: HL - Result
; ------------------------------------------------------
IFUSED ATOU
;;IFUSED ATOU
ATOU
PUSH BC
LD HL,0x0000
@ -208,7 +210,7 @@ ATOU
.ATOU_LE
POP BC
RET
ENDIF
;;ENDIF
; ------------------------------------------------------
; Convert 16 bit unsigned number to string
@ -216,7 +218,7 @@ ATOU
; DE - ptr to buffer
; Out: DE -> asciiz string representing a number
; ------------------------------------------------------
IFUSED UTOA
;;IFUSED UTOA
UTOA:
PUSH BC, HL
XOR A
@ -263,7 +265,7 @@ DIV_10:
DJNZ .DDL1
POP BC
RET
ENDIF
;;ENDIF
; ------------------------------------------------------
; FAST_UTOA
; Inp: HL - number
@ -271,7 +273,7 @@ DIV_10:
; CF is set to write leading zeroes
; Out: DE - address of strinf
; ------------------------------------------------------
IFUSED FAST_UTOA
;;IFUSED FAST_UTOA
FAST_UTOA
LD BC,0+256
PUSH BC
@ -343,7 +345,7 @@ FAST_UTOA
INC DE
JR .LEADING_ZEROES
ENDIF
;;ENDIF
; ------------------------------------------------------
; Find char in string
@ -352,7 +354,7 @@ FAST_UTOA
; Outp: CF=0, HL points to char if found
; CF=1 - Not found
; ------------------------------------------------------
IFUSED STRCHR
;;IFUSED STRCHR
STRCHR
PUSH BC
.STCH_NEXT
@ -363,20 +365,20 @@ STRCHR
CP C
JR Z, .STCH_FOUND
INC HL
JR STCH_NEXT
JR .STCH_NEXT
.STCH_N_FOUND
SCF
.STCH_FOUND
POP BC
RET
ENDIF
;;ENDIF
; ------------------------------------------------------
; Convert Byte to hex
; Inp: C
; Out: (DE)
; ------------------------------------------------------
IFUSED HEXB
;;IFUSED HEXB
HEXB
LD A,C
RRA
@ -395,7 +397,7 @@ HEXB
LD (DE), A
INC DE
RET
ENDIF
;;ENDIF
; ----------------------------------------------------
@ -407,7 +409,7 @@ GET_CUR_DIR
PUSH HL
LD C, DSS_CURDISK
RST DSS
CALL DSS_ERROR.CHECK
CALL @DSS_ERROR.CHECK
ADD A, 65
LD (HL),A
INC HL
@ -415,10 +417,10 @@ GET_CUR_DIR
INC HL
LD C, DSS_CURDIR
RST DSS
CALL DSS_ERROR.CHECK
CALL @DSS_ERROR.CHECK
POP HL
CALL ADD_BACK_SLASH
RET
JP ADD_BACK_SLASH
;RET
; ----------------------------------------------------
; Add back slash to path string

View File

@ -1,81 +0,0 @@
; ------------------------------------------------------
; FAST_UTOA
; Inp: HL - number
; A - Radix 2,8,10,16
; DE - Buffer
; CF is set to write leading zeroes
; Out: DE - address of strinf
; ------------------------------------------------------
FAST_UTOA
LD BC,0+256
PUSH BC
LD BC,-10+256
PUSH BC
INC H
DEC H
JR Z, .EIGHT_BIT
LD C,0XFF & (-100+256)
PUSH BC
LD BC,-1000+256
PUSH BC
LD BC,-10000
JR C,.LEADING_ZEROES
.NO_LEADING_ZEROES
CALL .DIVIDE
CP '0'
JR NZ,.WRITE
POP BC
DJNZ .NO_LEADING_ZEROES
JR .WRITE1S
.LEADING_ZEROES
CALL .DIVIDE
.WRITE
LD (DE),A
INC DE
POP BC
DJNZ .LEADING_ZEROES
.WRITE1S
LD A,L
ADD A,'0'
LD (DE),A
INC DE
RET
.DIVIDE
LD A,'0'-1
.DIVLOOP
INC A
ADD HL,BC
JR C, .DIVLOOP
SBC HL,BC
RET
.EIGHT_BIT
LD BC,-100
JR NC, .NO_LEADING_ZEROES
; write two leading zeroes to output string
LD A,'0'
LD (DE),A
INC DE
LD (DE),A
INC DE
JR .LEADING_ZEROES

View File

@ -4,6 +4,10 @@
; https://github.com/romychs
; License: BSD 3-Clause
; ======================================================
IFNDEF _WCOMMON
DEFINE _WCOMMON
ENABLE_RTS_CTR EQU 1
@ -12,7 +16,7 @@ ENABLE_RTS_CTR EQU 1
; ------------------------------------------------------
; Ckeck for error (CF=1) print message and exit
; ------------------------------------------------------
IFUSED CHECK_ERROR
;;IFUSED CHECK_ERROR
CHECK_ERROR
RET NC
ADD A,'0'
@ -21,7 +25,7 @@ CHECK_ERROR
CALL DUMP_UART_REGS
LD B,3
POP HL ; ret addr reset
ENDIF
;;ENDIF
; ------------------------------------------------------
; Program exit point
@ -32,7 +36,7 @@ EXIT
; ------------------------------------------------------
; Search Sprinter WiFi card
; ------------------------------------------------------
IFUSED FIND_SWF
;;IFUSED FIND_SWF
FIND_SWF
; Find Sprinter-WiFi
CALL @WIFI.UART_FIND
@ -48,12 +52,12 @@ NO_TL_FOUND
PRINTLN MSG_SWF_NOF
LD B,2
JP EXIT
ENDIF
;;ENDIF
; ------------------------------------------------------
; Dump all UTL16C550 registers to screen for debug
; ------------------------------------------------------
IFUSED DUMP_UART_REGS
;;IFUSED DUMP_UART_REGS
IFDEF TRACE
DUMP_UART_REGS
; Dump, DLAB=0 registers
@ -70,8 +74,9 @@ DUMP_UART_REGS
LD HL, REG_LCR
LD E, LCR_WL8
CALL WIFI.UART_WRITE
RET
JP WIFI.UART_WRITE
;CALL WIFI.UART_WRITE
;RET
DUMP_REGS
LD HL, PORT_UART_A
@ -95,12 +100,12 @@ DR_NEXT
DJNZ DR_NEXT
RET
ENDIF
ENDIF
;;ENDIF
; ------------------------------------------------------
; Store old video mode, set 80x32 and clear
; ------------------------------------------------------
IFUSED INIT_VMODE
;;IFUSED INIT_VMODE
INIT_VMODE
PUSH BC,DE,HL
; Store previous vmode
@ -116,19 +121,18 @@ INIT_VMODE
IVM_ALRDY_80
; Clear screen
LD A,' '
LD B,0x07
LD C,DSS_CLEAR
LD BC,0x0700 + DSS_CLEAR
LD HL,0x2050
LD DE,0x0000
RST DSS
POP HL,DE,BC
RET
ENDIF
;;ENDIF
; ------------------------------------------------------
; Restore saved video mode
; ------------------------------------------------------
IFUSED REST_VMODE
;;IFUSED REST_VMODE
REST_VMODE
PUSH BC
LD A,(SAVE_VMODE)
@ -145,12 +149,12 @@ REST_VMODE
RVM_SAME
POP BC
RET
ENDIF
;;ENDIF
; ------------------------------------------------------
; Init basic parameters of ESP
; ------------------------------------------------------
IFUSED INIT_ESP
;;IFUSED INIT_ESP
INIT_ESP
PUSH BC, DE
LD DE, @WIFI.RS_BUFF
@ -174,12 +178,12 @@ INIT_ESP
SEND_CMD CMD_CWLAP_OPT
POP DE,BC
RET
ENDIF
;;ENDIF
; ------------------------------------------------------
; Set DHCP mode
; Out: CF=1 if error
; ------------------------------------------------------
IFUSED SET_DHCP_MODE
;;IFUSED SET_DHCP_MODE
SET_DHCP_MODE
PUSH BC,DE
LD DE, WIFI.RS_BUFF
@ -188,19 +192,19 @@ SET_DHCP_MODE
SEND_CMD CMD_SET_DHCP
POP DE,BC
RET
ENDIF
;;ENDIF
; ------------------------------------------------------
; Messages
; ------------------------------------------------------
IFUSED FIND_SWF
;;IFUSED FIND_SWF
MSG_SWF_NOF
DB "Sprinter-WiFi not found!",0
MSG_SWF_FOUND
DB "Sprinter-WiFi found in ISA#"
MSG_SLOT_NO
DB "n slot.",0
ENDIF
;;ENDIF
MSG_COMM_ERROR
DB "Error communication with Sprinter-WiFi #"
@ -220,10 +224,10 @@ MSG_UART_INIT
LINE_END
DB "\r\n",0
IFUSED INIT_VMODE
;;IFUSED INIT_VMODE
SAVE_VMODE
DB 0
ENDIF
;;ENDIF
; ------------------------------------------------------
; Debug messages
@ -286,4 +290,6 @@ CMD_GET_IP
DB "AT+CIPSTA?\r\n",0
ENDMODULE
ENDMODULE
ENDIF

View File

@ -10,7 +10,7 @@
;DEFINE EQU 0
; Define to output TRACE messages
DEFINE TRACE
DEFINE TRACE
; Version of EXE file, 1 for DSS 1.70+
@ -19,11 +19,9 @@ EXE_VERSION EQU 1
; Timeout to wait ESP response
DEFAULT_TIMEOUT EQU 2000
DEFDEVICE SPRINTER, 0x4000, 256, 0,1,2,3
;DEFDEVICE SPRINTER, 0x4000, 256, 0,1,2,3
SLDOPT COMMENT WPMEM, LOGPOINT, ASSERTION
DEVICE SPRINTER ;NOSLOT64K
DEVICE NOSLOT64K
IFDEF DEBUG
INCLUDE "dss.asm"
@ -205,27 +203,27 @@ OK_EXIT
; ------------------------------------------------------
MSG_START
DB "Terminal for Sprinter-WiFi by Sprinter Team. v1.0 beta3, ", __DATE__, "\r\n"Z
DB "Terminal for Sprinter-WiFi by Sprinter Team. v1.0 beta3, ", __DATE__, "\r\n",0
MSG_HLP
DB"\r\nEnter ESP AT command or Alt+x to close terminal."Z
DB"\r\nEnter ESP AT command or Alt+x to close terminal.",0
MSG_EXIT
MSG_TX_ERROR
DB "Transmitter not ready"Z
DB "Transmitter not ready",0
MSG_RX_ERROR
DB "Receiver error LSR: 0x"
MSG_LSR_VALUE
DB "xx"Z
DB "xx",0
MSG_MANY_RX_ERROR
DB "Too many receiver errors!"Z
DB "Too many receiver errors!",0
MSG_ALT
DB "Pressed ALT+"
MSG_ALT_KEY
DB "xx"Z
DB "xx",0
; TX_DATA
; DB " ",0
@ -233,21 +231,22 @@ MSG_ALT_KEY
; Custom commands
; ------------------------------------------------------
CMD_QUIT
DB "QUIT\r"Z
DB "QUIT\r",0
RX_ERR
DB 0
IFDEF DEBUG
CMD_TEST1 DB "ATE0\r\n"Z
CMD_TEST1 DB "ATE0\r\n",0
BUFF_TEST1 DS RS_BUFF_SIZE,0
ENDIF
ENDMODULE
INCLUDE "wcommon.asm"
INCLUDE "dss_error.asm"
;INCLUDE "util.asm"
INCLUDE "isa.asm"
INCLUDE "esplib.asm"
END MAIN.START
END ;MAIN.START

View File

@ -85,8 +85,8 @@ DONE
CALL CLOSE_LOCAL_FILE
;IFDEF DEBUG
LD B,0
DSS_EXEC DSS_EXIT
LD BC, DSS_EXIT
RST DSS
;ENDIF
@ -147,8 +147,9 @@ PARSE_CMD_LINE
; handle lfn
CALL GET_LFN
CALL COPY_LFN
RET
JP COPY_LFN
;CALL COPY_LFN
;RET
.PLC_UPLOAD
; Work mode "Upload"
@ -162,9 +163,9 @@ PARSE_CMD_LINE
CALL @UTIL.STARTSWITH
JR NZ,OUT_USAGE_MSG
CALL GET_SRV_PARAMS
RET
JP GET_SRV_PARAMS
;CALL GET_SRV_PARAMS
;RET
; ------------------------------------------------------
OUT_ERR_CMD_MSG
@ -339,7 +340,7 @@ OPEN_LOCAL_FILE
OR A
JR NZ,.OLF_SKP_CP
LD HL, @TMP_BUFF
LD HL, TMP_BUFF
CALL UTIL.GET_CUR_DIR
LD DE,LOC_FILE
LD B,128
@ -352,7 +353,7 @@ OPEN_LOCAL_FILE
INC DE
DJNZ .OLF_NXT
.OLF_EFN
LD HL, @TMP_BUFF
LD HL, TMP_BUFF
; HL - points to file path name
.OLF_SKP_CP
@ -372,7 +373,7 @@ OPEN_LOCAL_FILE
POP HL
JR NC,.OLF_END
CP 0x07 ; file exists?
JP NZ,DSS_ERROR.PRINT ; print error and exit
JP NZ,DSS_ERROR.EPRINT ; print error and exit
PUSH HL
PRINTLN MSG_OF_EXISTS
POP HL
@ -405,15 +406,15 @@ PRINT_FILENAME
MSG_OF_EXISTS
DB "Output file already exists!"Z
DB "Output file already exists!",0
IFDEF TRACE
MSG_LFN_CR
DB "Create file: "Z
DB "Create file: ",0
MSG_LFN_OP
DB "Open file: "Z
DB "Open file: ",0
MSG_LFN_OPEN
DB "File successfully accessed."Z
DB "File successfully accessed.",0
ENDIF
@ -425,8 +426,9 @@ CLOSE_LOCAL_FILE
OR A
RET Z
DSS_EXEC DSS_CLOSE_FILE
CALL DSS_ERROR.CHECK
RET
JP DSS_ERROR.CHECK
;CALL DSS_ERROR.CHECK
;RET
; ------------------------------------------------------
; Display current working mode
@ -456,48 +458,48 @@ DISPLAY_MODE
; ------------------------------------------------------
MSG_START
DB "TFTP client for Sprinter-WiFi by Sprinter Team. v1.0 beta1, ", __DATE__, "\r\n"Z
DB "TFTP client for Sprinter-WiFi by Sprinter Team. v1.0 beta1, ", __DATE__, "\r\n",0
MSG_ERR_CMD
DB "Invalid command line parameters!\r\n"Z
DB "Invalid command line parameters!\r\n",0
MSG_HLP
DB "\r\nUse:\r\n wtftp.exe tftp://server[:port]/filename filename - to download from server;\r\n"
DB " wtftp.exe filename tftp://server[:port]/filename - to upload to server.\r\n"Z
DB " wtftp.exe filename tftp://server[:port]/filename - to upload to server.\r\n",0
MSG_TX_ERROR
DB "Transmitter not ready"Z
DB "Transmitter not ready",0
MSG_RX_ERROR
DB "Receiver error LSR: 0x"
MSG_LSR_VALUE
DB "xx"Z
DB "xx",0
MSG_MANY_RX_ERROR
DB "Too many receiver errors!"Z
DB "Too many receiver errors!",0
MSG_ERR_PORT
DB "Invalid UDP port in URL, will be number 1..65535"Z
DB "Invalid UDP port in URL, will be number 1..65535",0
MSG_ERR_RFN
DB "Remote file name not specified in URL, or too long!"Z
DB "Remote file name not specified in URL, or too long!",0
MSG_ERR_LFN
DB "Invalid local file name!"Z
DB "Invalid local file name!",0
MSG_MODE_D
DB "Download file "Z
DB "Download file ",0
MSG_MODE_D_S
DB " from server "Z
DB " from server ",0
MSG_MODE_D_T
DB " to file "Z
DB " to file ",0
MSG_MODE_U
DB "Upload file "Z
DB "Upload file ",0
MSG_MODE_U_S
DB " to server "Z
DB " to server ",0
MSG_MODE_U_T
DB " to file "Z
DB " to file ",0
; ------------------------------------------------------
; Variables
@ -505,7 +507,7 @@ MSG_MODE_U_T
; Start of tftf URL
TFTF_START
DB "tftp://"Z
DB "tftp://",0
; Work Mode
@ -528,7 +530,7 @@ REM_FILE
LOC_FILE
DS 128,0
; Local file handle
; Local file handlewtftp.asm(343)
LOC_FH
DW 0
@ -536,6 +538,8 @@ LOC_FH
HAVE_PATH
DB 0
TMP_BUFF EQU WIFI.RS_BUFF + RS_BUFF_SIZE
ENDMODULE
; ------------------------------------------------------
; Includes
@ -549,6 +553,6 @@ HAVE_PATH
INCLUDE "esplib.asm"
TMP_BUFF
END MAIN.START