2009-06-24 13:52:23 +00:00
|
|
|
.include "../inc/common.i"
|
|
|
|
.include "../inc/commonprint.i"
|
|
|
|
.include "../inc/net.i"
|
|
|
|
|
|
|
|
.import exit_to_basic
|
|
|
|
|
|
|
|
.import parse_dotted_quad
|
|
|
|
.import dotted_quad_value
|
2009-06-26 13:19:46 +00:00
|
|
|
|
|
|
|
.import tcp_listen
|
|
|
|
.import tcp_callback
|
2009-06-28 08:36:49 +00:00
|
|
|
.import ip65_random_word
|
2009-06-27 12:57:43 +00:00
|
|
|
.import ip65_error
|
|
|
|
|
2009-06-26 13:19:46 +00:00
|
|
|
.import tcp_connect
|
2009-06-27 12:57:43 +00:00
|
|
|
.import tcp_connect_ip
|
|
|
|
|
|
|
|
.import tcp_send
|
|
|
|
.import tcp_send_data_len
|
2009-06-24 13:52:23 +00:00
|
|
|
|
|
|
|
.import __CODE_LOAD__
|
|
|
|
.import __CODE_SIZE__
|
|
|
|
.import __RODATA_SIZE__
|
|
|
|
.import __DATA_SIZE__
|
|
|
|
|
|
|
|
|
|
|
|
.importzp acc32
|
|
|
|
.importzp op32
|
2009-06-27 12:57:43 +00:00
|
|
|
.importzp acc16
|
|
|
|
|
2009-06-24 13:52:23 +00:00
|
|
|
.import add_32_32
|
|
|
|
.import add_16_32
|
2009-06-27 12:57:43 +00:00
|
|
|
.import cmp_32_32
|
|
|
|
.import cmp_16_16
|
2009-06-28 08:36:49 +00:00
|
|
|
|
|
|
|
.import sub_16_16
|
|
|
|
|
2009-06-24 13:52:23 +00:00
|
|
|
.segment "STARTUP" ;this is what gets put at the start of the file on the C64
|
|
|
|
|
|
|
|
.word basicstub ; load address
|
|
|
|
|
|
|
|
basicstub:
|
|
|
|
.word @nextline
|
|
|
|
.word 2003
|
|
|
|
.byte $9e
|
|
|
|
.byte <(((init / 1000) .mod 10) + $30)
|
|
|
|
.byte <(((init / 100 ) .mod 10) + $30)
|
|
|
|
.byte <(((init / 10 ) .mod 10) + $30)
|
|
|
|
.byte <(((init ) .mod 10) + $30)
|
|
|
|
.byte 0
|
|
|
|
@nextline:
|
|
|
|
.word 0
|
|
|
|
|
|
|
|
.segment "EXEHDR" ;this is what gets put an the start of the file on the Apple 2
|
|
|
|
.addr __CODE_LOAD__-$11 ; Start address
|
|
|
|
.word __CODE_SIZE__+__RODATA_SIZE__+__DATA_SIZE__+4 ; Size
|
|
|
|
jmp init
|
|
|
|
|
|
|
|
.code
|
|
|
|
|
|
|
|
init:
|
2009-06-28 08:36:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
ldax #$1234
|
|
|
|
stax acc16
|
|
|
|
ldax #$1235
|
|
|
|
jsr test_sub_16_16
|
2009-06-27 12:57:43 +00:00
|
|
|
|
2009-06-28 08:36:49 +00:00
|
|
|
ldax #$ff34
|
|
|
|
stax acc16
|
|
|
|
ldax #$1235
|
|
|
|
jsr test_sub_16_16
|
|
|
|
|
|
|
|
ldax #$100
|
|
|
|
stax acc16
|
|
|
|
ldax #$ffff
|
|
|
|
jsr test_sub_16_16
|
|
|
|
|
|
|
|
ldax #$ffff
|
|
|
|
stax acc16
|
|
|
|
ldax #$100
|
|
|
|
jsr test_sub_16_16
|
|
|
|
|
|
|
|
rts
|
2009-06-27 12:57:43 +00:00
|
|
|
ldax #number1
|
|
|
|
stax acc32
|
|
|
|
stax op32
|
|
|
|
jsr test_cmp_32_32
|
|
|
|
|
|
|
|
ldax #number1
|
|
|
|
stax acc32
|
|
|
|
ldax #number13
|
|
|
|
stax op32
|
|
|
|
jsr test_cmp_32_32
|
|
|
|
|
|
|
|
ldax #number1
|
|
|
|
stax acc32
|
|
|
|
ldax #number2
|
|
|
|
stax op32
|
|
|
|
jsr test_cmp_32_32
|
|
|
|
|
|
|
|
ldax #$12
|
|
|
|
stax acc16
|
|
|
|
jsr test_cmp_16_16
|
|
|
|
|
|
|
|
ldax #$1234
|
|
|
|
stax acc16
|
|
|
|
jsr test_cmp_16_16
|
|
|
|
|
|
|
|
ldax #$1234
|
|
|
|
stax acc16
|
|
|
|
ldax #$1235
|
|
|
|
jsr test_cmp_16_16
|
|
|
|
|
|
|
|
|
|
|
|
ldax #$1234
|
|
|
|
stax acc16
|
|
|
|
ldax #$2234
|
|
|
|
jsr test_cmp_16_16
|
|
|
|
|
|
|
|
|
|
|
|
ldax #$0000
|
|
|
|
stax acc16
|
|
|
|
jsr test_cmp_16_16
|
|
|
|
|
|
|
|
ldax #$FFFF
|
|
|
|
stax acc16
|
|
|
|
jsr test_cmp_16_16
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-06-24 13:52:23 +00:00
|
|
|
ldax #number1
|
|
|
|
stax acc32
|
|
|
|
ldax #number2
|
|
|
|
stax op32
|
|
|
|
jsr test_add_32_32
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ldax #number3
|
|
|
|
stax acc32
|
|
|
|
ldax #number4
|
|
|
|
stax op32
|
|
|
|
jsr test_add_32_32
|
|
|
|
|
|
|
|
ldax #number5
|
|
|
|
stax acc32
|
|
|
|
ldax #number6
|
|
|
|
stax op32
|
|
|
|
jsr test_add_32_32
|
|
|
|
|
|
|
|
ldax #number7
|
|
|
|
stax acc32
|
|
|
|
ldax #number8
|
|
|
|
stax op32
|
|
|
|
jsr test_add_32_32
|
|
|
|
|
|
|
|
ldax #number9
|
|
|
|
stax acc32
|
|
|
|
ldax #number10
|
|
|
|
stax op32
|
|
|
|
jsr test_add_32_32
|
|
|
|
|
|
|
|
ldax #number11
|
|
|
|
stax acc32
|
|
|
|
ldax #number12
|
|
|
|
stax op32
|
|
|
|
jsr test_add_32_32
|
|
|
|
|
|
|
|
|
|
|
|
ldax #number13
|
|
|
|
stax acc32
|
|
|
|
ldax #$1234
|
|
|
|
jsr test_add_16_32
|
|
|
|
|
|
|
|
ldax #number14
|
|
|
|
stax acc32
|
|
|
|
ldax #$1234
|
|
|
|
jsr test_add_16_32
|
|
|
|
|
|
|
|
ldax #number15
|
|
|
|
stax acc32
|
|
|
|
ldax #$1234
|
|
|
|
jsr test_add_16_32
|
|
|
|
|
|
|
|
ldax #number16
|
|
|
|
stax acc32
|
|
|
|
ldax #$1234
|
|
|
|
jsr test_add_16_32
|
|
|
|
|
2009-06-26 13:19:46 +00:00
|
|
|
|
|
|
|
jsr print_cr
|
|
|
|
init_ip_via_dhcp
|
|
|
|
jsr print_ip_config
|
|
|
|
|
2009-06-28 08:36:49 +00:00
|
|
|
jsr print_cr
|
|
|
|
|
|
|
|
|
|
|
|
jsr print_random_number
|
|
|
|
|
2009-06-27 12:57:43 +00:00
|
|
|
;connect to port 81 - should be rejected
|
|
|
|
|
2009-06-26 13:19:46 +00:00
|
|
|
ldax #tcp_callback_routine
|
|
|
|
stax tcp_callback
|
|
|
|
ldax tcp_dest_ip
|
2009-06-27 12:57:43 +00:00
|
|
|
stax tcp_connect_ip
|
2009-06-26 13:19:46 +00:00
|
|
|
ldax tcp_dest_ip+2
|
2009-06-27 12:57:43 +00:00
|
|
|
stax tcp_connect_ip+2
|
|
|
|
|
|
|
|
ldax #81
|
|
|
|
jsr tcp_connect
|
|
|
|
jsr check_for_error
|
|
|
|
|
|
|
|
ldax #http_get_length
|
|
|
|
stax tcp_send_data_len
|
|
|
|
ldax #http_get_msg
|
|
|
|
jsr tcp_send
|
|
|
|
jsr check_for_error
|
2009-06-26 13:19:46 +00:00
|
|
|
|
2009-06-27 12:57:43 +00:00
|
|
|
;now try to connect to port 80 - should be accepted
|
|
|
|
|
|
|
|
ldax #tcp_callback_routine
|
|
|
|
stax tcp_callback
|
|
|
|
ldax tcp_dest_ip
|
|
|
|
stax tcp_connect_ip
|
|
|
|
ldax tcp_dest_ip+2
|
|
|
|
stax tcp_connect_ip+2
|
2009-06-28 08:36:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
jmp @skip_past_normal_http
|
2009-06-26 13:19:46 +00:00
|
|
|
ldax #80
|
|
|
|
jsr tcp_connect
|
2009-06-27 12:57:43 +00:00
|
|
|
jsr check_for_error
|
|
|
|
|
|
|
|
ldax #http_get_length
|
|
|
|
stax tcp_send_data_len
|
|
|
|
ldax #http_get_msg
|
|
|
|
jsr tcp_send
|
|
|
|
jsr check_for_error
|
2009-06-28 08:36:49 +00:00
|
|
|
|
|
|
|
ldax #tcp_callback_routine
|
|
|
|
stax tcp_callback
|
|
|
|
ldax tcp_dest_ip
|
|
|
|
stax tcp_connect_ip
|
|
|
|
ldax tcp_dest_ip+2
|
|
|
|
stax tcp_connect_ip+2
|
|
|
|
|
|
|
|
|
|
|
|
@skip_past_normal_http:
|
|
|
|
; connect to port 80 again, and send GET in 2 parts
|
|
|
|
|
|
|
|
|
|
|
|
ldax #80
|
|
|
|
jsr tcp_connect
|
|
|
|
jsr check_for_error
|
|
|
|
|
|
|
|
ldax #4
|
|
|
|
stax tcp_send_data_len
|
|
|
|
ldax #http_get_msg
|
|
|
|
jsr tcp_send
|
|
|
|
jsr check_for_error
|
|
|
|
ldax #http_get_length-4
|
|
|
|
stax tcp_send_data_len
|
|
|
|
ldax #http_get_msg+4
|
|
|
|
jsr tcp_send
|
|
|
|
jsr check_for_error
|
|
|
|
|
2009-06-27 12:57:43 +00:00
|
|
|
; .byte $92
|
|
|
|
|
|
|
|
ldax #looping
|
|
|
|
jsr print
|
|
|
|
@loop_forever:
|
2009-06-26 13:19:46 +00:00
|
|
|
jsr ip65_process
|
2009-06-27 12:57:43 +00:00
|
|
|
jmp @loop_forever
|
2009-06-26 13:19:46 +00:00
|
|
|
rts
|
2009-06-24 13:52:23 +00:00
|
|
|
|
2009-06-26 13:19:46 +00:00
|
|
|
tcp_callback_routine:
|
|
|
|
rts
|
2009-06-24 13:52:23 +00:00
|
|
|
|
|
|
|
|
2009-06-27 12:57:43 +00:00
|
|
|
check_for_error:
|
|
|
|
lda ip65_error
|
|
|
|
beq @exit
|
|
|
|
ldax #error_code
|
|
|
|
jsr print
|
|
|
|
lda ip65_error
|
|
|
|
jsr print_hex
|
|
|
|
jsr print_cr
|
|
|
|
lda #0
|
|
|
|
sta ip65_error
|
|
|
|
@exit:
|
|
|
|
rts
|
|
|
|
|
2009-06-28 08:36:49 +00:00
|
|
|
print_random_number:
|
|
|
|
jsr ip65_random_word
|
|
|
|
stx temp_ax
|
|
|
|
jsr print_hex
|
|
|
|
lda temp_ax
|
|
|
|
jsr print_hex
|
|
|
|
jsr print_cr
|
|
|
|
rts
|
2009-06-27 12:57:43 +00:00
|
|
|
|
2009-06-24 13:52:23 +00:00
|
|
|
;assumes acc32 & op32 already set
|
|
|
|
test_add_32_32:
|
|
|
|
ldy #3
|
|
|
|
:
|
|
|
|
lda (acc32),y
|
|
|
|
jsr print_hex
|
|
|
|
dey
|
|
|
|
bpl :-
|
|
|
|
|
|
|
|
lda #'+'
|
|
|
|
jsr print_a
|
|
|
|
ldy #3
|
|
|
|
:
|
|
|
|
lda (op32),y
|
|
|
|
jsr print_hex
|
|
|
|
dey
|
|
|
|
bpl :-
|
|
|
|
|
|
|
|
lda #'='
|
|
|
|
jsr print_a
|
|
|
|
jsr add_32_32
|
|
|
|
|
|
|
|
ldy #3
|
|
|
|
:
|
|
|
|
lda (acc32),y
|
|
|
|
jsr print_hex
|
|
|
|
dey
|
|
|
|
bpl :-
|
|
|
|
jsr print_cr
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-06-27 12:57:43 +00:00
|
|
|
;assumes acc32 & op32 already set
|
|
|
|
test_cmp_32_32:
|
|
|
|
ldy #3
|
|
|
|
:
|
|
|
|
lda (acc32),y
|
|
|
|
jsr print_hex
|
|
|
|
dey
|
|
|
|
bpl :-
|
|
|
|
|
|
|
|
lda #'='
|
|
|
|
jsr print_a
|
|
|
|
ldy #3
|
|
|
|
:
|
|
|
|
lda (op32),y
|
|
|
|
jsr print_hex
|
|
|
|
dey
|
|
|
|
bpl :-
|
|
|
|
|
|
|
|
lda #':'
|
|
|
|
jsr print_a
|
|
|
|
jsr cmp_32_32
|
|
|
|
bne @not_equal
|
|
|
|
lda #'T'
|
|
|
|
jmp @char_set
|
|
|
|
@not_equal:
|
|
|
|
lda #'F'
|
|
|
|
@char_set:
|
|
|
|
jsr print_a
|
|
|
|
jsr print_cr
|
|
|
|
rts
|
|
|
|
|
|
|
|
;assumes acc16& AX already set
|
|
|
|
test_cmp_16_16:
|
|
|
|
stax temp_ax
|
|
|
|
lda acc16+1
|
|
|
|
jsr print_hex
|
|
|
|
lda acc16
|
|
|
|
jsr print_hex
|
|
|
|
|
|
|
|
lda #'='
|
|
|
|
jsr print_a
|
|
|
|
lda temp_ax+1
|
|
|
|
jsr print_hex
|
|
|
|
lda temp_ax
|
|
|
|
jsr print_hex
|
|
|
|
|
|
|
|
lda #':'
|
|
|
|
jsr print_a
|
|
|
|
ldax temp_ax
|
|
|
|
jsr cmp_16_16
|
|
|
|
bne @not_equal
|
|
|
|
lda #'T'
|
|
|
|
jmp @char_set
|
|
|
|
@not_equal:
|
|
|
|
lda #'F'
|
|
|
|
@char_set:
|
|
|
|
jsr print_a
|
|
|
|
jsr print_cr
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2009-06-24 13:52:23 +00:00
|
|
|
;assumes acc32 & AX already set
|
|
|
|
test_add_16_32:
|
|
|
|
stax temp_ax
|
|
|
|
ldy #3
|
|
|
|
:
|
|
|
|
lda (acc32),y
|
|
|
|
jsr print_hex
|
|
|
|
dey
|
|
|
|
bpl :-
|
|
|
|
|
|
|
|
lda #'+'
|
|
|
|
jsr print_a
|
|
|
|
|
|
|
|
lda temp_ax+1
|
|
|
|
jsr print_hex
|
|
|
|
lda temp_ax
|
|
|
|
jsr print_hex
|
|
|
|
|
|
|
|
lda #'='
|
|
|
|
jsr print_a
|
|
|
|
ldax temp_ax
|
|
|
|
jsr add_16_32
|
|
|
|
|
|
|
|
ldy #3
|
|
|
|
:
|
|
|
|
lda (acc32),y
|
|
|
|
jsr print_hex
|
|
|
|
dey
|
|
|
|
bpl :-
|
|
|
|
jsr print_cr
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2009-06-28 08:36:49 +00:00
|
|
|
;assumes acc16 & AX already set
|
|
|
|
test_sub_16_16:
|
|
|
|
stax temp_ax
|
|
|
|
|
|
|
|
lda acc16+1
|
|
|
|
jsr print_hex
|
|
|
|
lda acc16
|
|
|
|
jsr print_hex
|
|
|
|
|
|
|
|
lda #'-'
|
|
|
|
jsr print_a
|
|
|
|
|
|
|
|
lda temp_ax+1
|
|
|
|
jsr print_hex
|
|
|
|
lda temp_ax
|
|
|
|
jsr print_hex
|
|
|
|
|
|
|
|
lda #'='
|
|
|
|
jsr print_a
|
|
|
|
ldax temp_ax
|
|
|
|
jsr sub_16_16
|
|
|
|
|
|
|
|
lda acc16+1
|
|
|
|
jsr print_hex
|
|
|
|
lda acc16
|
|
|
|
jsr print_hex
|
|
|
|
|
|
|
|
jsr print_cr
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2009-06-24 13:52:23 +00:00
|
|
|
@error:
|
|
|
|
ldax #failed_msg
|
|
|
|
jsr print
|
|
|
|
jsr print_cr
|
|
|
|
rts
|
|
|
|
|
|
|
|
.bss
|
|
|
|
temp_ax: .res 2
|
|
|
|
|
|
|
|
.rodata
|
|
|
|
|
|
|
|
|
|
|
|
.data
|
|
|
|
number1:
|
|
|
|
.byte $1,$2,$3,$f
|
|
|
|
number2:
|
|
|
|
.byte $10,$20,$30,$f0
|
|
|
|
number3:
|
|
|
|
.byte $ff,$ff,$ff,$ff
|
|
|
|
number4:
|
|
|
|
.byte $1,$0,$0,$0
|
|
|
|
|
|
|
|
number5:
|
|
|
|
.byte $ff,$ff,$ff,$ff
|
|
|
|
number6:
|
|
|
|
.byte $0,$0,$0,$0
|
|
|
|
number7:
|
|
|
|
.byte $ff,$ff,$ff,$fe
|
|
|
|
number8:
|
|
|
|
.byte $1,$0,$0,$0
|
|
|
|
number9:
|
|
|
|
.byte $ff,$ff,$ff,$fe
|
|
|
|
number10:
|
|
|
|
.byte $5,$0,$0,$0
|
|
|
|
number11:
|
|
|
|
.byte $ff,$0,$0,$e
|
|
|
|
number12:
|
|
|
|
.byte $5,$0,$0,$0
|
|
|
|
|
|
|
|
number13:
|
|
|
|
.byte $1,$2,$3,$4
|
|
|
|
|
|
|
|
number14:
|
|
|
|
.byte $ff,$ff,$ff,$ff
|
|
|
|
|
|
|
|
number15:
|
|
|
|
.byte $ff,$ff,$00,$00
|
|
|
|
|
|
|
|
number16:
|
|
|
|
.byte $00,$00,$00,$00
|
2009-06-26 13:19:46 +00:00
|
|
|
|
2009-06-28 08:36:49 +00:00
|
|
|
|
2009-06-26 13:19:46 +00:00
|
|
|
tcp_dest_ip:
|
2009-06-28 08:36:49 +00:00
|
|
|
; .byte 10,5,1,1
|
2009-06-27 12:57:43 +00:00
|
|
|
.byte 74,207,242,229
|
|
|
|
error_code:
|
|
|
|
.asciiz "ERROR CODE: $"
|
|
|
|
looping:
|
|
|
|
.asciiz "LOOPING..."
|
|
|
|
|
|
|
|
http_get_msg:
|
|
|
|
.byte "GET / HTTP/1.0",13,10,13,10
|
|
|
|
http_get_msg_end:
|
|
|
|
http_get_length=http_get_msg_end-http_get_msg
|