Replaced custom zeropage variables with cc65 default zeropage variables.

This commit is contained in:
Oliver Schmidt 2014-07-07 20:56:21 +02:00
parent e06c02e4a3
commit 2ae35b34d9
23 changed files with 108 additions and 226 deletions

View File

@ -20,7 +20,6 @@ all: $(DRIVERS)
C64OBJS=\
contiki.o \
c64zeropage.o \
c64print.o \
c64timer.o \
c64kernal.o \
@ -29,7 +28,6 @@ C64OBJS=\
A2OBJS=\
contiki.o \
a2zeropage.o \
a2print.o \
a2timer.o \
a2kernal.o \
@ -38,7 +36,6 @@ A2OBJS=\
VIC20OBJS=\
contiki.o \
vic20zeropage.o \
vic20print.o \
vic20timer.o \
vic20kernal.o \

View File

@ -12,11 +12,10 @@
.import print_a
.import print_hex
.importzp copy_src
.include "zeropage.inc"
.include "../inc/common.i"
allowed_ptr = copy_src ; reuse zero page
allowed_ptr = ptr1
.code

View File

@ -1,36 +0,0 @@
; zero page definitions
.exportzp copy_src
.exportzp copy_dest
.exportzp dns_hostname
.exportzp tftp_filename
.exportzp buffer_ptr
.exportzp eth_packet
copy_src = $06 ; also $07 - source pointer
copy_dest = $08 ; also $09 - destination pointer
dns_hostname = $18 ; also $19
tftp_filename = $1D ; also $1E - name of file to d/l or filemask to get directory listing for
buffer_ptr = $EB ; also $EC - source pointer
eth_packet = $ED ; also $EE
; -- LICENSE --
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
; The Original Code is ip65.
;
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2013
; Jonno Downes. All Rights Reserved.
; -- LICENSE END --

View File

@ -8,17 +8,17 @@
.export check_for_abort_key
.export get_key_if_available
.export get_key_ip65
.importzp copy_src
.import ip65_process
.include "zeropage.inc"
.include "../inc/common.i"
allowed_ptr = ptr1
.code
allowed_ptr = copy_src ; reuse zero page
; use C64 Kernel ROM function to read a key
; inputs: none
; outputs: A contains ASCII value of key just pressed

View File

@ -1,36 +0,0 @@
; zero page definitions
.exportzp copy_src
.exportzp copy_dest
.exportzp dns_hostname
.exportzp tftp_filename
.exportzp buffer_ptr
.exportzp eth_packet
copy_src = $5F ; also $60 - source pointer
copy_dest = $61 ; also $62 - destination pointer
dns_hostname = $63 ; also $64
tftp_filename = $65 ; also $66 - name of file to d/l or filemask to get directory listing for
buffer_ptr = $67 ; also $68 - source pointer
eth_packet = $69 ; also $6A
; -- LICENSE --
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
; The Original Code is ip65.
;
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2013
; Jonno Downes. All Rights Reserved.
; -- LICENSE END --

View File

@ -8,17 +8,17 @@
.export check_for_abort_key
.export get_key_if_available
.export get_key_ip65
.importzp copy_src
.import ip65_process
.include "zeropage.inc"
.include "../inc/common.i"
allowed_ptr = ptr1
.code
allowed_ptr = copy_src ; reuse zero page
; use Vic 20 Kernel ROM function to read a key
; inputs: none
; outputs: A contains ASCII value of key just pressed

View File

@ -1,36 +0,0 @@
; zero page definitions
.exportzp copy_src
.exportzp copy_dest
.exportzp dns_hostname
.exportzp tftp_filename
.exportzp buffer_ptr
.exportzp eth_packet
copy_src = $5F ; also $60 - source pointer
copy_dest = $61 ; also $62 - destination pointer
dns_hostname = $63 ; also $64
tftp_filename = $65 ; also $66 - name of file to d/l or filemask to get directory listing for
buffer_ptr = $67 ; also $68 - source pointer
eth_packet = $69 ; also $6A
; -- LICENSE --
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
; The Original Code is ip65.
;
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2013
; Jonno Downes. All Rights Reserved.
; -- LICENSE END --

View File

@ -4,6 +4,7 @@
.ifndef KPR_API_VERSION_NUMBER
.define EQU =
.include "zeropage.inc"
.include "../inc/kipper_constants.i"
.endif
@ -34,8 +35,7 @@
.importzp copy_src
.import cfg_tftp_server
; reuse the copy_src zero page var
pptr = copy_src
pptr = ptr1
.bss

View File

@ -1,15 +1,8 @@
; helper routines for arithmetic on 32 bit numbers
.include "zeropage.inc"
.include "../inc/common.i"
; reuse the copy_* zero page locations as pointers for 32bit addition
.importzp copy_src
.importzp copy_dest
acc32 = copy_src ; 32bit accumulater (pointer)
op32 = copy_dest ; 32 bit operand (pointer)
acc16 = acc32 ; 16bit accumulater (value, NOT pointer)
.bss
@ -19,9 +12,9 @@ temp_ax: .res 2
.code
; no 16bit operand as can just use AX
.exportzp acc32
.exportzp op32
.exportzp acc16
.exportzp acc32 = ptr1 ; 32bit accumulater (pointer)
.exportzp op32 = ptr2 ; 32 bit operand (pointer)
.exportzp acc16 = acc32 ; 16bit accumulater (value, NOT pointer)
.export add_32_32
.export add_16_32

View File

@ -1,5 +1,6 @@
; ARP address resolution
.include "zeropage.inc"
.include "../inc/common.i"
.export arp_init
@ -30,9 +31,7 @@
.import timer_read
.import timer_timeout
.importzp copy_src
ap = copy_src
ap = ptr1
ARP_TIMEOUT_MS = 100

View File

@ -3,6 +3,7 @@
;
; refs: RFC1001, RFC1002, "Implementing CIFS" - http://ubiqx.org/cifs/
.include "zeropage.inc"
.include "../inc/common.i"
.ifndef KPR_API_VERSION_NUMBER
@ -69,7 +70,7 @@ nbns_registration_message_length = 68
; outputs:
; AX: pointer to decoded hostname
cifs_l1_encode:
stax copy_src
stax ptr1
lda #0
tax
sta hostname_buffer+32
@ -85,7 +86,7 @@ cifs_l1_encode:
ldy #0
ldx #0
@copy_loop:
lda (copy_src),y
lda (ptr1),y
beq @done
lsr
lsr
@ -95,7 +96,7 @@ cifs_l1_encode:
adc #$41
sta hostname_buffer,x
inx
lda (copy_src),y
lda (ptr1),y
and #$0F
clc
adc #$41
@ -115,11 +116,11 @@ cifs_l1_encode:
; outputs:
; AX: pointer to decoded hostname (will be 16 byte hostname, right padded with spaces, nul terminated)
cifs_l1_decode:
stax copy_src
stax ptr1
ldy #0
ldx #0
@decode_loop:
lda (copy_src),y
lda (ptr1),y
sec
sbc #$41
asl
@ -128,7 +129,7 @@ cifs_l1_decode:
asl
sta hi_nibble
iny
lda (copy_src),y
lda (ptr1),y
sec
sbc #$41
clc
@ -306,10 +307,10 @@ nbns_callback:
@not_unicast:
; is it looking for our local hostname?
ldax #udp_inp+udp_data+nbns_question_name+1
stax copy_src
stax ptr1
ldy #0
@cmp_loop:
lda (copy_src),y
lda (ptr1),y
cmp local_hostname,y
bne @not_us
iny
@ -396,19 +397,19 @@ nb_session_callback:
; have we got a complete message?
ldax cifs_cmd_buffer
stax copy_src
stax ptr1
ldy #3
lda (copy_src),y
lda (ptr1),y
cmp cifs_cmd_length
bne @not_got_full_message
dey
lda (copy_src),y
lda (ptr1),y
cmp cifs_cmd_length+1
bne @not_got_full_message
; we have a complete message!
ldy #0
lda (copy_src),y ; get the message type
lda (ptr1),y ; get the message type
cmp #$81 ; is it a session request?
bne @not_session_request
ldax #positive_session_response_packet_length
@ -423,11 +424,11 @@ nb_session_callback:
; this SHOULD be a SMB - best check the header
ldy #4
lda (copy_src),y ; get the message data
lda (ptr1),y ; get the message data
cmp #$FF ; start of SMB header
bne @not_smb
iny
lda (copy_src),y ; get the message data
lda (ptr1),y ; get the message data
cmp #'S' ; start of SMB header
bne @not_smb
@ -453,17 +454,17 @@ nb_session_callback:
rts
smb_handler:
; at this point, copy_src points to an SMB block encapsulated in an NBT session header
; at this point, ptr1 points to an SMB block encapsulated in an NBT session header
clc
lda copy_src
lda ptr1
adc #4
sta smb_ptr ; skip past the NBT header
lda copy_src+1
lda ptr1+1
adc #00
sta smb_ptr+1
ldy #8
lda (copy_src),y ; get the SMB type
lda (ptr1),y ; get the SMB type
cmp #$72
bne @not_negotiate_protocol
jmp @negotiate_protocol
@ -484,7 +485,7 @@ smb_handler:
@parse_andx_block:
ldax andx_ptr
stax copy_src
stax ptr1
lda andx_opcode
cmp #$ff
@ -513,16 +514,16 @@ smb_handler:
@go_to_next_andx_block:
ldy #3
lda (copy_src),y ; get the AndX offset low byte
lda (ptr1),y ; get the AndX offset low byte
clc
adc smb_ptr
sta andx_ptr
iny
lda (copy_src),y ; get the AndX offset high byte
lda (ptr1),y ; get the AndX offset high byte
adc smb_ptr+1
sta andx_ptr+1
ldy #1
lda (copy_src),y ; get the subsequent AndX opcode
lda (ptr1),y ; get the subsequent AndX opcode
sta andx_opcode
jmp @parse_andx_block
@ -539,7 +540,7 @@ smb_handler:
; copy the request TID,PID,UID,MID into the response
ldy #28 ; offset of TID from start of message
ldx #0
: lda (copy_src),y
: lda (ptr1),y
sta negotiate_protocol_response_tid,x
inx
iny
@ -552,10 +553,10 @@ smb_handler:
clc
lda cifs_cmd_buffer
adc #$26
sta copy_src
sta ptr1
lda cifs_cmd_buffer+1
adc #$00
sta copy_src+1
sta ptr1+1
ldy #$0
@dialect_scan_loop:
@ -564,7 +565,7 @@ smb_handler:
lda dialect_index
cmp #$10 ; if we've scanned more than $10 dialects, something is wrong
beq @end_of_dialects
lda (copy_src),y
lda (ptr1),y
cmp #$02
bne @test_dialect
inc dialect_index
@ -572,14 +573,14 @@ smb_handler:
@test_dialect:
tya
clc
adc copy_src
sta copy_src
adc ptr1
sta ptr1
bcc :+
inc copy_src+1
inc ptr1+1
: ldy #0
@test_dialect_loop:
lda (copy_src),y
lda (ptr1),y
cmp preferred_dialect_id,y
bne @dialect_scan_loop
iny
@ -601,11 +602,11 @@ smb_handler:
start_smb_response:
ldax smb_response_buffer
stax copy_dest
stax ptr2
ldy #0
@copy_header_loop:
lda (copy_src),y ; copy_src should be the SMB request - cloning this will set PID / MID etc
sta (copy_dest),y
lda (ptr1),y ; copy_src should be the SMB request - cloning this will set PID / MID etc
sta (ptr2),y
iny
cpy #smb_response_header_length
bne @copy_header_loop
@ -614,18 +615,18 @@ start_smb_response:
lda #smb_response_header_length
sta smb_response_length
ldy #3
sta (copy_dest),y
sta (ptr2),y
; set the flags correctly
ldy #smb_response_flags_offset
lda #$82 ; FLAGS byte
sta (copy_dest),y
sta (ptr2),y
iny
lda #$01 ; FLAGS2 low byte
sta (copy_dest),y
sta (ptr2),y
iny
lda #$00 ; FLAGS2 hi byte
sta (copy_dest),y
sta (ptr2),y
rts
add_andx_response:

View File

@ -1,8 +1,10 @@
; utility routine to copy memory
.include "zeropage.inc"
.export copymem
.importzp copy_src
.importzp copy_dest
.exportzp copy_src = ptr1
.exportzp copy_dest = ptr2
.bss

View File

@ -1,5 +1,6 @@
; routines for dumping debug information
.include "zeropage.inc"
.include "../inc/common.i"
.include "../inc/printf.i"
@ -14,7 +15,6 @@
.import eth_outp, eth_outp_len
.import ip_outp
.import udp_outp
.importzp copy_src
.code
@ -105,7 +105,7 @@ console_out = $ffd2
; inputs: AX = address of (null terminated) string to print
; outputs: none
console_strout:
stax copy_src
stax ptr1
pha
txa
@ -113,7 +113,7 @@ console_strout:
tya
pha
ldy #0
: lda (copy_src),y
: lda (ptr1),y
beq @done
jsr console_out
iny

View File

@ -1,7 +1,8 @@
; minimal dns implementation - requires a DNS server that supports recursion
MAX_DNS_MESSAGES_SENT = 8 ; timeout after sending 8 messages will be about 7 seconds (1+2+3+4+5+6+7+8)/4
MAX_DNS_MESSAGES_SENT = 8 ; timeout after sending 8 messages will be about 7 seconds (1+2+3+4+5+6+7+8)/4
.include "zeropage.inc"
.include "../inc/common.i"
.ifndef KPR_API_VERSION_NUMBER
@ -38,7 +39,7 @@
.import check_for_abort_key
.import timer_read
.importzp dns_hostname
dns_hostname = ptr1
.bss

View File

@ -3,6 +3,7 @@
; NB - this routine uses the same buffer space and zero page locations as many other ip65 routines. so do not call
; other ip65 routines between the http_parse_request & http_get_value else odd things will happen.
.include "zeropage.inc"
.include "../inc/common.i"
.ifndef KPR_API_VERSION_NUMBER
@ -13,14 +14,11 @@
.export http_parse_request
.export http_get_value
.importzp copy_src
.importzp copy_dest
.import output_buffer
.import parse_hex_digits
; reuse the copy_src zero page var
string_ptr = copy_src
table_ptr = copy_dest
string_ptr = ptr1
table_ptr = ptr2
.bss

View File

@ -1,6 +1,7 @@
; a simple HTTP server
; to use - call httpd_start with AX pointing at routine to call for each inbound page
.include "zeropage.inc"
.include "../inc/common.i"
.ifndef KPR_API_VERSION_NUMBER
@ -33,7 +34,7 @@ HTTPD_TIMEOUT_SECONDS = 5 ; what's the maximum time we let 1 connection be
.import native_to_ascii
.import timer_seconds
temp_ptr = copy_src
temp_ptr = ptr1
.bss

View File

@ -1,3 +1,4 @@
.include "zeropage.inc"
.include "../inc/common.i"
.export ip_init
@ -56,11 +57,7 @@
.import tcp_process
.endif
.importzp copy_src
.importzp copy_dest
.exportzp ip_cksum_ptr
ip_cksum_ptr=copy_dest
.exportzp ip_cksum_ptr = ptr2
.bss
@ -347,13 +344,13 @@ ip_send:
rol ; pad with 0
; clc
adc #<ip_outp
sta copy_src ; borrow copymem zp...
sta ptr1
lda ip_outp + ip_len
adc #>ip_outp
sta copy_src + 1
sta ptr1 + 1
ldy #0
tya
sta (copy_src),y
sta (ptr1),y
sec ; round up to even number
@dontpad:
lda ip_outp + ip_len + 1

View File

@ -4,12 +4,8 @@
.export parser_init
.export parser_skip_next
.importzp copy_src
.importzp copy_dest
target_string = copy_src
search_string = copy_dest
.include "zeropage.inc"
.include "../inc/common.i"
.ifndef KPR_API_VERSION_NUMBER
@ -17,6 +13,9 @@ search_string = copy_dest
.include "../inc/kipper_constants.i"
.endif
target_string = ptr1
search_string = ptr2
.bss

View File

@ -3,15 +3,14 @@
.export parse_integer
.export parse_hex_digits
.importzp copy_dest
.import mul_8_16
.importzp acc16
target_string = copy_dest
.include "zeropage.inc"
.include "../inc/common.i"
target_string = ptr2
.bss

View File

@ -7,6 +7,7 @@
MAX_TCP_PACKETS_SENT = 8 ; timeout after sending 8 messages will be about 7 seconds (1+2+3+4+5+6+7+8)/4
.include "zeropage.inc"
.include "../inc/common.i"
.ifndef KPR_API_VERSION_NUMBER
@ -378,16 +379,16 @@ tcp_close:
; carry flag is set if an error occured, clear otherwise
tcp_send_string:
stax tcp_send_data_ptr
stax copy_src
stax ptr1
lda #0
tay
sta tcp_send_data_len
sta tcp_send_data_len+1
lda (copy_src),y
lda (ptr1),y
bne @find_end_of_string
rts ; if the string is empty, don't send anything!
@find_end_of_string:
lda (copy_src),y
lda (ptr1),y
beq @done
inc tcp_send_data_len
iny

View File

@ -6,6 +6,7 @@
; telnet_menu - called whenever the F1 key is pressed.
; telnet_on_connection - called after succesful connection
.include "zeropage.inc"
.include "../inc/common.i"
.import tcp_connect
@ -45,7 +46,7 @@
.import telnet_menu
.import telnet_on_connection
.importzp buffer_ptr
buffer_ptr = ptr4
.code

View File

@ -4,6 +4,7 @@
TFTP_MAX_RESENDS = 10
TFTP_TIMER_MASK = $F8 ; mask lower two bits, means we wait for 8 x1/4 seconds
.include "zeropage.inc"
.include "../inc/common.i"
.ifndef KPR_API_VERSION_NUMBER
@ -48,7 +49,7 @@ TFTP_TIMER_MASK = $F8 ; mask lower two bits, means we wait for 8 x1/4
.import timer_read
.importzp tftp_filename
.exportzp tftp_filename = ptr3
.bss

View File

@ -1,5 +1,6 @@
; routines for parsing a URL, and downloading an URL
.include "zeropage.inc"
.include "../inc/common.i"
.ifndef KPR_API_VERSION_NUMBER
@ -41,8 +42,8 @@ TIMEOUT_SECONDS = 15
.export url_download_buffer_length
.export resource_download
target_string = copy_src
search_string = copy_dest
target_string = ptr1
search_string = ptr2
selector_buffer = output_buffer
@ -155,9 +156,9 @@ lda #url_type_gopher
ldax #slash
jsr parser_skip_next
; AX now pointing at selector
stax copy_src
stax ptr1
ldax #selector_buffer
stax copy_dest
stax ptr2
lda #0
sta src_ptr
sta dest_ptr
@ -167,7 +168,7 @@ lda #url_type_gopher
bne @not_gopher
; first byte after / in a gopher url is the resource type
ldy src_ptr
lda (copy_src),y
lda (ptr1),y
beq @start_of_selector
sta url_resource_type
inc src_ptr
@ -180,7 +181,7 @@ lda #url_type_gopher
ldy #get_length-1
sty dest_ptr
: lda get,y
sta (copy_dest),y
sta (ptr2),y
dey
bpl :-
@ -190,13 +191,13 @@ lda #url_type_gopher
jmp @save_first_byte_of_selector
@copy_one_byte:
ldy src_ptr
lda (copy_src),y
lda (ptr1),y
cmp #$20
bcc @end_of_selector ; any control char (including CR,LF, and $00) should be treated as end of URL
inc src_ptr
@save_first_byte_of_selector:
ldy dest_ptr
sta (copy_dest),y
sta (ptr2),y
inc dest_ptr
bne @copy_one_byte
@end_of_selector:
@ -212,22 +213,22 @@ lda #url_type_gopher
beq :+
ldy dest_ptr
inc dest_ptr
sta (copy_dest),y
sta (ptr2),y
inx
bne :-
: ; now copy the host field
jsr skip_to_hostname
; AX now pointing at hostname
stax copy_src
stax ptr1
ldax #selector_buffer
stax copy_dest
stax ptr2
lda #0
sta src_ptr
@copy_one_byte_of_hostname:
ldy src_ptr
lda (copy_src),y
lda (ptr1),y
beq @end_of_hostname
cmp #':'
beq @end_of_hostname
@ -235,7 +236,7 @@ lda #url_type_gopher
beq @end_of_hostname
inc src_ptr
ldy dest_ptr
sta (copy_dest),y
sta (ptr2),y
inc dest_ptr
bne @copy_one_byte_of_hostname
@end_of_hostname:
@ -244,10 +245,10 @@ lda #url_type_gopher
@final_crlf:
ldy dest_ptr
lda #$0d
sta (copy_dest),y
sta (ptr2),y
iny
lda #$0a
sta (copy_dest),y
sta (ptr2),y
iny
sty dest_ptr
dex
@ -255,7 +256,7 @@ lda #url_type_gopher
@done:
lda #$00
sta (copy_dest),y
sta (ptr2),y
ldax #selector_buffer
stax url_selector
clc
@ -351,10 +352,10 @@ resource_download:
put_zero_at_end_of_dl_buffer:
; put a zero byte at the end of the file
ldax temp_buffer
stax copy_dest
stax ptr2
lda #0
tay
sta (copy_dest),y
sta (ptr2),y
rts
not_end_of_file: