mirror of
https://github.com/cc65/cc65.git
synced 2024-10-03 12:55:56 +00:00
Use .assert
git-svn-id: svn://svn.cc65.org/cc65/trunk@3478 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
f3ac2be07d
commit
9bd3aba923
@ -17,16 +17,12 @@ getfd:
|
|||||||
cmp #MAX_FDS
|
cmp #MAX_FDS
|
||||||
bcs error
|
bcs error
|
||||||
|
|
||||||
.if .sizeof(FD) = 4
|
|
||||||
|
|
||||||
; Convert handle to fdtab slot
|
; Convert handle to fdtab slot
|
||||||
|
.assert .sizeof(FD) = 4, error
|
||||||
asl
|
asl
|
||||||
asl
|
asl
|
||||||
|
|
||||||
.else
|
|
||||||
.error "Assertion failed"
|
|
||||||
.endif
|
|
||||||
|
|
||||||
; Check for fdtab slot in use
|
; Check for fdtab slot in use
|
||||||
tay
|
tay
|
||||||
lda fdtab + FD::REF_NUM,y
|
lda fdtab + FD::REF_NUM,y
|
||||||
@ -43,7 +39,7 @@ error: lda #EINVAL
|
|||||||
|
|
||||||
.data
|
.data
|
||||||
|
|
||||||
fdtab: .if .sizeof(FD) = 4
|
fdtab: .assert .sizeof(FD) = 4, error
|
||||||
|
|
||||||
.byte $80 ; STDIN_FILENO ::REF_NUM
|
.byte $80 ; STDIN_FILENO ::REF_NUM
|
||||||
.byte O_RDONLY ; STDIN_FILENO ::FLAGS
|
.byte O_RDONLY ; STDIN_FILENO ::FLAGS
|
||||||
@ -57,8 +53,4 @@ fdtab: .if .sizeof(FD) = 4
|
|||||||
.byte O_WRONLY ; STDERR_FILENO::FLAGS
|
.byte O_WRONLY ; STDERR_FILENO::FLAGS
|
||||||
.addr $0000 ; STDERR_FILENO::BUFFER
|
.addr $0000 ; STDERR_FILENO::BUFFER
|
||||||
|
|
||||||
.else
|
|
||||||
.error "Assertion failed"
|
|
||||||
.endif
|
|
||||||
|
|
||||||
.res (MAX_FDS - 3) * .sizeof(FD)
|
.res (MAX_FDS - 3) * .sizeof(FD)
|
||||||
|
@ -37,18 +37,13 @@ _open:
|
|||||||
: lda fdtab + FD::REF_NUM,y
|
: lda fdtab + FD::REF_NUM,y
|
||||||
beq found
|
beq found
|
||||||
|
|
||||||
.if .sizeof(FD) = 4
|
|
||||||
|
|
||||||
; Advance to next fdtab slot
|
; Advance to next fdtab slot
|
||||||
|
.assert .sizeof(FD) = 4, error
|
||||||
iny
|
iny
|
||||||
iny
|
iny
|
||||||
iny
|
iny
|
||||||
iny
|
iny
|
||||||
|
|
||||||
.else
|
|
||||||
.error "Assertion failed"
|
|
||||||
.endif
|
|
||||||
|
|
||||||
; Check for end of fdtab
|
; Check for end of fdtab
|
||||||
cpy #MAX_FDS * .sizeof(FD)
|
cpy #MAX_FDS * .sizeof(FD)
|
||||||
bcc :-
|
bcc :-
|
||||||
@ -107,13 +102,8 @@ found: tya
|
|||||||
and #O_CREAT
|
and #O_CREAT
|
||||||
beq open
|
beq open
|
||||||
|
|
||||||
.if MLI::CREATE::PATHNAME = MLI::OPEN::PATHNAME
|
|
||||||
|
|
||||||
; PATHNAME already set
|
; PATHNAME already set
|
||||||
|
.assert MLI::CREATE::PATHNAME = MLI::OPEN::PATHNAME, error
|
||||||
.else
|
|
||||||
.error "Assertion failed"
|
|
||||||
.endif
|
|
||||||
|
|
||||||
; Set all other parameters from template
|
; Set all other parameters from template
|
||||||
ldx #(MLI::CREATE::CREATE_TIME+1) - (MLI::CREATE::PATHNAME+1) - 1
|
ldx #(MLI::CREATE::CREATE_TIME+1) - (MLI::CREATE::PATHNAME+1) - 1
|
||||||
@ -200,17 +190,12 @@ open: ldy tmp2 ; Restore fdtab slot
|
|||||||
done: lda tmp1 ; Restore fd
|
done: lda tmp1 ; Restore fd
|
||||||
sta fdtab + FD::REF_NUM,y
|
sta fdtab + FD::REF_NUM,y
|
||||||
|
|
||||||
.if .sizeof(FD) = 4
|
|
||||||
|
|
||||||
; Convert fdtab slot to handle
|
; Convert fdtab slot to handle
|
||||||
|
.assert .sizeof(FD) = 4, error
|
||||||
tya
|
tya
|
||||||
lsr
|
lsr
|
||||||
lsr
|
lsr
|
||||||
|
|
||||||
.else
|
|
||||||
.error "Assertion failed"
|
|
||||||
.endif
|
|
||||||
|
|
||||||
; Cleanup name
|
; Cleanup name
|
||||||
jsr popname ; Preserves A
|
jsr popname ; Preserves A
|
||||||
|
|
||||||
|
@ -44,21 +44,13 @@ _write:
|
|||||||
jsr callmli
|
jsr callmli
|
||||||
bcs oserr
|
bcs oserr
|
||||||
|
|
||||||
.if MLI::MARK::REF_NUM = MLI::EOF::REF_NUM
|
|
||||||
|
|
||||||
; REF_NUM already set
|
; REF_NUM already set
|
||||||
|
.assert MLI::MARK::REF_NUM = MLI::EOF::REF_NUM, error
|
||||||
|
|
||||||
.else
|
|
||||||
.error "Assertion failed"
|
|
||||||
.endif
|
|
||||||
|
|
||||||
.if MLI::MARK::POSITION = MLI::EOF::EOF
|
|
||||||
|
|
||||||
; POSITION already set
|
; POSITION already set
|
||||||
|
.assert MLI::MARK::POSITION = MLI::EOF::EOF, error
|
||||||
.else
|
|
||||||
.error "Assertion failed"
|
|
||||||
.endif
|
|
||||||
|
|
||||||
; Set file pointer
|
; Set file pointer
|
||||||
lda #SET_MARK_CALL
|
lda #SET_MARK_CALL
|
||||||
@ -121,3 +113,4 @@ errno: jmp errnoexit
|
|||||||
|
|
||||||
; Return oserror
|
; Return oserror
|
||||||
oserr: jmp oserrexit
|
oserr: jmp oserrexit
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user