Files

382 lines
16 KiB
Plaintext

GSP COFF Assembler, Version 2.00, 87.300 Sun Oct 18 17:26:10 2026
(c) Copyright 1985, 1987, Texas Instruments Inc.
PAGE 1
0001 ; tftpr.asm -- tftpc.asm retargeted for the real unit a
0002 ; Server: 100.103.255.254:69; RRQ name: "xtext.coff".
0003 ;
0004 ; tftpc.asm -- minimal TFTP read client built on the fi
0005 ;
0006 ; The firmware's own tftp_open() calls a resolver that
0007 ; called from the rdebug process (dwt/notes/TCPIP.md),
0008 ; RFC 783 directly: RRQ, DATA/ACK, 512-byte blocks, one
0009 ;
0010 ; socket = 3F5C9A00h socket(2,2,0) -> fd
0011 ; sendto = 3F5D3D70h sendto(fd, buf, len, flags, t
0012 ; recvfrom = 3F5D7D50h recvfrom(fd, buf, len, flags,
0013 ; close = 3F5E8930h close(fd)
0014 ; malloc = 3F701230h malloc(bytes) -> bit pointer
0015 ;
0016 ; The transfer is 600 bytes, so DATA 1 is 512 (full) an
0017 ; (short); the short block ends the transfer. ACKs go
0018 ; recvfrom reports, not to a hard-coded port.
0019 ;
0020 ; Evidence cells (32-bit, bit addresses):
0021 ; 0187C000 stage (1 malloc, 2 socket, 3 receiving, 4
0022 ; 0187C020 fd
0023 ; 0187C040 destination buffer (malloc)
0024 ; 0187C060 total bytes fetched
0025 ; 0187C080 last recvfrom length
0026 ; 0187C0A0 last DATA block word as read from the wir
0027 ; 0187C0C0 marker 05A5A5A5h when the fetch completed
0028 ; 0187C200 entry SP
0029 ; 0187C220 entry A14
0030 ;
0031 ; Scratch (fixed bit addresses, above this image):
0032 ; 01875000 argument area
0033 ; 01876000 receive buffer (2048 bytes)
0034 ; 0187A000 recvfrom source sockaddr
0035 ; 0187A080 recvfrom sockaddr length
0036 ; 0187A100 ACK packet (4 bytes)
0037
0038 00000000 .text
0039 00000000 _start:
0040 00000000 0550 setf 16, 0, 0
0041 00000010 0740 setf 32, 0, 1
0042 00000020 098F mmtm sp, a0,a1,a2,a3,a4,a5,a6,a7
00000030 FF00
0043 00000040 078F move sp, @0187C200h, 1
00000050 0187C200
0044 00000070 078E move a14, @0187C220h, 1
00000080 0187C220
0045
0046 000000A0 09E0 movi 1, a0, L
000000B0 00000001
0047 000000D0 0780 move a0, @0187C000h, 1
000000E0 0187C000
0048
0049 ; ---- buf = malloc(010000h) -------------------------
0050 00000100 A3CF move a14, -*sp, 1
0051 00000110 09EE movi 01875000h, a14, L
GSP COFF Assembler, Version 2.00, 87.300 Sun Oct 18 17:26:10 2026
(c) Copyright 1985, 1987, Texas Instruments Inc.
PAGE 2
00000120 01875000
0052 00000140 09E0 movi 010000h, a0, L
00000150 00010000
0053 00000170 920E move a0, *a14+, 1
0054 00000180 0D5F calla 3F701230h
00000190 3F701230
0055 000001B0 07AF move @0187C200h, sp, 1
000001C0 0187C200
0056 000001E0 07AE move @0187C220h, a14, 1
000001F0 0187C220
0057 00000210 0550 setf 16, 0, 0
0058 00000220 0740 setf 32, 0, 1
0059 00000230 0788 move a8, @0187C040h, 1
00000240 0187C040
0060 00000260 4D0B move a8, a11 ; dest cursor (callee-saved)
0061 00000270 4D08 move a8, a8
0062 00000280 CA00 jreq fail
00000290 010F
0063
0064 000002A0 09E0 movi 2, a0, L
000002B0 00000002
0065 000002D0 0780 move a0, @0187C000h, 1
000002E0 0187C000
0066
0067 ; ---- fd = socket(2,2,0) ----------------------------
0068 00000300 09EE movi 01875000h, a14, L
00000310 01875000
0069 00000330 09E0 movi 0, a0, L
00000340 00000000
0070 00000360 920E move a0, *a14+, 1
0071 00000370 09E0 movi 2, a0, L
00000380 00000002
0072 000003A0 920E move a0, *a14+, 1
0073 000003B0 09E0 movi 2, a0, L
000003C0 00000002
0074 000003E0 920E move a0, *a14+, 1
0075 000003F0 0D5F calla 3F5C9A00h
00000400 3F5C9A00
0076 00000420 07AF move @0187C200h, sp, 1
00000430 0187C200
0077 00000450 07AE move @0187C220h, a14, 1
00000460 0187C220
0078 00000480 0550 setf 16, 0, 0
0079 00000490 0740 setf 32, 0, 1
0080 000004A0 0788 move a8, @0187C020h, 1
000004B0 0187C020
0081 000004D0 4D09 move a8, a9 ; fd (callee-saved)
0082 000004E0 4D08 move a8, a8
0083 000004F0 C400 jrlt fail
00000500 00E8
0084
0085 ; ---- sendto(fd, RRQ, 28, 0, SADDR, 16) -------------
0086 00000510 09EE movi 01875000h, a14, L
00000520 01875000
0087 00000540 09E0 movi 16, a0, L
00000550 00000010
GSP COFF Assembler, Version 2.00, 87.300 Sun Oct 18 17:26:10 2026
(c) Copyright 1985, 1987, Texas Instruments Inc.
PAGE 3
0088 00000570 920E move a0, *a14+, 1
0089 00000580 09E0 movi SADDR, a0, L
00000590 000014F0'
0090 000005B0 920E move a0, *a14+, 1
0091 000005C0 09E0 movi 0, a0, L
000005D0 00000000
0092 000005F0 920E move a0, *a14+, 1
0093 00000600 09E0 movi 20, a0, L
00000610 00000014
0094 00000630 920E move a0, *a14+, 1
0095 00000640 09E0 movi RRQ, a0, L
00000650 00001450'
0096 00000670 920E move a0, *a14+, 1
0097 00000680 932E move a9, *a14+, 1
0098 00000690 0D5F calla 3F5D3D70h
000006A0 3F5D3D70
0099 000006C0 07AF move @0187C200h, sp, 1
000006D0 0187C200
0100 000006F0 07AE move @0187C220h, a14, 1
00000700 0187C220
0101 00000720 0550 setf 16, 0, 0
0102 00000730 0740 setf 32, 0, 1
0103 00000740 4D08 move a8, a8
0104 00000750 C400 jrlt fail
00000760 00C2
0105
0106 00000770 09E0 movi 3, a0, L
00000780 00000003
0107 000007A0 0780 move a0, @0187C000h, 1
000007B0 0187C000
0108 000007D0 4400 sub a0, a0
0109 000007E0 0780 move a0, @0187C060h, 1 ; total = 0
000007F0 0187C060
0110
0111 00000810 recv_loop:
0112 ; ---- recvfrom(fd, BUF, 2048, 0, &FROM, &FROMLEN) ---
0113 ; arg5 is a POINTER to the socklen (as tftp_read passe
0114 ; value is initialised to 16 first.
0115 00000810 09E0 movi 16, a0, L
00000820 00000010
0116 00000840 0780 move a0, @0187A080h, 1 ; fromlen = 16
00000850 0187A080
0117 00000870 09EE movi 01875000h, a14, L
00000880 01875000
0118 000008A0 09E0 movi 0187A080h, a0, L
000008B0 0187A080
0119 000008D0 920E move a0, *a14+, 1 ; arg5 = &fromlen
0120 000008E0 09E0 movi 0187A000h, a0, L
000008F0 0187A000
0121 00000910 920E move a0, *a14+, 1 ; arg4 = &from
0122 00000920 09E0 movi 0, a0, L
00000930 00000000
0123 00000950 920E move a0, *a14+, 1 ; arg3 = flags
0124 00000960 09E0 movi 00800h, a0, L
00000970 00000800
0125 00000990 920E move a0, *a14+, 1 ; arg2 = 2048
GSP COFF Assembler, Version 2.00, 87.300 Sun Oct 18 17:26:10 2026
(c) Copyright 1985, 1987, Texas Instruments Inc.
PAGE 4
0126 000009A0 09E0 movi 01876000h, a0, L
000009B0 01876000
0127 000009D0 920E move a0, *a14+, 1 ; arg1 = receive buffer
0128 000009E0 932E move a9, *a14+, 1 ; arg0 = fd
0129 000009F0 0D5F calla 3F5D7D50h
00000A00 3F5D7D50
0130 00000A20 07AF move @0187C200h, sp, 1
00000A30 0187C200
0131 00000A50 07AE move @0187C220h, a14, 1
00000A60 0187C220
0132 00000A80 0550 setf 16, 0, 0
0133 00000A90 0740 setf 32, 0, 1
0134
0135 00000AA0 0788 move a8, @0187C080h, 1 ; last length
00000AB0 0187C080
0136 00000AD0 4D08 move a8, a8
0137 00000AE0 C600 jrle fail
00000AF0 0089
0138
0139 ; opcode: wire 00 03 -> little-endian word 0300h
0140 00000B00 05A0 move @01876000h, a0, 0
00000B10 01876000
0141 00000B30 0B40 cmpi 0300h, a0
00000B40 FCFF
0142 00000B50 CB00 jrne fail ; only DATA is accepted
00000B60 0082
0143
0144 00000B70 05A4 move @01876010h, a4, 0 ; block number, wire order
00000B80 01876010
0145 00000BA0 0784 move a4, @0187C0A0h, 1
00000BB0 0187C0A0
0146
0147 00000BD0 4D03 move a8, a3
0148 00000BE0 1483 subk 4, a3 ; payload length
0149
0150 ; ---- total += payload, dest += payload -------------
0151 00000BF0 07A1 move @0187C060h, a1, 1
00000C00 0187C060
0152 00000C20 4061 add a3, a1
0153 00000C30 0781 move a1, @0187C060h, 1 ; total += payload (bytes)
00000C40 0187C060
0154 00000C60 4D66 move a11, a6 ; copy destination
0155 00000C70 4C62 move a3, a2
0156 00000C80 2462 sll 3, a2 ; bytes -> bits: pointers are bit addresse
0157 00000C90 404B add a2, a11 ; dest cursor advances now (do NOT add by
0158
0159 ; ---- copy payload from BUF+4 to a6, one byte at a ti
0160 ; Interrupts are disabled for the copy so a 512-byte c
0161 ; with respect to the firmware's ISRs.
0162 00000CA0 0360 dint
0163 00000CB0 09E5 movi 01876020h, a5, L
00000CC0 01876020
0164 00000CE0 4C62 move a3, a2
0165 00000CF0 0783 move a3, @0187C0E0h, 1 ; payload length
00000D00 0187C0E0
0166 00000D20 0782 move a2, @0187C140h, 1 ; copy count
GSP COFF Assembler, Version 2.00, 87.300 Sun Oct 18 17:26:10 2026
(c) Copyright 1985, 1987, Texas Instruments Inc.
PAGE 5
00000D30 0187C140
0167 00000D50 0786 move a6, @0187C120h, 1 ; write start
00000D60 0187C120
0168 00000D80 078B move a11, @0187C100h, 1 ; cursor after advance
00000D90 0187C100
0169 00000DB0 0785 move a5, @0187C160h, 1 ; source
00000DC0 0187C160
0170 00000DE0 CA05 jreq copy_done
0171 00000DF0 copy_bytes:
0172 00000DF0 8EA0 movb *a5, a0
0173 00000E00 8C06 movb a0, *a6
0174 00000E10 1105 addk 8, a5 ; one byte
0175 00000E20 1106 addk 8, a6
0176 00000E30 3CA2 dsjs a2, copy_bytes
0177 00000E40 copy_done:
0178 00000E40 0D60 eint
0179
0180 ; ---- ACK: 00 04 <block as received> ----------------
0181 00000E50 09E0 movi 00400h, a0, L
00000E60 00000400
0182 00000E80 0580 move a0, @0187A100h, 0
00000E90 0187A100
0183 00000EB0 0584 move a4, @0187A110h, 0
00000EC0 0187A110
0184
0185 00000EE0 09EE movi 01875000h, a14, L
00000EF0 01875000
0186 00000F10 09E0 movi 16, a0, L
00000F20 00000010
0187 00000F40 920E move a0, *a14+, 1
0188 00000F50 09E0 movi 0187A000h, a0, L
00000F60 0187A000
0189 00000F80 920E move a0, *a14+, 1
0190 00000F90 09E0 movi 0, a0, L
00000FA0 00000000
0191 00000FC0 920E move a0, *a14+, 1
0192 00000FD0 09E0 movi 4, a0, L
00000FE0 00000004
0193 00001000 920E move a0, *a14+, 1
0194 00001010 09E0 movi 0187A100h, a0, L
00001020 0187A100
0195 00001040 920E move a0, *a14+, 1
0196 00001050 932E move a9, *a14+, 1
0197 00001060 0D5F calla 3F5D3D70h
00001070 3F5D3D70
0198 00001090 07AF move @0187C200h, sp, 1
000010A0 0187C200
0199 000010C0 07AE move @0187C220h, a14, 1
000010D0 0187C220
0200 000010F0 0550 setf 16, 0, 0
0201 00001100 0740 setf 32, 0, 1
0202 00001110 4D08 move a8, a8
0203 00001120 C426 jrlt fail
0204
0205 ; short block ends the transfer; full block means read
0206 00001130 07A2 move @0187C080h, a2, 1
GSP COFF Assembler, Version 2.00, 87.300 Sun Oct 18 17:26:10 2026
(c) Copyright 1985, 1987, Texas Instruments Inc.
PAGE 6
00001140 0187C080
0207 00001160 1482 subk 4, a2
0208 00001170 0B42 cmpi 512, a2
00001180 FDFF
0209 00001190 C402 jrlt close_it
0210 000011A0 C000 jruc recv_loop
000011B0 FF65
0211
0212 000011C0 close_it:
0213 000011C0 09E0 movi 4, a0, L
000011D0 00000004
0214 000011F0 0780 move a0, @0187C000h, 1
00001200 0187C000
0215 00001220 09EE movi 01875000h, a14, L
00001230 01875000
0216 00001250 932E move a9, *a14+, 1
0217 00001260 0D5F calla 3F5E8930h ; close(fd)
00001270 3F5E8930
0218 00001290 07AF move @0187C200h, sp, 1
000012A0 0187C200
0219 000012C0 07AE move @0187C220h, a14, 1
000012D0 0187C220
0220 000012F0 0550 setf 16, 0, 0
0221 00001300 0740 setf 32, 0, 1
0222 00001310 09E0 movi 05A5A5A5h, a0, L
00001320 05A5A5A5
0223 00001340 0780 move a0, @0187C0C0h, 1
00001350 0187C0C0
0224 00001370 4508 sub a8, a8
0225 00001380 C009 jruc epilogue
0226
0227 00001390 fail:
0228 00001390 09E0 movi 0FFh, a0, L
000013A0 000000FF
0229 000013C0 0780 move a0, @0187C000h, 1
000013D0 0187C000
0230 000013F0 09E8 movi 0FFFFFFFFh, a8, L
00001400 FFFFFFFF
0231 00001420 epilogue:
0232 00001420 09AF mmfm sp, a0,a1,a2,a3,a4,a5,a6,a7
00001430 00FF
0233 00001440 0960 rets
0234
0235 00001450 RRQ:
0236 00001450 0100 .word 00100h ; opcode 1 (00 01)
0237 00001460 7478 .word 07478h ; "xt"
0238 00001470 7865 .word 07865h ; "ex"
0239 00001480 2E74 .word 02E74h ; "t."
0240 00001490 6F63 .word 06F63h ; "co"
0241 000014A0 6666 .word 06666h ; "ff"
0242 000014B0 6F00 .word 06F00h ; "\0o" (NUL ends the name, mode starts
0243 000014C0 7463 .word 07463h ; "ct"
0244 000014D0 7465 .word 07465h ; "et"
0245 000014E0 0000 .word 00000h ; "\0" + pad
0246 000014F0 SADDR:
0247 000014F0 0002 .word 00002h ; sin_family = AF_INET
GSP COFF Assembler, Version 2.00, 87.300 Sun Oct 18 17:26:10 2026
(c) Copyright 1985, 1987, Texas Instruments Inc.
PAGE 7
0248 00001500 4500 .word 04500h ; sin_port = htons(69)
0249 00001510 6764 .word 06764h ; 100.103
0250 00001520 FEFF .word 0FEFFh ; .255.254
0251 00001530 0000 .word 0
0252 00001540 0000 .word 0
0253 00001550 0000 .word 0
0254 00001560 0000 .word 0
0255 .end
No Errors, No Warnings