Compare commits

..

No commits in common. "main" and "1.1.4" have entirely different histories.
main ... 1.1.4

10 changed files with 180 additions and 39 deletions

1
.gitignore vendored
View File

@ -17,4 +17,3 @@ src/BSDSocket_Size.s
src/bsdsocket_lib.fd src/bsdsocket_lib.fd
src/bsdsocket_lvo.i src/bsdsocket_lvo.i
src/*.Lib src/*.Lib
libs/

Binary file not shown.

View File

@ -153,16 +153,6 @@ Doing something cool with the extension?
timeouts using `Socket Async Wait Writing` to determine if the Internet timeouts using `Socket Async Wait Writing` to determine if the Internet
is available. is available.
## Slot 18 taken already?
I'm also building releases for slots 9, 11, and 17. They're available for
separate download from each Release version 1.1.4 and on.
Note that you won't be able to load the test AMOS programs, or any other
progaam using the Slot 18 version, because AMOS uses the extension's slot
number in the saved tile. You'll have to export and import ASCII versions
of programs.
## Versioning ## Versioning
This project uses semantic versioning. This project uses semantic versioning.

View File

@ -24,22 +24,6 @@ source.lines.each do |line|
end end
end end
FileUtils.cp 'src/AMOSPro_BSDSocket.Lib', 'AMOSPro_BSDSocket.Lib'
strings = []
Open3.popen2e('strings', 'AMOSPro_BSDSocket.Lib') do |stdin, stdout_and_stderr, wait_thr|
stdin.close
stdout_and_stderr.each { |l| strings << l }
wait_thr.join
end
unless strings.any? { |s| s[version] }
puts "Extension build doesn't match source version! Did you rebuild it yet on the Amiga?"
exit 1
end
FileUtils.mkdir_p 'dist' FileUtils.mkdir_p 'dist'
build_base = 'build' build_base = 'build'
@ -51,6 +35,8 @@ FileUtils.rm_rf 'aminet'
FileUtils.mkdir_p build_dir FileUtils.mkdir_p build_dir
FileUtils.mkdir_p 'aminet' FileUtils.mkdir_p 'aminet'
FileUtils.cp 'src/AMOSPro_BSDSocket.Lib', 'AMOSPro_BSDSocket.Lib'
hackerbun_target = File.expand_path("dist/AMOSPro_BSDSocket_#{version}.lha") hackerbun_target = File.expand_path("dist/AMOSPro_BSDSocket_#{version}.lha")
[ [

42
src/AMOSMacros.s Normal file
View File

@ -0,0 +1,42 @@
; get the effective address of something in extension memory
Dlea MACRO
MOVE.L ExtAdr+ExtNb*16(A5),\2
ADD.W #\1-MB,\2
ENDM
; load the base of extension memory into a register
Dload MACRO
MOVE.L ExtAdr+ExtNb*16(A5),\1
ENDM
; wrap code that doesn't take arguments with these
PreserveStackInstruction MACRO
MOVEM.L A2-A6/D6-D7,-(SP)
ENDM
RestoreStackInstruction MACRO
MOVEM.L (SP)+,A2-A6/D6-D7
ENDM
; wrap code that takes arguments with these
PreserveStackFunction MACRO
MOVEM.L A2/A4-A6/D6-D7,-(SP)
ENDM
RestoreStackFunction MACRO
MOVEM.L (SP)+,A2/A4-A6/D6-D7
ENDM
; Push and pop the extension's data storage into A3
WithDataStorageToA3 MACRO
MOVE.L A3,-(SP)
Dload A3
ENDM
EndDataStorage MACRO
MOVE.L (SP)+,A3
ENDM
EvenOutStringAddress MACRO
MOVE.W \1,\2
AND.W #$0001,\2
ADD.W \2,\1
ENDM

View File

@ -5,10 +5,9 @@
; Writing this code the right way, 25 years later. ; Writing this code the right way, 25 years later.
; extension number 18 ; extension number 18
; this now comes from GenAm command line option ExtNb equ 18-1
;ExtNb equ 18-1
Version MACRO Version MACRO
dc.b "1.1.4-20240502" dc.b "1.1.4-20240426"
ENDM ENDM
VerNumber equ $1 VerNumber equ $1

43
src/Constants.s Normal file
View File

@ -0,0 +1,43 @@
; bsdsocket library stuff
; ported from the various C include headers
SOCK_STREAM EQU 1
PF_INET EQU 2
AF_INET EQU PF_INET
IPPROTO_TCP EQU 6
INADDR_ANY EQU 0
FIONBIO EQU $8004667E
FIONASYNC EQU $8004667D
SOL_SOCKET EQU $FFFF
SO_REUSEADDR EQU $4
MAX_SOCKETS EQU 64
len_sockaddr_in EQU 16
sockaddr_in_sin_len EQU 0
sockaddr_in_sin_family EQU 1
sockaddr_in_sin_port EQU 2
sockaddr_in_sin_addr EQU 4
; global errors
Error_OtherError EQU -1
Error_LibraryNotOpen EQU -2
Error_PortOutOfRange EQU -11
Error_FdsetOutOfRange EQU -11
Error_UnableToBind EQU -12
; socket herrno and tag lists
; built from:
; * https://wiki.amigaos.net/amiga/autodocs/bsdsocket.doc.txt
; * https://github.com/deplinenoise/amiga-sdk/blob/master/netinclude/amitcp/socketbasetags.h
; * http://amigadev.elowar.com/read/ADCD_2.1/Includes_and_Autodocs_2._guide/node012E.html
TAG_USER EQU (1<<31)
SBTF_REF EQU $8000
SBTB_CODE EQU 1
SBTS_CODE EQU $3FFF
SBTC_HERRNO EQU 6
HerrnoTag EQU (TAG_USER|SBTF_REF|((SBTC_HERRNO&SBTS_CODE)<<SBTB_CODE))

43
src/LongDivide.s Normal file
View File

@ -0,0 +1,43 @@
; d0 = value to be divided
; d1 = divisor
; returns:
; d0 = divided value
; d1 = remainder
LongDivideD0ByD1 MACRO
CMP.L D0,D1
BMI _LongDivide_StartDivide\@
MOVE.L D0,D1
MOVEQ #0,D0
BRA _LongDivide_Skip\@
_LongDivide_StartDivide\@:
MOVEM.L D2-D4,-(SP)
MOVEQ #0,D2 ; remainder
MOVE.L #31,D3 ; bit tracking
; d4 tracks the status register
_LongDivide_ContinueDivide\@:
ASL.L #1,D0
SCS D4 ; bit that got rolled out
AND.L #1,D4
ROL.L #1,D2
ADD.L D4,D2 ; roll the value onto the remainder
MOVE.L D2,D4
SUB.L D1,D4
BMI _LongDivide_NotDivisible\@
ADDQ #1,D0
MOVE.L D4,D2
_LongDivide_NotDivisible\@:
DBRA D3,_LongDivide_ContinueDivide\@
MOVE.L D2,D1
MOVEM.L (SP)+,D2-D4
_LongDivide_Skip\@:
ENDM

View File

@ -2,7 +2,7 @@ echo "***Assembling AMOSPro_BSDSocket.Lib"
assign AMOSPro_System: SYS:Development/AMOS_Pro assign AMOSPro_System: SYS:Development/AMOS_Pro
assign AMOSPro_Sources: amos-pro-bsdsocket-extension:stuff/AMOS-Professional-Official assign AMOSPro_Sources: amos-pro-bsdsocket-extension:stuff/AMOS-Professional-Official
AMOSPro_Sources:c/Library_Digest BSDSocket.s AMOSPro_Sources:c/Library_Digest BSDSocket.s
AMOSPro_Sources:c/Genam FROM BSDSocket.s TO AMOSPro_BSDSocket.Lib -e ExtNb=18-1 AMOSPro_Sources:c/Genam FROM BSDSocket.s TO AMOSPro_BSDSocket.Lib
;delete >NIL: BSDSocket_Labels.s ;delete >NIL: BSDSocket_Labels.s
;delete >NIL: BSDSocket_Size.s ;delete >NIL: BSDSocket_Size.s
FAILAT 21 FAILAT 21
@ -10,11 +10,3 @@ copy AMOSPro_System:APSystem/AMOSPro_BSDSocket.lib AMOSPro_System:APSystem/AMOSP
FAILAT 10 FAILAT 10
copy AMOSPro_BSDSocket.Lib AMOSPro_System:APSystem/ copy AMOSPro_BSDSocket.Lib AMOSPro_System:APSystem/
apcmp "/test/TestSuite.amos" inclib apcmp "/test/TestSuite.amos" inclib
echo "Build for slot 9"
AMOSPro_Sources:c/Genam FROM BSDSocket.s TO AMOSPro_BSDSocket_Slot9.Lib -e ExtNb=9-1
echo "Build for slot 11"
AMOSPro_Sources:c/Genam FROM BSDSocket.s TO AMOSPro_BSDSocket_Slot11.Lib -e ExtNb=11-1
echo "Build for slot 17"
AMOSPro_Sources:c/Genam FROM BSDSocket.s TO AMOSPro_BSDSocket_Slot17.Lib -e ExtNb=17-1

47
src/fd_set.s Normal file
View File

@ -0,0 +1,47 @@
; fdset macros
EnsureValidFdset MACRO
CMP.L #MaxFd_sets,\1
BLT \2
MOVE.L #Error_FdsetOutOfRange,D3
RestoreStackFunction
Ret_Int
ENDM
EnsureValidFdsetBit MACRO
CMP.L #64,\1
BGE _EnsureValidFdsetBit_Fail\@
BRA \2
_EnsureValidFdsetBit_Fail\@:
MOVE.L \3,D3
RestoreStackFunction
Ret_Int
ENDM
; LeaFdset fd_set reg,target
LeaFdset MACRO
MOVE.L \1,-(SP)
Dlea fd_sets,\2 ; base of all, these are longs
ROL.L #3,\1 ; multiply by 8
ADD.L \1,\2 ; add to base of all
MOVE.L (SP)+,\1
ENDM
; LeaFdsetForBit fd_set reg,target address,target bit in address
LeaFdsetForBit MACRO
LeaFdset \1,\2 ; get fdset base address in \2
MOVE.L D3,-(SP)
MOVE.L \3,D3 ; Put target bit into D3
ROR.L #5,D3 ; lop off the first 5 bits
AND.L #$7,D3 ; only keep the top three
ROL.L #2,D3 ; multiply by 4
ADD.L D3,\2 ; add that value to the fdset address
AND.L #$1F,\3 ; only keep 0-31 in \3
MOVEQ #1,D3
ROL.L \3,D3 ; shift that bit left as many as target
MOVE.L D3,\3 ; put that in the target
MOVE.L (SP)+,D3
ENDM