1
0
mirror of https://github.com/cc65/cc65.git synced 2026-04-25 22:18:27 +00:00

Add ntohs, htons, ntohl, htons.

This commit is contained in:
Colin Leroy-Mira
2023-09-06 08:09:00 +02:00
parent e52e350498
commit dfe7562f76
6 changed files with 217 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
;
; Colin Leroy-Mira <colin@colino.net>, 2023-09-06
;
; int __fastcall__ ntohl (long val);
;
.export _ntohl, _htonl
.import popa
.importzp tmp1, tmp2, sreg
_htonl := _ntohl
.code
_ntohl:
; The parts of our 32 bit word
; are in sreg+1, sreg, X, A.
; Save A and X
stx tmp1
sta tmp2
; Invert high word
lda sreg+1
ldx sreg
; Invert low word
ldy tmp1
sty sreg
ldy tmp2
sty sreg+1
rts
+18
View File
@@ -0,0 +1,18 @@
;
; Colin Leroy-Mira <colin@colino.net>, 2023-09-06
;
; int __fastcall__ ntohs (int val);
;
.export _ntohs, _htons
.importzp tmp1
_htons := _ntohs
.code
_ntohs:
sta tmp1
txa
ldx tmp1
rts