diff --git a/sources/DSS/.vscode/tasks.json b/sources/DSS/.vscode/tasks.json index 105b8cb..9a48e77 100644 --- a/sources/DSS/.vscode/tasks.json +++ b/sources/DSS/.vscode/tasks.json @@ -166,7 +166,7 @@ }, "group": { "kind": "build", - "isDefault": true + "isDefault": false } }, diff --git a/sources/DSS/tftp.asm b/sources/DSS/tftp.asm index 0ccfa29..a7b87d7 100644 --- a/sources/DSS/tftp.asm +++ b/sources/DSS/tftp.asm @@ -8,19 +8,19 @@ MODULE TFTP ; ------------------------------------------------------ -; Operation codes 2b for tftp packet header +; Operation codes 2b for tftp packet header (bytes swapped) ; ------------------------------------------------------ ; Opcode Read Request -OP_RRQ EQU '01' +OP_RRQ EQU '10' ; Opcode Write Request -OP_WRQ EQU '02' +OP_WRQ EQU '20' ; Opcode Data packet -OP_DATA EQU '03' +OP_DATA EQU '30' ; Opcode Acknowledge packet -OP_ACK EQU '04' +OP_ACK EQU '40' ; Opcode Error packet -OP_ERROR EQU '05' +OP_ERROR EQU '50' ; ------------------------------------------------------ ; Build packet for request file from TFTF-server @@ -30,7 +30,7 @@ BUILD_RRQ_PACKET PUSH DE LD DE,OP_RRQ ; opcode CALL .BUILD_RW_PACKET - POP HL,DE + POP DE RET ; ------------------------------------------------------ @@ -40,15 +40,14 @@ BUILD_RRQ_PACKET PUSH DE LD DE,OP_WRQ ; opcode CALL .BUILD_RW_PACKET - POP HL,DE + POP DE RET ; ------------------------------------------------------ ; Build packet for write file or receive form TFTF-server ; ------------------------------------------------------ -.BUILD_RW_PACKET +.BUILD_RW_PACKET LD HL,TFTP_BUFF - PUSH HL LD (HL), DE INC HL INC HL @@ -65,14 +64,24 @@ BUILD_RRQ_PACKET ; Mode 'octet'Z .BRP_MOD INC HL - LD DE,'ct' + LD DE,'co' LD (HL),DE INC HL + INC HL LD DE,'et' LD (HL),DE INC HL + INC HL LD DE,'t' LD (HL),DE + INC HL + INC HL + ; Calculate packet length + LD DE, TFTP_BUFF + SBC HL,DE + EX DE,HL + LD HL,TFTF_PACKET_LEN + LD (HL),DE RET ; ------------------------------------------------------ @@ -157,6 +166,8 @@ CHK_ERROR DB "Unknown TFTP packet received!"Z ; Buffer for UDP datagram with TFTP payload +TFTF_PACKET_LEN + DW 0 TFTP_BUFF DS 516,0 diff --git a/sources/DSS/wtftp.asm b/sources/DSS/wtftp.asm index 1be358a..fb0940a 100644 --- a/sources/DSS/wtftp.asm +++ b/sources/DSS/wtftp.asm @@ -8,7 +8,7 @@ ; Set to 1 to turn debug ON with DeZog VSCode plugin ; Set to 0 to compile .EXE -; DEFINE DEBUG + DEFINE DEBUG ; Set to 1 to output TRACE messages DEFINE TRACE @@ -62,7 +62,7 @@ EXE_HEADER START IFDEF DEBUG - LD IX,CMD_LINE_TFTP_D1 + LD IX,CMD_LINE_TFTP_U LD SP, STACK_TOP ENDIF @@ -121,6 +121,7 @@ OK_EXIT JP WCOMMON.EXIT ; ------------------------------------------------------ +; Parse command line parameters ; IX - points to cmd line ; ------------------------------------------------------ PARSE_CMD_LINE @@ -174,7 +175,6 @@ OUT_USAGE_MSG PRINTLN MSG_HLP JP OK_EXIT - ; ------------------------------------------------------ ; Move srv name and port number from (HL) to (DE) ; ------------------------------------------------------ @@ -237,8 +237,6 @@ GET_SRV_PARAMS .GDNF_NXT INC HL LD A,(HL) -; OR A -; JR Z,.GDNF_END CP 0x21 JP M,.GDNF_END LD (DE),A @@ -261,8 +259,8 @@ GET_SRV_PARAMS RET ; ------------------------------------------------------ -; Get local file name from command string -; +; Get local file name from command line +; Inp: HL -> command line ; ------------------------------------------------------ GET_LFN PUSH BC,DE @@ -342,7 +340,6 @@ OPEN_LOCAL_FILE JR NZ,.OLF_SKP_CP LD HL, @TMP_BUFF - ;PUSH HL CALL UTIL.GET_CUR_DIR LD DE,LOC_FILE LD B,128 @@ -356,7 +353,6 @@ OPEN_LOCAL_FILE DJNZ .OLF_NXT .OLF_EFN LD HL, @TMP_BUFF - ;POP HL ; HL - points to file path name .OLF_SKP_CP @@ -432,8 +428,6 @@ CLOSE_LOCAL_FILE CALL DSS_ERROR.CHECK RET - - ; ------------------------------------------------------ ; Display current working mode ; ------------------------------------------------------