Skip to content

Commit 613eb05

Browse files
committed
update
1 parent 33b7c54 commit 613eb05

File tree

9 files changed

+52
-11
lines changed

9 files changed

+52
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.o
22
*.lib
33
build/
4+
tmp/
45

bpm.tml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "inet"
3-
version = "2024.4"
3+
version = "2025.1"
44
authors = [ "[email protected]",]
55
license = "MIT OR Apache-2.0"
66
edition = "2018"
@@ -14,5 +14,6 @@ buildfolder = "build"
1414
packagetype = "tgz"
1515
codetype = "lib"
1616
oricutron_replace_autoboot_run = "True"
17+
templatecode = ""
1718

1819
[dependencies]

docs/_inet_aton.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## inet_aton(const char *cp, unsigned long *inp);
2+
***Description***
3+
4+
returns in BIG ENDIAN
5+
***Description***
6+
7+
returns in BIG ENDIAN
8+

docs/inet_aton.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
3+
## inet_aton
4+
***Description***
5+
6+
Convert ip str to int 32 (net work notation : big endian), returns 255 255 255 255 if error
7+
***Input***
8+
9+
* Accumulator : Low addr of string
10+
* X Register : high addr
11+
12+
***Modify***
13+
14+
* RESB* RES* TR0* TR1; TR0 indexed* TR2; TR0 indexed* TR3; TR0 indexed
15+
***Returns***
16+
17+
* X Register : X = 1 error, is not an ip
18+
19+
20+
21+
22+
23+
***Example***
24+
25+
```ca65 lda #<ip_str ldx #>ip_str jsr inet_aton rtsip_str: .asciiz 192.168.1.1```
26+
```
27+

docs/md2hlp.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
;
33
; Default options
44
;
5-
Version = 2
5+
Version = 3
66
Break on hyphens = True
77

88
Head = ^A
@@ -30,6 +30,7 @@ cite = _|,
3030

3131

3232
link = ^T,^P
33+
image = None
3334

3435
ink_black = ^@
3536
ink_red = ^A

src/_inet_aton.s

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
.importzp ptr1
99

1010
.proc _inet_aton
11-
;;@proto inet_aton(const char *cp, unsigned long *inp);
11+
;;@proto long inet_aton(const char *cp, unsigned long *inp);
12+
;;@brief returns in BIG ENDIAN
1213

1314
sta ptr1 ; Ptr to store int
1415
stx ptr1+1 ; ptr to store int
@@ -21,17 +22,17 @@
2122
cpx #$01
2223
beq @return_error
2324

24-
lda TR7
25+
lda TR4
2526
ldy #$00
2627
sta (ptr1),y
2728
iny
28-
lda TR6
29+
lda TR5
2930
sta (ptr1),y
3031
iny
31-
lda TR5
32+
lda TR6
3233
sta (ptr1),y
3334
iny
34-
lda TR4
35+
lda TR7
3536
sta (ptr1),y
3637

3738
lda #$01

src/include/inetextend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
unsigned char inet_aton(const char *cp, unsigned long *inp);
1+
long inet_aton(const char *cp, unsigned long *inp);

src/inet_aton.s

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.export inet_aton
44

55
.proc inet_aton
6-
;;@brief Convert ip str to int 32, returns 255 255 255 255 if error
6+
;;@brief Convert ip str to int 32 (net work notation : big endian), returns 255 255 255 255 if error
77
;;@inputA Low addr of string
88
;;@inputX high addr
99
;;@modifyMEM_RESB
@@ -26,12 +26,13 @@
2626
;;@` .asciiz 192.168.1.1
2727
;;@```
2828

29-
29+
; Store the ptr of the string
3030
sta RES
3131
stx RES+1
3232

3333
ldx #$00
3434
stx RESB ; Current digit
35+
; Clear TR4 to TR7 to 0
3536
stx TR4
3637
stx TR5
3738
stx TR6

tests/inetaton.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
void display(int32_t inp, unsigned char error, char *str) {
77
if (error == 1)
88
printf("IP : %d.%d.%d.%d\n", (unsigned char)(inp >> 24), (unsigned char)(inp >> 16) & 0xff, (unsigned char)(inp >> 8) & 0xff, (unsigned char)(inp & 0xff));
9+
printf("%d" ,inp[0]);
910
else
1011
printf("Invalid conversion for : %s\n", str);
1112
}
1213

1314
int main() {
14-
uint32_t inp=0;
15+
uint32_t inp = 0;
1516
uint8_t error=0;
1617

1718
error = inet_aton("1.2.3.4", &inp);

0 commit comments

Comments
 (0)