Subversion Repositories Spectranet

[/] [branches/] [gnubinutils/] [rom/] [w5100_genintfunc.asm] - Blame information for rev 384

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 25 winston
;The MIT License
2
;
3
;Copyright (c) 2008 Dylan Smith
4
;
5
;Permission is hereby granted, free of charge, to any person obtaining a copy
6
;of this software and associated documentation files (the "Software"), to deal
7
;in the Software without restriction, including without limitation the rights
8
;to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
;copies of the Software, and to permit persons to whom the Software is
10
;furnished to do so, subject to the following conditions:
11
;
12
;The above copyright notice and this permission notice shall be included in
13
;all copies or substantial portions of the Software.
14
;
15
;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
;AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
;LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
;OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
;THE SOFTWARE.
22
;
23
;
24
; General internal functions for the socket library.
25
;
26 384 winston
.include        "w5100_defs.inc"
27
.include        "sysvars.inc"
28
.include        "sockdefs.inc"
29 25 winston
;
30
; F_gethwsock:
31
; Get the hardware socket for a file descriptor. If no hardware socket
32
; is associated with the fd, set the carry flag and return with the error
33
; code in A. Otherwise, return the hardware socket register area MSB in
34
; H.
35 384 winston
.text
36
.globl F_gethwsock
37
F_gethwsock:
38 25 winston
        ex af, af'
39 142 winston
        ld a, (v_pga)           ; save current page A
40
        ld (v_buf_pga), a
41 110 winston
        ld a, REGPAGE
42 25 winston
        call F_setpageA
43
        ex af, af'
44
        ld h, v_fd1hwsock / 256 ; set (hl) to point at the fd map
45
        ld l, a
46
        ld a, (hl)
47
        ld h, a                 ; point hl at putative hardware socket
48
        and NOTSOCKMASK         ; is this not a hardware socket?
49 27 winston
        ret z                   ; OK - return with hw sock register in H
50 384 winston
.nohwsock1:
51 267 winston
        ld a, ESBADF
52 25 winston
        scf
53
        ret
54 142 winston
 
55
;----------------------------------------------------------------------------
56
; J_leavesockfn - jump point to restore original page A
57 384 winston
.globl J_leavesockfn
58
J_leavesockfn:
59 142 winston
        ex af, af'
60
        ld a, (v_buf_pga)
61
        call F_setpageA
62
        ex af, af'
63
        ret