From eec2147826be2977fbe2cbf7df750735f8bea1b4 Mon Sep 17 00:00:00 2001 From: Dean Netherton Date: Thu, 27 Feb 2025 19:58:59 +1100 Subject: [PATCH] ch376-native: applied z88dk version 20250224 --- Source/HBIOS/ch376-native/Makefile | 2 +- Source/HBIOS/ch376-native/base-drv/ch376.c.s | 132 +++--- .../HBIOS/ch376-native/base-drv/class_hub.c.s | 2 +- .../base-drv/critical-section.c.s | 2 +- .../ch376-native/base-drv/dev_transfers.c.s | 218 ++++----- .../HBIOS/ch376-native/base-drv/enumerate.c.s | 357 +++++++------- .../ch376-native/base-drv/enumerate_hub.c.s | 30 +- .../base-drv/enumerate_storage.c.s | 4 +- .../HBIOS/ch376-native/base-drv/protocol.c.s | 64 +-- .../HBIOS/ch376-native/base-drv/transfers.c.s | 21 +- .../ch376-native/base-drv/usb-base-drv.c.s | 21 +- .../HBIOS/ch376-native/base-drv/usb-init.c.s | 37 +- .../HBIOS/ch376-native/base-drv/usb_state.c.s | 16 +- .../HBIOS/ch376-native/base-drv/work-area.c.s | 2 +- .../HBIOS/ch376-native/keyboard/class_hid.c.s | 4 +- .../keyboard/class_hid_keyboard.c.s | 8 +- .../HBIOS/ch376-native/keyboard/kyb-init.c.s | 51 +- .../ch376-native/scsi-drv/class_scsi.c.s | 436 ++++++++++-------- .../HBIOS/ch376-native/scsi-drv/scsi-init.c.s | 6 +- .../HBIOS/ch376-native/ufi-drv/class_ufi.c.s | 177 +++---- .../HBIOS/ch376-native/ufi-drv/ufi-init.c.s | 6 +- Source/HBIOS/ch376-native/ufi-drv/usb_cbi.c.s | 5 +- 22 files changed, 819 insertions(+), 782 deletions(-) diff --git a/Source/HBIOS/ch376-native/Makefile b/Source/HBIOS/ch376-native/Makefile index 1b6c1369..cd6f25b0 100644 --- a/Source/HBIOS/ch376-native/Makefile +++ b/Source/HBIOS/ch376-native/Makefile @@ -12,7 +12,7 @@ ZCCFLAGS := +z80 -vn -startup=0 -clib=sdcc_iy -compiler=sdcc -Cs--std=c23 -Cs-- ZCC_PATH := $(shell command -v zcc) DOCKER_PATH := $(shell command -v docker) -ZCC := $(shell command -v zcc >/dev/null 2>&1 && echo zcc || echo 'docker run -w /host/${PWD} -v /:/host/ -u $(shell id -u ${USER}):$(shell id -g ${USER}) -t z88dk/z88dk zcc') +ZCC := $(shell command -v zcc >/dev/null 2>&1 && echo zcc || echo 'docker run -w /host/${PWD} -v /:/host/ -u $(shell id -u ${USER}):$(shell id -g ${USER}) -t z88dk/z88dk:20250224 zcc') ifeq ($(ZCC_PATH),) ifeq ($(DOCKER_PATH),) diff --git a/Source/HBIOS/ch376-native/base-drv/ch376.c.s b/Source/HBIOS/ch376-native/base-drv/ch376.c.s index 48b93254..0277a1e8 100644 --- a/Source/HBIOS/ch376-native/base-drv/ch376.c.s +++ b/Source/HBIOS/ch376-native/base-drv/ch376.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -56,19 +56,18 @@ _result: ; --------------------------------- _ch_command: ;source-doc/base-drv/ch376.c:10: while ((CH376_COMMAND_PORT & PARA_STATE_BUSY) && --counter != 0) - ld c,0xff + ld b,0xff l_ch_command_00102: ld a, +((_CH376_COMMAND_PORT) / 256) in a, (((_CH376_COMMAND_PORT) & 0xFF)) bit 4, a jr Z,l_ch_command_00104 - dec c - jr NZ,l_ch_command_00102 + djnz l_ch_command_00102 l_ch_command_00104: ;source-doc/base-drv/ch376.c:21: CH376_COMMAND_PORT = command; ld a, l ld bc,_CH376_COMMAND_PORT - out (c),a + out (c), a ;source-doc/base-drv/ch376.c:22: } ret ;source-doc/base-drv/ch376.c:26: usb_error ch_long_wait_int_and_get_status(void) { return ch_wait_int_and_get_status(5000); } @@ -104,57 +103,51 @@ _ch_get_status: ld a, +((_CH376_DATA_PORT) / 256) in a, (((_CH376_DATA_PORT) & 0xFF)) ;source-doc/base-drv/ch376.c:36: if (ch_status >= USB_FILERR_MIN && ch_status <= USB_FILERR_MAX) - ld l,a - sub 0x41 + cp 0x41 jr C,l_ch_get_status_00102 - ld a,0xb4 - sub l + cp 0xb5 + jr NC,l_ch_get_status_00102 ;source-doc/base-drv/ch376.c:37: return ch_status; - jr NC,l_ch_get_status_00126 + ld l, a + jr l_ch_get_status_00126 l_ch_get_status_00102: ;source-doc/base-drv/ch376.c:39: if (ch_status == CH_CMD_RET_SUCCESS) - ld a, l -;source-doc/base-drv/ch376.c:40: return USB_ERR_OK; - sub 0x51 + cp 0x51 jr NZ,l_ch_get_status_00105 - ld l,a +;source-doc/base-drv/ch376.c:40: return USB_ERR_OK; + ld l,0x00 jr l_ch_get_status_00126 l_ch_get_status_00105: ;source-doc/base-drv/ch376.c:42: if (ch_status == CH_USB_INT_SUCCESS) - ld a, l -;source-doc/base-drv/ch376.c:43: return USB_ERR_OK; - sub 0x14 + cp 0x14 jr NZ,l_ch_get_status_00107 - ld l,a +;source-doc/base-drv/ch376.c:43: return USB_ERR_OK; + ld l,0x00 jr l_ch_get_status_00126 l_ch_get_status_00107: ;source-doc/base-drv/ch376.c:45: if (ch_status == CH_USB_INT_CONNECT) - ld a, l - sub 0x15 + cp 0x15 jr NZ,l_ch_get_status_00109 ;source-doc/base-drv/ch376.c:46: return USB_INT_CONNECT; ld l,0x81 jr l_ch_get_status_00126 l_ch_get_status_00109: ;source-doc/base-drv/ch376.c:48: if (ch_status == CH_USB_INT_DISK_READ) - ld a, l - sub 0x1d + cp 0x1d jr NZ,l_ch_get_status_00111 ;source-doc/base-drv/ch376.c:49: return USB_ERR_DISK_READ; ld l,0x1d jr l_ch_get_status_00126 l_ch_get_status_00111: ;source-doc/base-drv/ch376.c:51: if (ch_status == CH_USB_INT_DISK_WRITE) - ld a, l - sub 0x1e + cp 0x1e jr NZ,l_ch_get_status_00113 ;source-doc/base-drv/ch376.c:52: return USB_ERR_DISK_WRITE; ld l,0x1e jr l_ch_get_status_00126 l_ch_get_status_00113: ;source-doc/base-drv/ch376.c:54: if (ch_status == CH_USB_INT_DISCONNECT) { - ld a, l - sub 0x16 + cp 0x16 jr NZ,l_ch_get_status_00115 ;source-doc/base-drv/ch376.c:55: ch_cmd_set_usb_mode(5); ld l,0x05 @@ -164,15 +157,13 @@ l_ch_get_status_00113: jr l_ch_get_status_00126 l_ch_get_status_00115: ;source-doc/base-drv/ch376.c:59: if (ch_status == CH_USB_INT_BUF_OVER) - ld a, l - sub 0x17 + cp 0x17 jr NZ,l_ch_get_status_00117 ;source-doc/base-drv/ch376.c:60: return USB_ERR_DATA_ERROR; ld l,0x04 jr l_ch_get_status_00126 l_ch_get_status_00117: ;source-doc/base-drv/ch376.c:62: ch_status &= 0x2F; - ld a, l and 0x2f ;source-doc/base-drv/ch376.c:64: if (ch_status == 0x2A) cp 0x2a @@ -234,7 +225,7 @@ l_ch_probe_00103: ;source-doc/base-drv/ch376.c:86: CH376_DATA_PORT = (uint8_t)~0x55; ld a,0xaa ld bc,_CH376_DATA_PORT - out (c),a + out (c), a ;source-doc/base-drv/ch376.c:87: delay(); call _delay ;source-doc/base-drv/ch376.c:88: complement = CH376_DATA_PORT; @@ -272,14 +263,16 @@ _ch_cmd_set_usb_mode: ld a,0x15 push bc ld bc,_CH376_COMMAND_PORT - out (c),a + out (c), a +;source-doc/base-drv/ch376.c:116: delay(); call _delay pop bc ;source-doc/base-drv/ch376.c:117: CH376_DATA_PORT = mode; ld a, c push bc ld bc,_CH376_DATA_PORT - out (c),a + out (c), a +;source-doc/base-drv/ch376.c:118: delay(); call _delay pop bc ;source-doc/base-drv/ch376.c:122: while (result != CH_CMD_RET_SUCCESS && result != CH_CMD_RET_ABORT && --count != 0) { @@ -351,7 +344,7 @@ _ch_issue_token: ;source-doc/base-drv/ch376.c:137: CH376_DATA_PORT = toggle_bit; ld a,(ix+4) ld bc,_CH376_DATA_PORT - out (c),a + out (c), a ;source-doc/base-drv/ch376.c:138: CH376_DATA_PORT = endpoint << 4 | pid; ld a,(ix+5) add a, a @@ -360,7 +353,7 @@ _ch_issue_token: add a, a or (ix+6) ld bc,_CH376_DATA_PORT - out (c),a + out (c), a ;source-doc/base-drv/ch376.c:139: } pop ix ret @@ -484,7 +477,6 @@ _ch_data_in_transfer: push ix ld ix,0 add ix,sp - push af ;source-doc/base-drv/ch376.c:158: if (buffer_size == 0) ld a,(ix+7) or (ix+6) @@ -496,18 +488,17 @@ l_ch_data_in_transfer_00102: ;source-doc/base-drv/ch376.c:161: USB_MODULE_LEDS = 0x01; ld a,0x01 ld bc,_USB_MODULE_LEDS - out (c),a + out (c), a ;source-doc/base-drv/ch376.c:162: do { ld c,(ix+8) ld b,(ix+9) - pop de - push bc l_ch_data_in_transfer_00107: ;source-doc/base-drv/ch376.c:163: ch_issue_token_in(endpoint); ld l,c ld h,b push hl call _ch_issue_token_in +;source-doc/base-drv/ch376.c:165: result = ch_long_wait_int_and_get_status(); call _ch_long_wait_int_and_get_statu pop bc ld a, l @@ -519,9 +510,9 @@ l_ch_data_in_transfer_00107: ;source-doc/base-drv/ch376.c:168: endpoint->toggle = !endpoint->toggle; ld e, c ld d, b - pop hl - ld a,(hl) - push hl + ld l, e + ld h, d + ld a, (hl) and 0x01 xor 0x01 and 0x01 @@ -544,7 +535,7 @@ l_ch_data_in_transfer_00107: ;source-doc/base-drv/ch376.c:173: USB_MODULE_LEDS = 0x03; ld a,0x03 ld bc,_USB_MODULE_LEDS - out (c),a + out (c), a ;source-doc/base-drv/ch376.c:174: return USB_ERR_DATA_ERROR; ld l,0x04 jr l_ch_data_in_transfer_00111 @@ -575,7 +566,7 @@ l_ch_data_in_transfer_00149: ;source-doc/base-drv/ch376.c:181: USB_MODULE_LEDS = 0x03; ld a,0x03 ld bc,_USB_MODULE_LEDS - out (c),a + out (c), a ;source-doc/base-drv/ch376.c:182: return USB_ERR_OK; ld l,0x00 jr l_ch_data_in_transfer_00111 @@ -584,13 +575,11 @@ l_ch_data_in_transfer_00110: ;source-doc/base-drv/ch376.c:185: USB_MODULE_LEDS = 0x03; ld a,0x03 ld bc,_USB_MODULE_LEDS - out (c),a + out (c), a ;source-doc/base-drv/ch376.c:186: return result; - ld hl,(_result) - ld h,+((_result) / 256) + ld hl, (_result) l_ch_data_in_transfer_00111: ;source-doc/base-drv/ch376.c:187: } - ld sp, ix pop ix ret ;source-doc/base-drv/ch376.c:189: usb_error ch_data_in_transfer_n(uint8_t *const buffer, int8_t *const buffer_size, endpoint_param *const endpoint) { @@ -604,32 +593,28 @@ _ch_data_in_transfer_n: ;source-doc/base-drv/ch376.c:193: USB_MODULE_LEDS = 0x01; ld a,0x01 ld bc,_USB_MODULE_LEDS - out (c),a + out (c), a ;source-doc/base-drv/ch376.c:195: ch_issue_token_in(endpoint); ld l,(ix+8) ld h,(ix+9) call _ch_issue_token_in ;source-doc/base-drv/ch376.c:197: CHECK(ch_long_wait_int_and_get_status()); call _ch_long_wait_int_and_get_statu - ld a, l - ld b, a + ld a,l or a jr NZ,l_ch_data_in_transfer_n_00103 ;source-doc/base-drv/ch376.c:199: endpoint->toggle = !endpoint->toggle; - ld e,(ix+8) - ld d,(ix+9) - ld c, e - ld b, d - ex de, hl + ld l,(ix+8) + ld h,(ix+9) ld a, (hl) and 0x01 xor 0x01 and 0x01 - ld e, a - ld a, (bc) + ld c, a + ld a, (hl) and 0xfe - or e - ld (bc), a + or c + ld (hl), a ;source-doc/base-drv/ch376.c:201: count = ch_read_data(buffer); ld l,(ix+4) ld h,(ix+5) @@ -641,7 +626,7 @@ _ch_data_in_transfer_n: ;source-doc/base-drv/ch376.c:205: USB_MODULE_LEDS = 0x03; ld a,0x03 ld bc,_USB_MODULE_LEDS - out (c),a + out (c), a ;source-doc/base-drv/ch376.c:207: return USB_ERR_OK; ld l,0x00 jr l_ch_data_in_transfer_n_00104 @@ -649,12 +634,9 @@ _ch_data_in_transfer_n: l_ch_data_in_transfer_n_00103: ;source-doc/base-drv/ch376.c:209: USB_MODULE_LEDS = 0x03; ld a,0x03 - push bc ld bc,_USB_MODULE_LEDS - out (c),a - pop bc + out (c), a ;source-doc/base-drv/ch376.c:210: return result; - ld l, b l_ch_data_in_transfer_n_00104: ;source-doc/base-drv/ch376.c:211: } pop ix @@ -667,7 +649,6 @@ _ch_data_out_transfer: push ix ld ix,0 add ix,sp - push af dec sp ;source-doc/base-drv/ch376.c:216: const uint8_t max_packet_size = calc_max_packet_size(endpoint->max_packet_sizex); ld c,(ix+8) @@ -676,16 +657,14 @@ _ch_data_out_transfer: ld d, b inc de ld a, (de) - ld (ix-3),a + ld (ix-1),a ;source-doc/base-drv/ch376.c:218: USB_MODULE_LEDS = 0x02; ld a,0x02 push bc ld bc,_USB_MODULE_LEDS - out (c),a + out (c), a pop bc ;source-doc/base-drv/ch376.c:220: while (buffer_length > 0) { - ld (ix-2),c - ld (ix-1),b l_ch_data_out_transfer_00103: xor a cp (ix+6) @@ -695,7 +674,7 @@ l_ch_data_out_transfer_00103: l_ch_data_out_transfer_00139: jp P, l_ch_data_out_transfer_00105 ;source-doc/base-drv/ch376.c:221: const uint8_t size = max_packet_size < buffer_length ? max_packet_size : buffer_length; - ld d,(ix-3) + ld d,(ix-1) ld e,0x00 ld a, d sub (ix+6) @@ -738,6 +717,7 @@ l_ch_data_out_transfer_00110: ld h,b push hl call _ch_issue_token_out +;source-doc/base-drv/ch376.c:226: CHECK(ch_long_wait_int_and_get_status()); call _ch_long_wait_int_and_get_statu ld a, l pop bc @@ -747,8 +727,8 @@ l_ch_data_out_transfer_00110: ;source-doc/base-drv/ch376.c:228: endpoint->toggle = !endpoint->toggle; ld e, c ld d, b - ld l,(ix-2) - ld h,(ix-1) + ld l, e + ld h, d ld a, (hl) and 0x01 xor 0x01 @@ -763,7 +743,7 @@ l_ch_data_out_transfer_00105: ;source-doc/base-drv/ch376.c:231: USB_MODULE_LEDS = 0x03; ld a,0x03 ld bc,_USB_MODULE_LEDS - out (c),a + out (c), a ;source-doc/base-drv/ch376.c:232: return USB_ERR_OK; ld l,0x00 jr l_ch_data_out_transfer_00107 @@ -772,11 +752,11 @@ l_ch_data_out_transfer_00106: ;source-doc/base-drv/ch376.c:235: USB_MODULE_LEDS = 0x03; ld a,0x03 ld bc,_USB_MODULE_LEDS - out (c),a + out (c), a ;source-doc/base-drv/ch376.c:236: return result; l_ch_data_out_transfer_00107: ;source-doc/base-drv/ch376.c:237: } - ld sp, ix + inc sp pop ix ret ;source-doc/base-drv/ch376.c:239: void ch_set_usb_address(const uint8_t device_address) __z88dk_fastcall { @@ -792,7 +772,7 @@ _ch_set_usb_address: ;source-doc/base-drv/ch376.c:241: CH376_DATA_PORT = device_address; ld a, l ld bc,_CH376_DATA_PORT - out (c),a + out (c), a ;source-doc/base-drv/ch376.c:242: } ret _result: diff --git a/Source/HBIOS/ch376-native/base-drv/class_hub.c.s b/Source/HBIOS/ch376-native/base-drv/class_hub.c.s index 89e43f5d..056266f9 100644 --- a/Source/HBIOS/ch376-native/base-drv/class_hub.c.s +++ b/Source/HBIOS/ch376-native/base-drv/class_hub.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- diff --git a/Source/HBIOS/ch376-native/base-drv/critical-section.c.s b/Source/HBIOS/ch376-native/base-drv/critical-section.c.s index 51f86184..62766348 100644 --- a/Source/HBIOS/ch376-native/base-drv/critical-section.c.s +++ b/Source/HBIOS/ch376-native/base-drv/critical-section.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- diff --git a/Source/HBIOS/ch376-native/base-drv/dev_transfers.c.s b/Source/HBIOS/ch376-native/base-drv/dev_transfers.c.s index 475fbd05..3060aa9c 100644 --- a/Source/HBIOS/ch376-native/base-drv/dev_transfers.c.s +++ b/Source/HBIOS/ch376-native/base-drv/dev_transfers.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -93,27 +93,31 @@ _usbdev_blk_out_trnsfer: push ix ld ix,0 add ix,sp - dec sp + push af + push af ;source-doc/base-drv/dev_transfers.c:30: */ ld e,(ix+4) ld d,(ix+5) - ld c, e - ld b, d - inc bc - inc bc - inc bc + ld hl,0x0003 + add hl, de + ex (sp), hl ;source-doc/base-drv/dev_transfers.c:32: return usb_control_transfer(cmd_packet, buffer, device->address, device->max_packet_size); - ld l, e - ld h, d - ld a, (hl) + ld (ix-2),e + ld (ix-1),d + pop bc + pop hl + ld a,(hl) + push hl + push bc rlca rlca rlca rlca and 0x0f - push bc push de - push bc + ld l,(ix-4) + ld h,(ix-3) + push hl push af inc sp ld l,(ix+8) @@ -128,56 +132,52 @@ _usbdev_blk_out_trnsfer: pop af inc sp pop de - pop bc ld a, l ld (_result), a ;source-doc/base-drv/dev_transfers.c:34: - ld a,(_result) + ld hl,_result + ld a, (hl) sub 0x02 jr NZ,l_usbdev_blk_out_trnsfer_00102 ;source-doc/base-drv/dev_transfers.c:35: usb_error usbdev_blk_out_trnsfer(device_config *const dev, const uint8_t *const buffer, const uint16_t buffer_size) { - ld l, e - ld h, d - inc hl - ld a, (hl) - ld (ix-1),a ex de, hl + inc hl + ld d, (hl) + ld l,(ix-2) + ld h,(ix-1) ld a, (hl) rlca rlca rlca rlca and 0x0f - ld d, a - ld l, c - ld h, b - ld a, (hl) + ld b, a + pop hl + ld a,(hl) + push hl rrca and 0x07 - push bc - ld h,(ix-1) - ld l,d - push hl + ld e,b + push de push af inc sp call _usbtrn_clear_endpoint_halt pop af inc sp - pop bc ;source-doc/base-drv/dev_transfers.c:36: - ld a, (bc) - and 0xfe - ld (bc), a + pop hl + push hl + res 0, (hl) ;source-doc/base-drv/dev_transfers.c:37: endpoint_param *const endpoint = &dev->endpoints[ENDPOINT_BULK_OUT]; ld l,0x02 jr l_usbdev_blk_out_trnsfer_00104 l_usbdev_blk_out_trnsfer_00102: ;source-doc/base-drv/dev_transfers.c:40: ;source-doc/base-drv/dev_transfers.c:43: endpoint->toggle = 0; - ld hl,(_result) + ld hl, (_result) l_usbdev_blk_out_trnsfer_00104: ;source-doc/base-drv/dev_transfers.c:44: return USB_ERR_STALL; - inc sp + ld sp, ix pop ix ret ;source-doc/base-drv/dev_transfers.c:46: @@ -188,25 +188,31 @@ _usbdev_bulk_in_transfer: push ix ld ix,0 add ix,sp - dec sp + push af + push af ;source-doc/base-drv/dev_transfers.c:47: RETURN_CHECK(result); - ld c,(ix+4) - ld b,(ix+5) + ld e,(ix+4) + ld d,(ix+5) ld hl,0x0006 - add hl, bc + add hl, de + ex (sp), hl ;source-doc/base-drv/dev_transfers.c:49: done: - ld e,c - ld d,b - ex de,hl - ld a, (hl) + ld (ix-2),e + ld (ix-1),d + pop bc + pop hl + ld a,(hl) + push hl + push bc rlca rlca rlca rlca and 0x0f - push bc - push de push de + ld l,(ix-4) + ld h,(ix-3) + push hl push af inc sp ld l,(ix+8) @@ -221,21 +227,19 @@ _usbdev_bulk_in_transfer: pop af inc sp pop de - pop bc ld a, l ld (_result), a ;source-doc/base-drv/dev_transfers.c:51: } - ld a,(_result) + ld hl,_result + ld a, (hl) sub 0x02 jr NZ,l_usbdev_bulk_in_transfer_00102 ;source-doc/base-drv/dev_transfers.c:52: - ld l, c - ld h, b + ex de, hl inc hl - ld a, (hl) - ld (ix-1),a - ld l, c - ld h, b + ld d, (hl) + ld l,(ix-2) + ld h,(ix-1) ld a, (hl) rlca rlca @@ -243,23 +247,21 @@ _usbdev_bulk_in_transfer: rlca and 0x0f ld b, a - ld l, e - ld h, d - ld a, (hl) + pop hl + ld a,(hl) + push hl rrca and 0x07 + ld e,b push de - ld h,(ix-1) - ld l,b - push hl push af inc sp call _usbtrn_clear_endpoint_halt pop af inc sp - pop de ;source-doc/base-drv/dev_transfers.c:53: usb_error usbdev_bulk_in_transfer(device_config *const dev, uint8_t *const buffer, uint8_t *const buffer_size) { - ex de, hl + pop hl + push hl res 0, (hl) ;source-doc/base-drv/dev_transfers.c:54: endpoint_param *const endpoint = &dev->endpoints[ENDPOINT_BULK_IN]; ld l,0x02 @@ -267,10 +269,10 @@ _usbdev_bulk_in_transfer: l_usbdev_bulk_in_transfer_00102: ;source-doc/base-drv/dev_transfers.c:57: ;source-doc/base-drv/dev_transfers.c:59: usbtrn_clear_endpoint_halt(endpoint->number, dev->address, dev->max_packet_size); - ld hl,(_result) + ld hl, (_result) l_usbdev_bulk_in_transfer_00104: ;source-doc/base-drv/dev_transfers.c:60: endpoint->toggle = 0; - inc sp + ld sp, ix pop ix ret ;source-doc/base-drv/dev_transfers.c:62: } @@ -281,7 +283,8 @@ _usbdev_dat_in_trnsfer: push ix ld ix,0 add ix,sp - dec sp + push af + push af ;source-doc/base-drv/dev_transfers.c:67: } ld e,(ix+4) ld d,(ix+5) @@ -297,22 +300,27 @@ _usbdev_dat_in_trnsfer: add a, e pop de add a, c - ld c, a + ld (ix-4),a ld a,0x00 adc a, b - ld b, a + ld (ix-3),a ;source-doc/base-drv/dev_transfers.c:69: usb_error usbdev_dat_in_trnsfer(device_config *const device, - ld l, e - ld h, d - ld a, (hl) + ld (ix-2),e + ld (ix-1),d + pop bc + pop hl + ld a,(hl) + push hl + push bc rlca rlca rlca rlca and 0x0f - push bc push de - push bc + ld l,(ix-4) + ld h,(ix-3) + push hl push af inc sp ld l,(ix+8) @@ -327,56 +335,52 @@ _usbdev_dat_in_trnsfer: pop af inc sp pop de - pop bc ld a, l ld (_result), a ;source-doc/base-drv/dev_transfers.c:71: const uint16_t buffer_size, - ld a,(_result) + ld hl,_result + ld a, (hl) sub 0x02 jr NZ,l_usbdev_dat_in_trnsfer_00102 ;source-doc/base-drv/dev_transfers.c:72: const usb_endpoint_type endpoint_type) { - ld l, e - ld h, d - inc hl - ld a, (hl) - ld (ix-1),a ex de, hl + inc hl + ld d, (hl) + ld l,(ix-2) + ld h,(ix-1) ld a, (hl) rlca rlca rlca rlca and 0x0f - ld d, a - ld l, c - ld h, b - ld a, (hl) + ld b, a + pop hl + ld a,(hl) + push hl rrca and 0x07 - push bc - ld h,(ix-1) - ld l,d - push hl + ld e,b + push de push af inc sp call _usbtrn_clear_endpoint_halt pop af inc sp - pop bc ;source-doc/base-drv/dev_transfers.c:73: - ld a, (bc) - and 0xfe - ld (bc), a + pop hl + push hl + res 0, (hl) ;source-doc/base-drv/dev_transfers.c:74: endpoint_param *const endpoint = &device->endpoints[endpoint_type]; ld l,0x02 jr l_usbdev_dat_in_trnsfer_00104 l_usbdev_dat_in_trnsfer_00102: ;source-doc/base-drv/dev_transfers.c:77: ;source-doc/base-drv/dev_transfers.c:79: usbtrn_clear_endpoint_halt(endpoint->number, device->address, device->max_packet_size); - ld hl,(_result) + ld hl, (_result) l_usbdev_dat_in_trnsfer_00104: ;source-doc/base-drv/dev_transfers.c:80: endpoint->toggle = 0; - inc sp + ld sp, ix pop ix ret ;source-doc/base-drv/dev_transfers.c:82: } @@ -388,6 +392,7 @@ _usbdev_dat_in_trnsfer_0: ld ix,0 add ix,sp push af + push af ;source-doc/base-drv/dev_transfers.c:83: ld e,(ix+4) ld d,(ix+5) @@ -395,9 +400,13 @@ _usbdev_dat_in_trnsfer_0: add hl, de ex (sp), hl ;source-doc/base-drv/dev_transfers.c:85: done: - ld l, e - ld h, d - ld a, (hl) + ld (ix-2),e + ld (ix-1),d + pop bc + pop hl + ld a,(hl) + push hl + push bc rlca rlca rlca @@ -406,8 +415,8 @@ _usbdev_dat_in_trnsfer_0: ld c,(ix+8) ld b,0x00 push de - ld l,(ix-2) - ld h,(ix-1) + ld l,(ix-4) + ld h,(ix-3) push hl push af inc sp @@ -424,29 +433,30 @@ _usbdev_dat_in_trnsfer_0: ld a, l ld (_result), a ;source-doc/base-drv/dev_transfers.c:87: } - ld a,(_result) + ld hl,_result + ld a, (hl) sub 0x02 jr NZ,l_usbdev_dat_in_trnsfer_0_00102 ;source-doc/base-drv/dev_transfers.c:88: - ld l, e - ld h, d - inc hl - ld b, (hl) ex de, hl + inc hl + ld d, (hl) + ld l,(ix-2) + ld h,(ix-1) ld a, (hl) rlca rlca rlca rlca and 0x0f - ld d, a + ld b, a pop hl ld a,(hl) push hl rrca and 0x07 - ld c, d - push bc + ld e,b + push de push af inc sp call _usbtrn_clear_endpoint_halt @@ -461,7 +471,7 @@ _usbdev_dat_in_trnsfer_0: jr l_usbdev_dat_in_trnsfer_0_00103 l_usbdev_dat_in_trnsfer_0_00102: ;source-doc/base-drv/dev_transfers.c:93: - ld hl,(_result) + ld hl, (_result) l_usbdev_dat_in_trnsfer_0_00103: ;source-doc/base-drv/dev_transfers.c:94: if (result == USB_ERR_STALL) { ld sp, ix diff --git a/Source/HBIOS/ch376-native/base-drv/enumerate.c.s b/Source/HBIOS/ch376-native/base-drv/enumerate.c.s index 37dc3d50..6a6c17c2 100644 --- a/Source/HBIOS/ch376-native/base-drv/enumerate.c.s +++ b/Source/HBIOS/ch376-native/base-drv/enumerate.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -99,7 +99,7 @@ _parse_endpoint_keyboard: inc bc ld a, d and 0x03 - ld l,a + ld l, a ld a, (bc) and 0xfc or l @@ -362,74 +362,77 @@ _configure_device: push af push af ;source-doc/base-drv/enumerate.c:79: dev_cfg->interface_number = interface->bInterfaceNumber; - ld a,(ix+8) - ld (ix-4),a - ld a,(ix+9) - ld (ix-3),a - pop bc - push bc - inc bc - inc bc - ld e,(ix+6) - ld d,(ix+7) + ld c,(ix+8) + ld b,(ix+9) + ld e, c + ld d, b inc de inc de - ld a, (de) - ld (bc), a + ld l,(ix+6) + ld h,(ix+7) + inc hl + inc hl + ld a, (hl) + ld (de), a ;source-doc/base-drv/enumerate.c:80: dev_cfg->max_packet_size = working->desc.bMaxPacketSize0; - ld a,(ix-4) - add a,0x01 - ld (ix-2),a - ld a,(ix-3) - adc a,0x00 - ld (ix-1),a - ld c,(ix+4) - ld b,(ix+5) - ld hl,10 - add hl,bc + ld hl,0x0001 + add hl, bc + ex (sp), hl + ld e,(ix+4) + ld d,(ix+5) + ld hl,0x000a + add hl,de ld a, (hl) - pop de pop hl push hl + ld (hl), a ;source-doc/base-drv/enumerate.c:81: dev_cfg->address = working->current_device_address; - ld (hl),a - push de - ld hl,0x0018 - add hl,bc + ld (ix-2),c + ld (ix-1),b + ld l, e + ld h, d + ld a,+((0x0018) & 0xFF) + add a,l + ld l,a + ld a,+((0x0018) / 256) + adc a,h + ld h,a ld a, (hl) + ld l,(ix-2) + ld h,(ix-1) add a, a add a, a add a, a add a, a - ld l, a - ld a, (de) + push bc + ld c, a + ld a, (hl) and 0x0f - or l - ld (de), a + or c + ld (hl), a + pop bc ;source-doc/base-drv/enumerate.c:82: dev_cfg->type = working->usb_device; - pop de - push de - ld l, c - ld h, b + ld l, e + ld h, d inc hl inc hl ld a, (hl) and 0x0f ld l, a - ld a, (de) + ld a, (bc) and 0xf0 or l - ld (de), a + ld (bc), a ;source-doc/base-drv/enumerate.c:84: return usbtrn_set_configuration(dev_cfg->address, dev_cfg->max_packet_size, working->config.desc.bConfigurationvalue); ld hl,36 - add hl, bc + add hl, de ld b, (hl) - ld l,(ix-2) - ld h,(ix-1) - ld d, (hl) pop hl - ld a,(hl) + ld d,(hl) push hl + ld l,(ix-2) + ld h,(ix-1) + ld a, (hl) rlca rlca rlca @@ -454,7 +457,6 @@ _op_capture_hub_driver_interfac: add ix,sp push af push af - push af dec sp ex de, hl ;source-doc/base-drv/enumerate.c:88: const interface_descriptor *const interface = (interface_descriptor *)working->ptr; @@ -463,22 +465,20 @@ _op_capture_hub_driver_interfac: ld a, (hl) dec hl ld l, (hl) - ld (ix-4),l - ld (ix-3),a + ld (ix-2),l + ld (ix-1),a ;source-doc/base-drv/enumerate.c:92: working->hub_config = &hub_config; ld hl,0x0019 add hl, de - ld (ix-2),l - ld (ix-1),h + ld c, l + ld b, h ld hl,0 add hl, sp - ld c, l - ld l,(ix-2) - ld b,h - ld h,(ix-1) - ld (hl), c - inc hl - ld (hl), b + ld a, l + ld (bc), a + inc bc + ld a, h + ld (bc), a ;source-doc/base-drv/enumerate.c:94: hub_config.type = USB_IS_HUB; ld hl,0 add hl, sp @@ -490,8 +490,8 @@ _op_capture_hub_driver_interfac: ld hl,2 add hl, sp push hl - ld l,(ix-4) - ld h,(ix-3) + ld l,(ix-2) + ld h,(ix-1) push hl push de call _configure_device @@ -524,7 +524,7 @@ _op_cap_drv_intf: add ix,sp ld c, l ld b, h - ld hl, -16 + ld hl, -14 add hl, sp ld sp, hl ;source-doc/base-drv/enumerate.c:104: const interface_descriptor *const interface = (interface_descriptor *)working->ptr; @@ -567,12 +567,12 @@ _op_cap_drv_intf: ;source-doc/base-drv/enumerate.c:108: working->p_current_device = NULL; ld a,(ix-2) add a,0x1d - ld (ix-4),a - ld l,a + ld e, a ld a,(ix-1) adc a,0x00 - ld (ix-3),a - ld h,a + ld d, a + ld l, e + ld h, d xor a ld (hl), a inc hl @@ -612,15 +612,12 @@ l_op_cap_drv_intf_00154: ;source-doc/base-drv/enumerate.c:119: working->p_current_device = &unkown_dev_cfg; ld hl,0 add hl, sp - ex de, hl - ld l,(ix-4) - ld h,(ix-3) - ld (hl), e - inc hl - ld (hl), d + ld a, l + ld (de), a + inc de + ld a, h + ld (de), a ;source-doc/base-drv/enumerate.c:120: CHECK(configure_device(working, interface, &unkown_dev_cfg)); - ld hl,0 - add hl, sp push hl push bc ld l,(ix-2) @@ -638,25 +635,26 @@ l_op_cap_drv_intf_00154: l_op_cap_drv_intf_00107: ;source-doc/base-drv/enumerate.c:125: device_config *dev_cfg = find_first_free(); push bc + push de call _find_first_free -;source-doc/base-drv/enumerate.c:126: if (dev_cfg == NULL) + pop de pop bc - ld a,h +;source-doc/base-drv/enumerate.c:126: if (dev_cfg == NULL) + ld a, h or l - ex de,hl jr NZ,l_op_cap_drv_intf_00109 ;source-doc/base-drv/enumerate.c:127: return USB_ERR_OUT_OF_MEMORY; ld l,0x83 jr l_op_cap_drv_intf_00114 l_op_cap_drv_intf_00109: ;source-doc/base-drv/enumerate.c:128: working->p_current_device = dev_cfg; - ld l,(ix-4) - ld h,(ix-3) - ld (hl), e - inc hl - ld (hl), d + ld a, l + ld (de), a + inc de + ld a, h + ld (de), a ;source-doc/base-drv/enumerate.c:129: CHECK(configure_device(working, interface, dev_cfg)); - push de + push hl push bc ld l,(ix-2) ld h,(ix-1) @@ -690,34 +688,32 @@ l_op_cap_drv_intf_00114: _op_id_class_drv: ex de, hl ;source-doc/base-drv/enumerate.c:141: const interface_descriptor *const ptr = (const interface_descriptor *)working->ptr; - ld hl,0x001c + ld hl,27 add hl,de - ld a, (hl) - dec hl - ld l, (hl) + ld c, (hl) + inc hl + ld b, (hl) ;source-doc/base-drv/enumerate.c:143: working->usb_device = ptr->bLength > 5 ? identify_class_driver(working) : 0; - ld c, e - ld b, d - inc bc - inc bc - ld h, a - ld l, (hl) - ld a,0x05 - sub l - jr NC,l_op_id_class_drv_00103 - push bc + ld l, e + ld h, d + inc hl + inc hl + ld a, (bc) + cp 0x06 + jr C,l_op_id_class_drv_00103 + push hl push de push de call _identify_class_driver pop af ld a, l pop de - pop bc + pop hl jr l_op_id_class_drv_00104 l_op_id_class_drv_00103: xor a l_op_id_class_drv_00104: - ld (bc), a + ld (hl), a ;source-doc/base-drv/enumerate.c:145: return op_cap_drv_intf(working); ex de, hl call _op_cap_drv_intf @@ -732,13 +728,13 @@ _op_get_cfg_desc: push ix ld ix,0 add ix,sp - push af - ex de, hl + dec sp + ld c, l + ld b, h ;source-doc/base-drv/enumerate.c:149: memset(working->config.buffer, 0, MAX_CONFIG_SIZE); ld hl,0x001f - add hl, de - pop af - push hl + add hl, bc + push bc ld b,0x46 l_op_get_cfg_desc_00113: xor a @@ -747,88 +743,77 @@ l_op_get_cfg_desc_00113: ld (hl), a inc hl djnz l_op_get_cfg_desc_00113 + pop bc ;source-doc/base-drv/enumerate.c:151: const uint8_t max_packet_size = working->desc.bMaxPacketSize0; - ld c, e - ld b, d - inc bc - inc bc - inc bc - ld hl,7 - add hl, bc + ld e,c + ld d,b + ld hl,10 + add hl,bc ld a, (hl) + ld (ix-1),a ;source-doc/base-drv/enumerate.c:154: working->config.buffer)); - ld c, e - ld b, d - ld hl,24 + ld hl,0x001f add hl, bc - ld b, (hl) - ld l, e - ld h, d + ex de, hl + ld hl,0x0018 + add hl,bc + ld a, (hl) + ld hl,0x0015 + add hl,bc + ld h, (hl) push bc - ld bc,0x0015 - add hl, bc - pop bc - ld c, (hl) push de - ld l,(ix-2) - ld h,(ix-1) - push hl - ld h,0x8c - ld l,a + ld d,0x8c + push de + inc sp + ld d,(ix-1) + push de + inc sp + ld l,h + ld h,a push hl - push bc call _usbtrn_gfull_cfg_desc pop af pop af pop af - pop de + pop bc ld a, l ld (_result), a - ld a,(_result) + ld hl,_result + ld a, (hl) or a jr NZ,l_op_get_cfg_desc_00103 ;source-doc/base-drv/enumerate.c:156: working->ptr = (working->config.buffer + sizeof(config_descriptor)); ld hl,0x001b - add hl, de - ld a, e - add a,0x1f - ld c, a - ld a, d - adc a,0x00 - ld b, a + add hl, bc ld a, c - add a,0x09 - ld c, a + add a,0x28 + ld e, a ld a, b adc a,0x00 - ld (hl), c + ld (hl), e inc hl ld (hl), a ;source-doc/base-drv/enumerate.c:157: working->interface_count = working->config.desc.bNumInterfaces; ld hl,0x0016 - add hl, de - ld c, l - ld b, h - pop hl - push hl - inc hl - inc hl - inc hl - inc hl + add hl, bc + ex de, hl + ld hl,0x0023 + add hl,bc ld a, (hl) - ld (bc), a + ld (de), a ;source-doc/base-drv/enumerate.c:159: return op_id_class_drv(working); - ex de, hl + ld l, c + ld h, b call _op_id_class_drv jr l_op_get_cfg_desc_00104 ;source-doc/base-drv/enumerate.c:160: done: l_op_get_cfg_desc_00103: ;source-doc/base-drv/enumerate.c:161: return result; - ld hl,_result - ld a, (hl) + ld a, (_result) l_op_get_cfg_desc_00104: ;source-doc/base-drv/enumerate.c:162: } - ld sp, ix + inc sp pop ix ret ;source-doc/base-drv/enumerate.c:164: usb_error read_all_configs(enumeration_state *const state) { @@ -845,44 +830,56 @@ _read_all_configs: ;source-doc/base-drv/enumerate.c:169: memset(&working, 0, sizeof(_working)); ld hl,0 add hl, sp + ld e,l + ld d,h + ld b,0x56 + jr l_read_all_configs_00150 +l_read_all_configs_00149: ld (hl),0x00 - ld e, l - ld d, h - inc de - ld bc,0x00aa - ldir + inc hl +l_read_all_configs_00150: + ld (hl),0x00 + inc hl + djnz l_read_all_configs_00149 ;source-doc/base-drv/enumerate.c:170: working.state = state; + ld l, e + ld h, d ld a,(ix+4) - ld hl,0 - add hl, sp ld (hl), a - ld a,(ix+5) inc hl + ld a,(ix+5) ld (hl), a ;source-doc/base-drv/enumerate.c:172: CHECK(usbtrn_get_descriptor(&working.desc)); - ld hl,3 + push de + ld hl,5 add hl, sp push hl call _usbtrn_get_descriptor pop af ld a, l + pop de or a jr NZ,l_read_all_configs_00108 ;source-doc/base-drv/enumerate.c:174: state->next_device_address++; - ld e,(ix+4) - ld d,(ix+5) - ld a, (de) - inc a - ld c,a - ld (de), a + ld b,(ix+5) + ld a,(ix+4) + ld l, a + ld h, b + ld c, (hl) + inc c + ld l, a + ld h, b + ld (hl), c ;source-doc/base-drv/enumerate.c:175: working.current_device_address = state->next_device_address; - ld hl,24 - add hl, sp + ld hl,0x0018 + add hl, de ld (hl), c ;source-doc/base-drv/enumerate.c:176: CHECK(usbtrn_set_address(working.current_device_address)); + push de ld l, c call _usbtrn_set_address ld a, l + pop de ;source-doc/base-drv/enumerate.c:178: for (uint8_t config_index = 0; config_index < working.desc.bNumConfigurations; config_index++) { or a jr NZ,l_read_all_configs_00108 @@ -895,13 +892,16 @@ l_read_all_configs_00110: sub b jr NC,l_read_all_configs_00107 ;source-doc/base-drv/enumerate.c:179: working.config_index = config_index; - inc hl + ld hl,0x0015 + add hl, de ld (hl), c ;source-doc/base-drv/enumerate.c:181: CHECK(op_get_cfg_desc(&working)); + ld l, e + ld h, d push bc - ld hl,2 - add hl, sp + push de call _op_get_cfg_desc + pop de pop bc or a jr NZ,l_read_all_configs_00108 @@ -934,22 +934,23 @@ _enumerate_all_devices: add hl, sp ld e,l ld d,h + ld (hl),0x00 ;source-doc/base-drv/enumerate.c:193: state.next_device_address = 0; + ld c, e + ld b, d xor a - ld (hl),a - ld (de), a + ld (bc), a ;source-doc/base-drv/enumerate.c:195: usb_error result = read_all_configs(&state); - push de + push bc push de call _read_all_configs pop af - ld c, l - pop de + pop bc ;source-doc/base-drv/enumerate.c:197: work_area->count_of_detected_usb_devices = state.next_device_address; - ld a, (de) - ld ((_x + 1)),a + ld de,_x + 1 + ld a, (bc) + ld (de), a ;source-doc/base-drv/enumerate.c:200: return result; - ld l, c ;source-doc/base-drv/enumerate.c:201: } inc sp pop ix diff --git a/Source/HBIOS/ch376-native/base-drv/enumerate_hub.c.s b/Source/HBIOS/ch376-native/base-drv/enumerate_hub.c.s index 0fc01bd3..958d7061 100644 --- a/Source/HBIOS/ch376-native/base-drv/enumerate_hub.c.s +++ b/Source/HBIOS/ch376-native/base-drv/enumerate_hub.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -190,35 +190,37 @@ _hub_get_status_port: ;source-doc/base-drv/enumerate_hub.c:33: get_status_port = cmd_get_status_port; ld hl,0 add hl, sp - ex de, hl + ld e,l + ld d,h + push hl ld bc,0x0008 ld hl,_cmd_get_status_port ldir + pop bc ;source-doc/base-drv/enumerate_hub.c:35: get_status_port.bIndex[0] = index; ld a,(ix+6) ld (ix-4),a ;source-doc/base-drv/enumerate_hub.c:36: return usb_control_transfer(&get_status_port, port_status, hub_config->address, hub_config->max_packet_size); - ld l,(ix+4) - ld h,(ix+5) - ld e,l - ld d,h + ld e,(ix+5) + ld a,(ix+4) + ld l, a + ld h, e inc hl - ld b, (hl) - ex de, hl + ld d, (hl) + ld l, a + ld h, e ld a, (hl) rlca rlca rlca rlca and 0x0f - ld e,(ix+7) - ld d,(ix+8) - ld c,a - push bc + ld l,(ix+7) + ld h,(ix+8) + ld e,a push de - ld hl,4 - add hl, sp push hl + push bc call _usb_control_transfer ;source-doc/base-drv/enumerate_hub.c:37: } ld sp,ix diff --git a/Source/HBIOS/ch376-native/base-drv/enumerate_storage.c.s b/Source/HBIOS/ch376-native/base-drv/enumerate_storage.c.s index 72982a22..d8e57ed5 100644 --- a/Source/HBIOS/ch376-native/base-drv/enumerate_storage.c.s +++ b/Source/HBIOS/ch376-native/base-drv/enumerate_storage.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -133,7 +133,7 @@ l_parse_endpoints_00107: inc de ld a, b and 0x03 - ld l,a + ld l, a ld a, (de) and 0xfc or l diff --git a/Source/HBIOS/ch376-native/base-drv/protocol.c.s b/Source/HBIOS/ch376-native/base-drv/protocol.c.s index c63f157d..c22b7e5e 100644 --- a/Source/HBIOS/ch376-native/base-drv/protocol.c.s +++ b/Source/HBIOS/ch376-native/base-drv/protocol.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -73,9 +73,10 @@ _usbtrn_get_descriptor: ;source-doc/base-drv/protocol.c:30: setup_packet cmd; ld c,(ix+4) ld b,(ix+5) - ld e, c - ld d, b push bc + push bc + ld e,c + ld d,b ld a,0x08 push af inc sp @@ -83,13 +84,14 @@ _usbtrn_get_descriptor: push af inc sp push de - ld hl,6 + ld hl,8 add hl, sp push hl call _usb_control_transfer pop af pop af pop af + pop de pop bc ld a, l ld (_result), a @@ -98,30 +100,30 @@ _usbtrn_get_descriptor: or a jr NZ,l_usbtrn_get_descriptor_00103 ;source-doc/base-drv/protocol.c:34: result = usb_control_transfer(&cmd, (uint8_t *)buffer, 0, 8); - ld hl,0 + push de + push bc + ld hl,4 add hl, sp ex de, hl - push bc ld bc,0x0008 ld hl,_cmd_get_device_descriptor ldir pop bc + pop de ;source-doc/base-drv/protocol.c:35: ld (ix-2),0x12 xor a ld (ix-1),a ;source-doc/base-drv/protocol.c:36: CHECK(result); - ld e,(ix+4) - ld d,(ix+5) ld hl,7 - add hl, de + add hl, bc ld a, (hl) push af inc sp xor a push af inc sp - push bc + push de ld hl,4 add hl, sp push hl @@ -135,7 +137,7 @@ _usbtrn_get_descriptor: ;source-doc/base-drv/protocol.c:40: result = usb_control_transfer(&cmd, (uint8_t *)buffer, 0, buffer->bMaxPacketSize0); l_usbtrn_get_descriptor_00103: ;source-doc/base-drv/protocol.c:41: - ld hl,(_result) + ld hl, (_result) ;source-doc/base-drv/protocol.c:42: RETURN_CHECK(result); ld sp, ix pop ix @@ -173,20 +175,22 @@ _usbtrn_get_descriptor2: ;source-doc/base-drv/protocol.c:51: * @param buffer the buffer to store the device descriptor in ld c,(ix+4) ld b,(ix+5) - ld e, c - ld d, b push bc + push bc + ld e,c + ld d,b ld h,0x08 ld l,(ix+6) push hl push de - ld hl,6 + ld hl,8 add hl, sp push hl call _usb_control_transfer pop af pop af pop af + pop de pop bc ld a, l ld (_result), a @@ -195,27 +199,27 @@ _usbtrn_get_descriptor2: or a jr NZ,l_usbtrn_get_descriptor2_00103 ;source-doc/base-drv/protocol.c:55: setup_packet cmd; - ld hl,0 + push de + push bc + ld hl,4 add hl, sp ex de, hl - push bc ld bc,0x0008 ld hl,_cmd_get_device_descriptor ldir pop bc + pop de ;source-doc/base-drv/protocol.c:56: cmd = cmd_get_device_descriptor; ld (ix-2),0x12 xor a ld (ix-1),a ;source-doc/base-drv/protocol.c:57: cmd.wLength = 8; - ld e,(ix+4) - ld d,(ix+5) ld hl,7 - add hl, de + add hl, bc ld h,(hl) ld l,(ix+6) push hl - push bc + push de ld hl,4 add hl, sp push hl @@ -228,7 +232,7 @@ _usbtrn_get_descriptor2: ;source-doc/base-drv/protocol.c:58: l_usbtrn_get_descriptor2_00103: ;source-doc/base-drv/protocol.c:59: result = usb_control_transfer(&cmd, (uint8_t *)buffer, device_address, 8); - ld hl,(_result) + ld hl, (_result) ;source-doc/base-drv/protocol.c:60: ld sp, ix pop ix @@ -247,10 +251,10 @@ _usbtrn_set_address: push af ld c, l ;source-doc/base-drv/protocol.c:68: } - ld hl,0 + push bc + ld hl,2 add hl, sp ex de, hl - push bc ld bc,0x0008 ld hl,_cmd_set_device_address ldir @@ -351,9 +355,13 @@ _usbtrn_get_config_descriptor: ld a,(ix+6) ld (ix-6),a ;source-doc/base-drv/protocol.c:98: + ld hl,0x0006 + add hl, bc ld e,(ix+7) - ld (ix-2),e - ld (ix-1),0x00 + xor a + ld (hl), e + inc hl + ld (hl), a ;source-doc/base-drv/protocol.c:100: } ld e,(ix+4) ld d,(ix+5) @@ -408,8 +416,8 @@ _usbtrn_gfull_cfg_desc: or a jr NZ,l_usbtrn_gfull_cfg_desc_00107 ;source-doc/base-drv/protocol.c:112: * @return usb_error USB_ERR_OK if all good, otherwise specific error code - ld l, c - ld h, b + ld l,(ix+8) + ld h,(ix+9) inc hl inc hl ld d, (hl) @@ -442,7 +450,7 @@ l_usbtrn_gfull_cfg_desc_00104: ;source-doc/base-drv/protocol.c:119: setup_packet cmd; l_usbtrn_gfull_cfg_desc_00107: ;source-doc/base-drv/protocol.c:120: cmd = cmd_get_config_descriptor; - ld hl,(_result) + ld hl, (_result) l_usbtrn_gfull_cfg_desc_00108: ;source-doc/base-drv/protocol.c:121: cmd.bValue[0] = config_index; pop ix diff --git a/Source/HBIOS/ch376-native/base-drv/transfers.c.s b/Source/HBIOS/ch376-native/base-drv/transfers.c.s index 0cf7ef14..47e2cfb1 100644 --- a/Source/HBIOS/ch376-native/base-drv/transfers.c.s +++ b/Source/HBIOS/ch376-native/base-drv/transfers.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -120,7 +120,7 @@ _usb_control_transfer: inc hl ld a, b and 0x03 - ld e,a + ld e, a ld a, (hl) and 0xfc or e @@ -144,6 +144,7 @@ l_usb_control_transfer_00102: ;source-doc/base-drv/transfers.c:50: const uint8_t max_packet_size) { push bc call _critical_begin +;source-doc/base-drv/transfers.c:52: endpoint_param endpoint = {1, 0, max_packet_size}; ld l,(ix+8) call _ch_set_usb_address pop bc @@ -158,7 +159,9 @@ l_usb_control_transfer_00102: call _ch_write_data pop af inc sp +;source-doc/base-drv/transfers.c:55: call _ch_issue_token_setup +;source-doc/base-drv/transfers.c:56: if (transferIn && buffer == 0) call _ch_short_wait_int_and_get_stat pop bc ;source-doc/base-drv/transfers.c:57: return USB_ERR_OTHER; @@ -175,13 +178,13 @@ l_usb_control_transfer_00102: ld b,a or c jr Z,l_usb_control_transfer_00116 + ld hl,0 + add hl, sp ld e,(ix+6) ld d,(ix+7) ld a,(ix-1) or a jr Z,l_usb_control_transfer_00118 - ld hl,0 - add hl, sp push hl push bc push de @@ -191,8 +194,6 @@ l_usb_control_transfer_00102: pop af jr l_usb_control_transfer_00119 l_usb_control_transfer_00118: - ld hl,0 - add hl, sp push hl push bc push de @@ -220,7 +221,7 @@ l_usb_control_transfer_00117: ;source-doc/base-drv/transfers.c:69: ld a,0x00 ld bc,_CH376_DATA_PORT - out (c),a + out (c), a ;source-doc/base-drv/transfers.c:70: result = length != 0 call _ch_issue_token_out_ep0 ;source-doc/base-drv/transfers.c:71: ? (transferIn ? ch_data_in_transfer(buffer, length, &endpoint) : ch_data_out_transfer(buffer, length, &endpoint)) @@ -392,7 +393,7 @@ _usb_data_in_transfer: ;source-doc/base-drv/transfers.c:126: * @brief Perform a USB data in on the specififed endpoint call _critical_end ;source-doc/base-drv/transfers.c:128: * @param buffer the buffer to receive the data - ld hl,(_result) + ld hl, (_result) ;source-doc/base-drv/transfers.c:129: * @param buffer_size the maximum size of data to be received pop ix ret @@ -428,7 +429,7 @@ _usb_data_in_transfer_n: ;source-doc/base-drv/transfers.c:141: call _critical_end ;source-doc/base-drv/transfers.c:143: - ld hl,(_result) + ld hl, (_result) ;source-doc/base-drv/transfers.c:144: return result; pop ix ret @@ -464,7 +465,7 @@ _usb_data_out_transfer: ;source-doc/base-drv/transfers.c:156: usb_error call _critical_end ;source-doc/base-drv/transfers.c:158: critical_begin(); - ld hl,(_result) + ld hl, (_result) ;source-doc/base-drv/transfers.c:159: pop ix ret diff --git a/Source/HBIOS/ch376-native/base-drv/usb-base-drv.c.s b/Source/HBIOS/ch376-native/base-drv/usb-base-drv.c.s index bdc2d537..314f6d9f 100644 --- a/Source/HBIOS/ch376-native/base-drv/usb-base-drv.c.s +++ b/Source/HBIOS/ch376-native/base-drv/usb-base-drv.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -56,20 +56,18 @@ _storage_count: ; --------------------------------- _chnative_seek: push ix -;source-doc/base-drv/usb-base-drv.c:7: storage_device->current_lba = lba; ld ix,0 add ix,sp - ld c,(ix+4) - ld b,(ix+5) - push bc - ld a,(ix-2) + ld c, l + ld b, h +;source-doc/base-drv/usb-base-drv.c:7: storage_device->current_lba = lba; + ld h,(ix+5) + ld a,(ix+4) add a,0x0c - ld c,l - ld b,h ld l, a - ld a,(ix-1) - adc a,0x00 - ld h, a + jr NC,l_chnative_seek_00103 + inc h +l_chnative_seek_00103: ld (hl), e inc hl ld (hl), d @@ -80,7 +78,6 @@ _chnative_seek: ;source-doc/base-drv/usb-base-drv.c:8: return 0; xor a ;source-doc/base-drv/usb-base-drv.c:9: } - ld sp, ix pop ix pop hl pop bc diff --git a/Source/HBIOS/ch376-native/base-drv/usb-init.c.s b/Source/HBIOS/ch376-native/base-drv/usb-init.c.s index d4e25782..90f05110 100644 --- a/Source/HBIOS/ch376-native/base-drv/usb-init.c.s +++ b/Source/HBIOS/ch376-native/base-drv/usb-init.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -74,11 +74,11 @@ _usb_host_bus_reset: ;source-doc/base-drv/ch376.h:111: ld a,0x25 ld bc,_CH376_DATA_PORT - out (c),a + out (c), a ;source-doc/base-drv/ch376.h:112: #define calc_max_packet_sizex(packet_size) (packet_size & 0x3FF) ld a,0xdf ld bc,_CH376_DATA_PORT - out (c),a + out (c), a ;source-doc/base-drv/usb-init.c:20: return USB_ERR_OK; ld l,0x00 ;source-doc/base-drv/usb-init.c:21: } @@ -103,7 +103,7 @@ __chnative_init: ;source-doc/base-drv/usb-init.c:28: USB_MODULE_LEDS = 0x00; ld a,0x00 ld bc,_USB_MODULE_LEDS - out (c),a + out (c), a ;source-doc/base-drv/usb-init.c:30: ch_cmd_reset_all(); call _ch_cmd_reset_all ;source-doc/base-drv/usb-init.c:32: delay_medium(); @@ -128,7 +128,7 @@ l__chnative_init_00104: ;source-doc/base-drv/usb-init.c:39: USB_MODULE_LEDS = 0x00; ld a,0x00 ld bc,_USB_MODULE_LEDS - out (c),a + out (c), a ;source-doc/base-drv/usb-init.c:40: print_string("\b $"); ld hl,usb_init_str_1 call _print_string @@ -137,7 +137,7 @@ l__chnative_init_00102: ;source-doc/base-drv/usb-init.c:42: USB_MODULE_LEDS = 0x03; ld a,0x03 ld bc,_USB_MODULE_LEDS - out (c),a + out (c), a ;source-doc/base-drv/usb-init.c:43: print_string("\b*$"); ld hl,usb_init_str_2 call _print_string @@ -162,7 +162,7 @@ l__chnative_init_00110: or a jr NZ,l__chnative_init_00108 ld bc,_USB_MODULE_LEDS - out (c),a + out (c), a ;source-doc/base-drv/usb-init.c:54: print_string("\r\nCH376: NOT PRESENT$"); ld hl,usb_init_str_4 call _print_string @@ -176,7 +176,7 @@ l__chnative_init_00111: ;source-doc/base-drv/usb-init.c:61: USB_MODULE_LEDS = 0x01; ld a,0x01 ld bc,_USB_MODULE_LEDS - out (c),a + out (c), a ;source-doc/base-drv/usb-init.c:63: print_hex(ch_cmd_get_ic_version()); call _ch_cmd_get_ic_version call _print_hex @@ -190,21 +190,14 @@ l__chnative_init_00111: l__chnative_init_00116: bit 0,(ix+4) jr Z,l__chnative_init_00120 - ld de,0x000a + ld b,0x0a jr l__chnative_init_00121 l__chnative_init_00120: - ld de,0x0005 + ld b,0x05 l__chnative_init_00121: - ld b, c - ld l,0x00 - ld a, b - sub e - ld a, l - sbc a, d - jp PO, l__chnative_init_00185 - xor 0x80 -l__chnative_init_00185: - jp P, l__chnative_init_00114 + ld a, c + sub b + jr NC,l__chnative_init_00114 ;source-doc/base-drv/usb-init.c:69: const uint8_t r = ch_very_short_wait_int_and_get_(); push bc call _ch_very_short_wait_int_and_get @@ -221,7 +214,7 @@ l__chnative_init_00185: ;source-doc/base-drv/usb-init.c:76: USB_MODULE_LEDS = 0x03; ld a,0x03 ld bc,_USB_MODULE_LEDS - out (c),a + out (c), a ;source-doc/base-drv/usb-init.c:77: return; jr l__chnative_init_00118 l__chnative_init_00117: @@ -232,7 +225,7 @@ l__chnative_init_00114: ;source-doc/base-drv/usb-init.c:81: USB_MODULE_LEDS = 0x00; ld a,0x00 ld bc,_USB_MODULE_LEDS - out (c),a + out (c), a ;source-doc/base-drv/usb-init.c:82: print_string("USB: DISCONNECTED$"); ld hl,usb_init_str_8 call _print_string diff --git a/Source/HBIOS/ch376-native/base-drv/usb_state.c.s b/Source/HBIOS/ch376-native/base-drv/usb_state.c.s index 62bea257..e494fb01 100644 --- a/Source/HBIOS/ch376-native/base-drv/usb_state.c.s +++ b/Source/HBIOS/ch376-native/base-drv/usb_state.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -70,10 +70,8 @@ l_find_device_config_00103: ld h, d ld a, (hl) and 0x0f - ld c, a ;source-doc/base-drv/usb_state.c:20: if (type == requested_type) - ld a,(ix+4) - sub c + sub (ix+4) jr NZ,l_find_device_config_00102 ;source-doc/base-drv/usb_state.c:21: return (device_config *)p_config; ex de, hl @@ -168,12 +166,14 @@ l_next_device_config_00102: ld a,0x00 adc a, +((_device_config_sizes) / 256) ld h, a - ld l, (hl) + ld a, (hl) ;source-doc/base-drv/usb_state.c:58: const uint8_t *_p = (uint8_t *)p; ;source-doc/base-drv/usb_state.c:59: device_config *const result = (device_config *)(_p + size); - ld h,0x00 - add hl, de - ex de, hl + add a, e + ld e, a + ld a,0x00 + adc a, d + ld d, a ;source-doc/base-drv/usb_state.c:61: if (result >= (device_config *)&usb_state->device_configs_end) ld hl,0x0068 add hl, bc diff --git a/Source/HBIOS/ch376-native/base-drv/work-area.c.s b/Source/HBIOS/ch376-native/base-drv/work-area.c.s index adb9c88a..0449816b 100644 --- a/Source/HBIOS/ch376-native/base-drv/work-area.c.s +++ b/Source/HBIOS/ch376-native/base-drv/work-area.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- diff --git a/Source/HBIOS/ch376-native/keyboard/class_hid.c.s b/Source/HBIOS/ch376-native/keyboard/class_hid.c.s index a893b7fd..f53b35a5 100644 --- a/Source/HBIOS/ch376-native/keyboard/class_hid.c.s +++ b/Source/HBIOS/ch376-native/keyboard/class_hid.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -62,6 +62,7 @@ _hid_set_protocol: push af ;source-doc/keyboard/class_hid.c:8: cmd = cmd_hid_set; push hl + ex de,hl ld hl,2 add hl, sp ex de, hl @@ -126,6 +127,7 @@ _hid_set_idle: push af ;source-doc/keyboard/class_hid.c:18: cmd = cmd_hid_set; push hl + ex de,hl ld hl,2 add hl, sp ex de, hl diff --git a/Source/HBIOS/ch376-native/keyboard/class_hid_keyboard.c.s b/Source/HBIOS/ch376-native/keyboard/class_hid_keyboard.c.s index 44aa6d22..0c16292f 100644 --- a/Source/HBIOS/ch376-native/keyboard/class_hid_keyboard.c.s +++ b/Source/HBIOS/ch376-native/keyboard/class_hid_keyboard.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -184,16 +184,14 @@ l_scancode_to_char_00120: ld d,0x00 ld hl,_scancodes_shift_table add hl, de - ld a,(hl) - ld c,a + ld a, (hl) jp _char_with_caps_lock l_scancode_to_char_00122: ;source-doc/keyboard/class_hid_keyboard.c:380: return char_with_caps_lock(scancodes_shift_table[code]); ld d,0x00 ld hl,_scancodes_table add hl, de - ld a,(hl) - ld c,a + ld a, (hl) jp _char_with_caps_lock l_scancode_to_char_00123: ;source-doc/keyboard/class_hid_keyboard.c:381: diff --git a/Source/HBIOS/ch376-native/keyboard/kyb-init.c.s b/Source/HBIOS/ch376-native/keyboard/kyb-init.c.s index 9a558c3b..e7fed9b8 100644 --- a/Source/HBIOS/ch376-native/keyboard/kyb-init.c.s +++ b/Source/HBIOS/ch376-native/keyboard/kyb-init.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -173,8 +173,8 @@ l_keyboard_buf_put_00110: ld b,0x00 ld hl,_previous_keyCodes add hl, bc - ld a,(ix+5) - sub (hl) + ld a, (hl) + sub (ix+5) ;source-doc/keyboard/kyb-init.c:57: if (previous_keyCodes[i] == key_code) jr Z,l_keyboard_buf_put_00112 ;source-doc/keyboard/kyb-init.c:55: // if already reported, just skip it @@ -182,7 +182,7 @@ l_keyboard_buf_put_00110: jr l_keyboard_buf_put_00110 l_keyboard_buf_put_00106: ;source-doc/keyboard/kyb-init.c:59: - ld a,(_write_index) + ld a, (_write_index) inc a and 0x07 ld c, a @@ -192,21 +192,20 @@ l_keyboard_buf_put_00106: jr Z,l_keyboard_buf_put_00112 ;source-doc/keyboard/kyb-init.c:61: if (next_write_index != read_index) { // Check if buffer is not full ld de,_buffer+0 - ld hl,(_write_index) + ld hl, (_write_index) ld h,0x00 add hl, hl add hl, de ld a,(ix+4) ld (hl), a ;source-doc/keyboard/kyb-init.c:62: buffer[write_index].modifier_keys = modifier_keys; - ld hl,(_write_index) + ld hl, (_write_index) ld h,0x00 add hl, hl add hl, de - ex de, hl - inc de + inc hl ld a,(ix+5) - ld (de), a + ld (hl), a ;source-doc/keyboard/kyb-init.c:63: buffer[write_index].key_code = key_code; ld hl,_write_index ld (hl), c @@ -231,13 +230,11 @@ _keyboard_buf_size: jr l_keyboard_buf_size_00103 l_keyboard_buf_size_00102: ;source-doc/keyboard/kyb-init.c:71: - ld hl,_read_index - ld c, (hl) + ld hl, (_read_index) ld a,0x08 - sub c - ld hl,_write_index - ld c, (hl) - add a, c + sub l + ld hl, (_write_index) + add a, l l_keyboard_buf_size_00103: ;source-doc/keyboard/kyb-init.c:72: return KEYBOARD_BUFFER_SIZE - read_index + write_index; ret @@ -264,7 +261,7 @@ _keyboard_buf_get_next: l_keyboard_buf_get_next_00102: ;source-doc/keyboard/kyb-init.c:78: ld bc,_buffer+0 - ld hl,(_read_index) + ld hl, (_read_index) ld h,0x00 add hl, hl add hl, bc @@ -273,11 +270,10 @@ l_keyboard_buf_get_next_00102: inc hl ld c, (hl) ;source-doc/keyboard/kyb-init.c:80: const uint8_t key_code = buffer[read_index].key_code; - ld hl,_read_index - ld a, (hl) + ld a, (_read_index) inc a and 0x07 - ld (hl), a + ld (_read_index),a ;source-doc/keyboard/kyb-init.c:82: ld a, c sub 0x39 @@ -325,11 +321,10 @@ l_keyboard_buf_get_next_00105: ; --------------------------------- _keyboard_buf_flush: ;source-doc/keyboard/kyb-init.c:93: void keyboard_buf_flush() { - ld hl,_write_index - ld (hl),0x00 ;source-doc/keyboard/kyb-init.c:94: write_index = 0; - ld hl,_read_index - ld (hl),0x00 + xor a + ld (_write_index),a + ld (_read_index),a ;source-doc/keyboard/kyb-init.c:95: read_index = 0; ret ;source-doc/keyboard/kyb-init.c:101: @@ -349,13 +344,13 @@ _keyboard_tick: ;././source-doc/base-drv//ch376.h:111: ld a,0x25 ld bc,_CH376_DATA_PORT - out (c),a + out (c), a ;././source-doc/base-drv//ch376.h:112: #define calc_max_packet_sizex(packet_size) (packet_size & 0x3FF) ld a,0x1f ld bc,_CH376_DATA_PORT - out (c),a + out (c), a ;source-doc/keyboard/kyb-init.c:106: ch_configure_nak_retry_disable(); - ld bc,_report+0 + ld bc,_report ld hl, (_keyboard_config) ld a,0x08 push af @@ -374,11 +369,11 @@ _keyboard_tick: ;././source-doc/base-drv//ch376.h:111: ld a,0x25 ld bc,_CH376_DATA_PORT - out (c),a + out (c), a ;././source-doc/base-drv//ch376.h:112: #define calc_max_packet_sizex(packet_size) (packet_size & 0x3FF) ld a,0xdf ld bc,_CH376_DATA_PORT - out (c),a + out (c), a ;source-doc/keyboard/kyb-init.c:108: ch_configure_nak_retry_3s(); ld hl,_result ld a, (hl) diff --git a/Source/HBIOS/ch376-native/scsi-drv/class_scsi.c.s b/Source/HBIOS/ch376-native/scsi-drv/class_scsi.c.s index b921d313..672829ab 100644 --- a/Source/HBIOS/ch376-native/scsi-drv/class_scsi.c.s +++ b/Source/HBIOS/ch376-native/scsi-drv/class_scsi.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -70,7 +70,7 @@ _do_scsi_cmd: push ix ld ix,0 add ix,sp - ld hl, -6 + ld hl, -8 add hl, sp ld sp, hl ;source-doc/scsi-drv/class_scsi.c:17: cbw->dCBWTag[0] = next_tag++; @@ -79,7 +79,10 @@ _do_scsi_cmd: ld hl,0x0004 add hl, bc ex (sp), hl - ld de,(_next_tag) + ld a, (_next_tag) + ld e, a + ld hl,_next_tag + 1 + ld d, (hl) ld hl, (_next_tag) inc hl ld (_next_tag), hl @@ -102,39 +105,43 @@ l_do_scsi_cmd_00102: pop bc ;source-doc/scsi-drv/class_scsi.c:25: &dev->endpoints[ENDPOINT_BULK_OUT])); ld a,(ix+4) - ld (ix-4),a + ld (ix-6),a + ld e, a ld a,(ix+5) + ld (ix-5),a + ld d,a + inc de + inc de + inc de + ld a,(ix-6) + ld (ix-4),a + ld l, a + ld a,(ix-5) ld (ix-3),a - ld a,(ix-4) - add a,0x03 - ld (ix-2),a - ld a,(ix-3) - adc a,0x00 - ld (ix-1),a - ld l,(ix-4) - ld h,(ix-3) + ld h,a ld a, (hl) rlca rlca rlca rlca and 0x0f - ld e,(ix+6) - ld d,(ix+7) + ld l,(ix+6) + ld h,(ix+7) push bc - ld l,(ix-2) - ld h,(ix-1) - push hl + push de + push de push af inc sp + push hl ld hl,0x001f + ex (sp), hl push hl - push de call _usb_data_out_transfer pop af pop af pop af inc sp + pop de pop bc ld a, l ld (_result), a @@ -144,30 +151,33 @@ l_do_scsi_cmd_00102: ;source-doc/scsi-drv/class_scsi.c:27: if (cbw->dCBWDataTransferLength != 0) { ld hl,8 add hl, bc - ld e, (hl) + ld c, (hl) inc hl - ld d, (hl) + ld b, (hl) inc hl - ld c, (hl) inc hl ld a, (hl) + dec hl + ld l, (hl) + or l + or b or c - or d - or e jr Z,l_do_scsi_cmd_00113 ;source-doc/scsi-drv/class_scsi.c:30: &dev->endpoints[ENDPOINT_BULK_IN])); - ld c,(ix+8) - ld b,(ix+9) + ld a,(ix+8) + ld (ix-2),a + ld a,(ix+9) + ld (ix-1),a ;source-doc/scsi-drv/class_scsi.c:28: if (!send) { bit 0,(ix+10) jr NZ,l_do_scsi_cmd_00110 ;source-doc/scsi-drv/class_scsi.c:30: &dev->endpoints[ENDPOINT_BULK_IN])); - ld a,(ix-4) + ld a,(ix-6) add a,0x06 - ld (ix-2),a - ld a,(ix-3) + ld e, a + ld a,(ix-5) adc a,0x00 - ld (ix-1),a + ld d, a ld l,(ix-4) ld h,(ix-3) ld a, (hl) @@ -176,13 +186,13 @@ l_do_scsi_cmd_00102: rlca rlca and 0x0f - ld l,(ix-2) - ld h,(ix-1) - push hl + push de push af inc sp - push de push bc + ld l,(ix-2) + ld h,(ix-1) + push hl call _usb_data_in_transfer pop af pop af @@ -204,13 +214,13 @@ l_do_scsi_cmd_00110: rlca rlca and 0x0f - ld l,(ix-2) - ld h,(ix-1) - push hl + push de push af inc sp - push de push bc + ld l,(ix-2) + ld h,(ix-1) + push hl call _usb_data_out_transfer pop af pop af @@ -223,10 +233,10 @@ l_do_scsi_cmd_00110: jr NZ,l_do_scsi_cmd_00120 l_do_scsi_cmd_00113: ;source-doc/scsi-drv/class_scsi.c:39: usb_data_in_transfer((uint8_t *)&csw, sizeof(_scsi_command_status_wrapper), dev->address, &dev->endpoints[ENDPOINT_BULK_IN])); - ld a,(ix-4) + ld a,(ix-6) add a,0x06 ld e, a - ld a,(ix-3) + ld a,(ix-5) adc a,0x00 ld d, a ld l,(ix-4) @@ -275,14 +285,14 @@ l_do_scsi_cmd_00113: jr l_do_scsi_cmd_00120 l_do_scsi_cmd_00117: ;source-doc/scsi-drv/class_scsi.c:44: result = USB_ERR_OK; - ld hl,_result - ld (hl),0x00 + xor a + ld (_result),a ;source-doc/scsi-drv/class_scsi.c:46: done: l_do_scsi_cmd_00120: ;source-doc/scsi-drv/class_scsi.c:47: critical_end(); call _critical_end ;source-doc/scsi-drv/class_scsi.c:48: return result; - ld hl,(_result) + ld hl, (_result) ;source-doc/scsi-drv/class_scsi.c:49: } ld sp, ix pop ix @@ -301,37 +311,43 @@ _get_scsi_read_capacity: ;source-doc/scsi-drv/class_scsi.c:55: cbw_scsi.cbw = scsi_command_block_wrapper; ld hl,0 add hl, sp - ex de, hl + ld e,l + ld d,h + push hl ld bc,0x000f ld hl,_scsi_command_block_wrapper ldir ;source-doc/scsi-drv/class_scsi.c:56: cbw_scsi.read_capacity = scsi_read_capacity; - ld hl,15 + ld hl,17 add hl, sp ex de, hl ld bc,0x000c ld hl,_scsi_read_capacity ldir + pop bc ;source-doc/scsi-drv/class_scsi.c:58: cbw_scsi.cbw.bCBWLUN = 0; ld (ix-14),0x00 ;source-doc/scsi-drv/class_scsi.c:59: cbw_scsi.cbw.bCBWCBLength = sizeof(_scsi_read_capacity); ld (ix-13),0x0c ;source-doc/scsi-drv/class_scsi.c:60: cbw_scsi.cbw.dCBWDataTransferLength = sizeof(scsi_read_capacity_result); - ld (ix-19),0x08 + ld hl,0x0008 + add hl, bc + ld (hl),0x08 + inc hl xor a - ld (ix-18),a - ld (ix-17),a - ld (ix-16),a + ld (hl), a + inc hl + ld (hl), a + inc hl + ld (hl), a ;source-doc/scsi-drv/class_scsi.c:62: return do_scsi_cmd(dev, &cbw_scsi.cbw, cap_result, false); - ld c,(ix+6) - ld b,(ix+7) + ld e,(ix+6) + ld d,(ix+7) xor a push af inc sp + push de push bc - ld hl,3 - add hl, sp - push hl ld l,(ix+4) ld h,(ix+5) push hl @@ -354,37 +370,43 @@ _scsi_inquiry: ;source-doc/scsi-drv/class_scsi.c:69: cbw_scsi.cbw = scsi_command_block_wrapper; ld hl,0 add hl, sp - ex de, hl + ld e,l + ld d,h + push hl ld bc,0x000f ld hl,_scsi_command_block_wrapper ldir ;source-doc/scsi-drv/class_scsi.c:70: cbw_scsi.inquiry = scsi_packet_inquiry; - ld hl,15 + ld hl,17 add hl, sp ex de, hl ld bc,0x000c ld hl,_scsi_packet_inquiry ldir + pop bc ;source-doc/scsi-drv/class_scsi.c:72: cbw_scsi.cbw.bCBWLUN = 0; ld (ix-14),0x00 ;source-doc/scsi-drv/class_scsi.c:73: cbw_scsi.cbw.bCBWCBLength = sizeof(_scsi_packet_inquiry); ld (ix-13),0x0c ;source-doc/scsi-drv/class_scsi.c:74: cbw_scsi.cbw.dCBWDataTransferLength = 0x24; - ld (ix-19),0x24 + ld hl,0x0008 + add hl, bc + ld (hl),0x24 + inc hl xor a - ld (ix-18),a - ld (ix-17),a - ld (ix-16),a + ld (hl), a + inc hl + ld (hl), a + inc hl + ld (hl), a ;source-doc/scsi-drv/class_scsi.c:76: return do_scsi_cmd(dev, &cbw_scsi.cbw, inq_result, false); - ld c,(ix+6) - ld b,(ix+7) + ld e,(ix+6) + ld d,(ix+7) xor a push af inc sp + push de push bc - ld hl,3 - add hl, sp - push hl ld l,(ix+4) ld h,(ix+5) push hl @@ -407,12 +429,14 @@ _scsi_test: ;source-doc/scsi-drv/class_scsi.c:81: cbw_scsi.cbw = scsi_command_block_wrapper; ld hl,0 add hl, sp - ex de, hl + ld e,l + ld d,h + push hl ld bc,0x000f ld hl,_scsi_command_block_wrapper ldir ;source-doc/scsi-drv/class_scsi.c:82: memset(&cbw_scsi.test, 0, sizeof(_scsi_packet_test)); - ld hl,15 + ld hl,17 add hl, sp ld b,0x06 l_scsi_test_00103: @@ -422,30 +446,29 @@ l_scsi_test_00103: ld (hl), a inc hl djnz l_scsi_test_00103 + pop bc ;source-doc/scsi-drv/class_scsi.c:84: cbw_scsi.cbw.bCBWLUN = 0; ld (ix-14),0x00 ;source-doc/scsi-drv/class_scsi.c:85: cbw_scsi.cbw.bCBWCBLength = sizeof(_scsi_packet_test); ld (ix-13),0x0c ;source-doc/scsi-drv/class_scsi.c:86: cbw_scsi.cbw.dCBWDataTransferLength = 0; - ld hl,8 - add hl, sp + ld hl,0x0008 + add hl, bc xor a - ld (hl),a + ld (hl), a inc hl - ld (hl),a + ld (hl), a inc hl - ld (hl),a + ld (hl), a inc hl - ld (hl),a + ld (hl), a ;source-doc/scsi-drv/class_scsi.c:88: return do_scsi_cmd(dev, &cbw_scsi.cbw, 0, false); xor a push af inc sp ld hl,0x0000 push hl - ld hl,3 - add hl, sp - push hl + push bc ld l,(ix+4) ld h,(ix+5) push hl @@ -468,37 +491,43 @@ _scsi_request_sense: ;source-doc/scsi-drv/class_scsi.c:95: cbw_scsi.cbw = scsi_command_block_wrapper; ld hl,0 add hl, sp - ex de, hl + ld e,l + ld d,h + push hl ld bc,0x000f ld hl,_scsi_command_block_wrapper ldir ;source-doc/scsi-drv/class_scsi.c:96: cbw_scsi.request_sense = scsi_packet_request_sense; - ld hl,15 + ld hl,17 add hl, sp ex de, hl ld bc,0x000c ld hl,_scsi_packet_request_sense ldir + pop bc ;source-doc/scsi-drv/class_scsi.c:98: cbw_scsi.cbw.bCBWLUN = 0; ld (ix-14),0x00 ;source-doc/scsi-drv/class_scsi.c:99: cbw_scsi.cbw.bCBWCBLength = sizeof(_scsi_packet_request_sense); ld (ix-13),0x0c ;source-doc/scsi-drv/class_scsi.c:100: cbw_scsi.cbw.dCBWDataTransferLength = sizeof(scsi_sense_result); - ld (ix-19),0x12 + ld hl,0x0008 + add hl, bc + ld (hl),0x12 + inc hl xor a - ld (ix-18),a - ld (ix-17),a - ld (ix-16),a + ld (hl), a + inc hl + ld (hl), a + inc hl + ld (hl), a ;source-doc/scsi-drv/class_scsi.c:102: return do_scsi_cmd(dev, &cbw_scsi.cbw, sens_result, false); - ld c,(ix+6) - ld b,(ix+7) + ld e,(ix+6) + ld d,(ix+7) xor a push af inc sp + push de push bc - ld hl,3 - add hl, sp - push hl ld l,(ix+4) ld h,(ix+5) push hl @@ -553,7 +582,7 @@ l_scsi_sense_init_00104: ;source-doc/scsi-drv/class_scsi.c:112: critical_end(); call _critical_end ;source-doc/scsi-drv/class_scsi.c:114: return result; - ld hl,(_result) + ld hl, (_result) ;source-doc/scsi-drv/class_scsi.c:115: } ld sp, ix pop ix @@ -566,17 +595,20 @@ _scsi_read: push ix ld ix,0 add ix,sp - push af ;source-doc/scsi-drv/class_scsi.c:120: memset(&cbw, 0, sizeof(cbw_scsi_read_write)); - ld hl,_cbw + ld de,_cbw + ld l, e + ld h, d + ld b,0x0e + jr l_scsi_read_00113 +l_scsi_read_00112: ld (hl),0x00 - ld e, l - ld d, h - inc de - ld bc,0x001a - ldir + inc hl +l_scsi_read_00113: + ld (hl),0x00 + inc hl + djnz l_scsi_read_00112 ;source-doc/scsi-drv/class_scsi.c:121: cbw.cbw = scsi_command_block_wrapper; - ld de,_cbw ld bc,0x000f ld hl,_scsi_command_block_wrapper ldir @@ -598,50 +630,52 @@ _scsi_read: ld hl,_cbw + 23 ld (hl),0x01 ;source-doc/scsi-drv/class_scsi.c:129: cbw.scsi_cmd.lba[0] = dev->current_lba >> 24; - ld c,(ix+4) - ld b,(ix+5) - ld hl,0x000c - add hl, bc - pop af - push hl + ld l,(ix+4) + ld h,(ix+5) + ld bc,0x000c + add hl,bc + ld c,l + ld b,h inc hl inc hl inc hl ld a, (hl) ld ((_cbw + 17)),a ;source-doc/scsi-drv/class_scsi.c:130: cbw.scsi_cmd.lba[1] = dev->current_lba >> 16; - pop hl - push hl - inc hl - inc hl - ld a, (hl) - ld ((_cbw + 18)),a ;source-doc/scsi-drv/class_scsi.c:131: cbw.scsi_cmd.lba[2] = dev->current_lba >> 8; - pop hl - push hl + ld l,c + ld h,b + inc hl inc hl ld a,(hl) - ld ((_cbw + 19)),a + ld ((_cbw + 18)),a + dec hl + ld e, (hl) + ld hl, +(_cbw + 19) + ld (hl), e ;source-doc/scsi-drv/class_scsi.c:132: cbw.scsi_cmd.lba[3] = dev->current_lba; - pop hl - ld a,(hl) - push hl - ld ((_cbw + 20)),a + ld a, (bc) + inc hl + ld (hl), a ;source-doc/scsi-drv/class_scsi.c:134: result = do_scsi_cmd(dev, &cbw.cbw, buffer, false); ld e,(ix+6) ld d,(ix+7) + push bc xor a push af inc sp push de ld hl,_cbw push hl - push bc + ld l,(ix+4) + ld h,(ix+5) + push hl call _do_scsi_cmd pop af pop af pop af inc sp + pop bc ld a, l ld (_result), a ;source-doc/scsi-drv/class_scsi.c:136: if (result == USB_ERR_OK) @@ -649,35 +683,37 @@ _scsi_read: or a jr NZ,l_scsi_read_00102 ;source-doc/scsi-drv/class_scsi.c:137: dev->current_lba++; - pop hl - ld c,(hl) - push hl - inc hl - ld b, (hl) - inc hl + ld l, c + ld h, b ld e, (hl) inc hl ld d, (hl) - inc c - jr NZ,l_scsi_read_00112 - inc b - jr NZ,l_scsi_read_00112 - inc de -l_scsi_read_00112: - pop hl - push hl - ld (hl), c - inc hl - ld (hl), b inc hl - ld (hl), e + ld a,(hl) inc hl - ld (hl), d + ld h,(hl) + ld l,a + inc e + jr NZ,l_scsi_read_00114 + inc d + jr NZ,l_scsi_read_00114 + inc hl +l_scsi_read_00114: + ld a, e + ld (bc), a + inc bc + ld a, d + ld (bc), a + inc bc + ld a, l + ld (bc), a + inc bc + ld a, h + ld (bc), a l_scsi_read_00102: ;source-doc/scsi-drv/class_scsi.c:138: return result; - ld hl,(_result) + ld hl, (_result) ;source-doc/scsi-drv/class_scsi.c:139: } - ld sp, ix pop ix ret ;source-doc/scsi-drv/class_scsi.c:141: usb_error scsi_write(device_config_storage *const dev, uint8_t *const buffer) { @@ -688,17 +724,20 @@ _scsi_write: push ix ld ix,0 add ix,sp - push af ;source-doc/scsi-drv/class_scsi.c:142: memset(&cbw, 0, sizeof(cbw_scsi_read_write)); - ld hl,_cbw + ld de,_cbw + ld l, e + ld h, d + ld b,0x0e + jr l_scsi_write_00113 +l_scsi_write_00112: ld (hl),0x00 - ld e, l - ld d, h - inc de - ld bc,0x001a - ldir + inc hl +l_scsi_write_00113: + ld (hl),0x00 + inc hl + djnz l_scsi_write_00112 ;source-doc/scsi-drv/class_scsi.c:143: cbw.cbw = scsi_command_block_wrapper; - ld de,_cbw ld bc,0x000f ld hl,_scsi_command_block_wrapper ldir @@ -720,50 +759,52 @@ _scsi_write: ld hl,_cbw + 23 ld (hl),0x01 ;source-doc/scsi-drv/class_scsi.c:151: cbw.scsi_cmd.lba[0] = dev->current_lba >> 24; - ld c,(ix+4) - ld b,(ix+5) - ld hl,0x000c - add hl, bc - pop af - push hl + ld l,(ix+4) + ld h,(ix+5) + ld bc,0x000c + add hl,bc + ld c,l + ld b,h inc hl inc hl inc hl ld a, (hl) ld ((_cbw + 17)),a ;source-doc/scsi-drv/class_scsi.c:152: cbw.scsi_cmd.lba[1] = dev->current_lba >> 16; - pop hl - push hl - inc hl - inc hl - ld a, (hl) - ld ((_cbw + 18)),a ;source-doc/scsi-drv/class_scsi.c:153: cbw.scsi_cmd.lba[2] = dev->current_lba >> 8; - pop hl - push hl + ld l,c + ld h,b + inc hl inc hl ld a,(hl) - ld ((_cbw + 19)),a + ld ((_cbw + 18)),a + dec hl + ld e, (hl) + ld hl, +(_cbw + 19) + ld (hl), e ;source-doc/scsi-drv/class_scsi.c:154: cbw.scsi_cmd.lba[3] = dev->current_lba; - pop hl - ld a,(hl) - push hl - ld ((_cbw + 20)),a + ld a, (bc) + inc hl + ld (hl), a ;source-doc/scsi-drv/class_scsi.c:156: result = do_scsi_cmd(dev, &cbw.cbw, buffer, true); ld e,(ix+6) ld d,(ix+7) + push bc ld a,0x01 push af inc sp push de ld hl,_cbw push hl - push bc + ld l,(ix+4) + ld h,(ix+5) + push hl call _do_scsi_cmd pop af pop af pop af inc sp + pop bc ld a, l ld (_result), a ;source-doc/scsi-drv/class_scsi.c:158: if (result == USB_ERR_OK) @@ -771,35 +812,37 @@ _scsi_write: or a jr NZ,l_scsi_write_00102 ;source-doc/scsi-drv/class_scsi.c:159: dev->current_lba++; - pop hl - ld c,(hl) - push hl - inc hl - ld b, (hl) - inc hl + ld l, c + ld h, b ld e, (hl) inc hl ld d, (hl) - inc c - jr NZ,l_scsi_write_00112 - inc b - jr NZ,l_scsi_write_00112 - inc de -l_scsi_write_00112: - pop hl - push hl - ld (hl), c - inc hl - ld (hl), b inc hl - ld (hl), e + ld a,(hl) inc hl - ld (hl), d + ld h,(hl) + ld l,a + inc e + jr NZ,l_scsi_write_00114 + inc d + jr NZ,l_scsi_write_00114 + inc hl +l_scsi_write_00114: + ld a, e + ld (bc), a + inc bc + ld a, d + ld (bc), a + inc bc + ld a, l + ld (bc), a + inc bc + ld a, h + ld (bc), a l_scsi_write_00102: ;source-doc/scsi-drv/class_scsi.c:160: return result; - ld hl,(_result) + ld hl, (_result) ;source-doc/scsi-drv/class_scsi.c:161: } - ld sp, ix pop ix ret ;source-doc/scsi-drv/class_scsi.c:163: usb_error scsi_eject(device_config_storage *const dev) { @@ -816,12 +859,14 @@ _scsi_eject: ;source-doc/scsi-drv/class_scsi.c:165: cbw_scsi.cbw = scsi_command_block_wrapper; ld hl,0 add hl, sp - ex de, hl + ld e,l + ld d,h + push hl ld bc,0x000f ld hl,_scsi_command_block_wrapper ldir ;source-doc/scsi-drv/class_scsi.c:167: memset(&cbw_scsi.eject, 0, sizeof(_scsi_packet_eject)); - ld hl,15 + ld hl,17 add hl, sp ld b,0x03 l_scsi_eject_00103: @@ -831,6 +876,7 @@ l_scsi_eject_00103: ld (hl), a inc hl djnz l_scsi_eject_00103 + pop bc ;source-doc/scsi-drv/class_scsi.c:169: cbw_scsi.eject.operation_code = 0x1B; ld (ix-6),0x1b ;source-doc/scsi-drv/class_scsi.c:170: cbw_scsi.eject.loej = 1; @@ -842,25 +888,23 @@ l_scsi_eject_00103: ;source-doc/scsi-drv/class_scsi.c:173: cbw_scsi.cbw.bCBWCBLength = sizeof(_scsi_packet_eject); ld (ix-7),0x06 ;source-doc/scsi-drv/class_scsi.c:174: cbw_scsi.cbw.dCBWDataTransferLength = 0; - ld hl,8 - add hl, sp + ld hl,0x0008 + add hl, bc xor a - ld (hl),a + ld (hl), a inc hl - ld (hl),a + ld (hl), a inc hl - ld (hl),a + ld (hl), a inc hl - ld (hl),a + ld (hl), a ;source-doc/scsi-drv/class_scsi.c:176: return do_scsi_cmd(dev, &cbw_scsi.cbw, 0, false); xor a push af inc sp ld hl,0x0000 push hl - ld hl,3 - add hl, sp - push hl + push bc ld l,(ix+4) ld h,(ix+5) push hl diff --git a/Source/HBIOS/ch376-native/scsi-drv/scsi-init.c.s b/Source/HBIOS/ch376-native/scsi-drv/scsi-init.c.s index aac79d77..c1e9efbb 100644 --- a/Source/HBIOS/ch376-native/scsi-drv/scsi-init.c.s +++ b/Source/HBIOS/ch376-native/scsi-drv/scsi-init.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -85,14 +85,16 @@ l_chscsi_init_00105: ld h,0x00 push de call _print_uint16 +;source-doc/scsi-drv/scsi-init.c:26: print_string(":$"); ld hl,scsi_init_str_1 call _print_string pop de ;source-doc/scsi-drv/scsi-init.c:27: print_uint16(storage_count); - ld hl,(_storage_count) + ld hl, (_storage_count) ld h,0x00 push de call _print_uint16 +;source-doc/scsi-drv/scsi-init.c:28: print_string(" $"); ld hl,scsi_init_str_2 call _print_string pop de diff --git a/Source/HBIOS/ch376-native/ufi-drv/class_ufi.c.s b/Source/HBIOS/ch376-native/ufi-drv/class_ufi.c.s index c0be3f53..82a0a022 100644 --- a/Source/HBIOS/ch376-native/ufi-drv/class_ufi.c.s +++ b/Source/HBIOS/ch376-native/ufi-drv/class_ufi.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -197,8 +197,6 @@ _ufi_test_unit_ready: ;source-doc/ufi-drv/class_ufi.c:35: memset(&ufi_cmd_request_test_unit_ready, 0, sizeof(ufi_test_unit_ready_command)); ld hl,0 add hl, sp - ld e,l - ld d,h ld b,0x06 l_ufi_test_unit_ready_00104: xor a @@ -215,7 +213,9 @@ l_ufi_test_unit_ready_00104: xor a push af inc sp - push de + ld hl,7 + add hl, sp + push hl ld l,(ix+4) ld h,(ix+5) push hl @@ -226,26 +226,25 @@ l_ufi_test_unit_ready_00104: ;source-doc/ufi-drv/class_ufi.c:40: ufi_cmd_request_sense = _ufi_cmd_request_sense; ld hl,12 add hl, sp - ld e,l - ld d,h - push hl + ex de, hl ld bc,0x000c ld hl,__ufi_cmd_request_sense ldir - pop bc ;source-doc/ufi-drv/class_ufi.c:43: (uint8_t *)response, NULL); - ld e,(ix+6) - ld d,(ix+7) + ld c,(ix+6) + ld b,(ix+7) ;source-doc/ufi-drv/class_ufi.c:42: result = usb_execute_cbi(storage_device, (uint8_t *)&ufi_cmd_request_sense, false, sizeof(ufi_request_sense_response), ld hl,0x0000 push hl - push de + push bc ld l,0x12 push hl xor a push af inc sp - push bc + ld hl,19 + add hl, sp + push hl ld l,(ix+4) ld h,(ix+5) push hl @@ -269,25 +268,24 @@ _ufi_request_sense: ;source-doc/ufi-drv/class_ufi.c:51: ufi_cmd_request_sense = _ufi_cmd_request_sense; ld hl,0 add hl, sp - ld e,l - ld d,h - push hl + ex de, hl ld bc,0x000c ld hl,__ufi_cmd_request_sense ldir - pop bc ;source-doc/ufi-drv/class_ufi.c:53: usb_error result = usb_execute_cbi(storage_device, (uint8_t *)&ufi_cmd_request_sense, false, sizeof(ufi_request_sense_response), - ld e,(ix+6) - ld d,(ix+7) + ld c,(ix+6) + ld b,(ix+7) ld hl,0x0000 push hl - push de + push bc ld l,0x12 push hl xor a push af inc sp - push bc + ld hl,7 + add hl, sp + push hl ld l,(ix+4) ld h,(ix+5) push hl @@ -340,29 +338,30 @@ _ufi_read_frmt_caps: pop af pop af inc sp - ld e, l + ld a, l pop bc + ld l, a ;source-doc/ufi-drv/class_ufi.c:69: CHECK(result); - ld a,e - ld l,a or a jr NZ,l_ufi_read_frmt_caps_00103 ;source-doc/ufi-drv/class_ufi.c:71: const uint8_t available_length = response->capacity_list_length; - ld e,(ix+6) - ld d,(ix+7) - ld hl,3 - add hl, de - ld e, (hl) + ld l,(ix+6) + ld h,(ix+7) + inc hl + inc hl + inc hl + ld a, (hl) ;source-doc/ufi-drv/class_ufi.c:73: const uint8_t max_length = - ld a,0x24 - sub e - jr NC,l_ufi_read_frmt_caps_00106 + cp 0x25 + jr C,l_ufi_read_frmt_caps_00106 ld e,0x24 + jr l_ufi_read_frmt_caps_00107 l_ufi_read_frmt_caps_00106: + ld e, a +l_ufi_read_frmt_caps_00107: ;source-doc/ufi-drv/class_ufi.c:77: memcpy(&cmd, &ufi_cmd_read_format_capacities, sizeof(cmd)); push de push bc - ex de, hl ld hl,16 add hl, sp ex de, hl @@ -417,25 +416,24 @@ _ufi_inquiry: ;source-doc/ufi-drv/class_ufi.c:90: ufi_cmd_inquiry = _ufi_cmd_inquiry; ld hl,0 add hl, sp - ld e,l - ld d,h - push hl + ex de, hl ld bc,0x000c ld hl,__ufi_cmd_inquiry ldir - pop bc ;source-doc/ufi-drv/class_ufi.c:92: usb_error result = - ld e,(ix+6) - ld d,(ix+7) + ld c,(ix+6) + ld b,(ix+7) ld hl,0x0000 push hl - push de + push bc ld l,0x24 push hl xor a push af inc sp - push bc + ld hl,7 + add hl, sp + push hl ld l,(ix+4) ld h,(ix+5) push hl @@ -459,8 +457,6 @@ _ufi_read_write_sector: ;source-doc/ufi-drv/class_ufi.c:107: memset(&cmd, 0, sizeof(cmd)); ld hl,0 add hl, sp - ld e,l - ld d,h ld b,0x06 l_ufi_read_write_sector_00113: xor a @@ -470,8 +466,6 @@ l_ufi_read_write_sector_00113: inc hl djnz l_ufi_read_write_sector_00113 ;source-doc/ufi-drv/class_ufi.c:108: cmd.operation_code = send ? 0x2A : 0x28; - ld c, e - ld b, d bit 0,(ix+6) jr Z,l_ufi_read_write_sector_00104 ld a,0x2a @@ -479,7 +473,7 @@ l_ufi_read_write_sector_00113: l_ufi_read_write_sector_00104: ld a,0x28 l_ufi_read_write_sector_00105: - ld (bc), a + ld (ix-12),a ;source-doc/ufi-drv/class_ufi.c:109: cmd.lba[2] = sector_number >> 8; ld a,(ix+8) ld (ix-8),a @@ -491,6 +485,7 @@ l_ufi_read_write_sector_00105: ld a,(ix+9) ld (ix-4),a add a, a + ld b, a ld c,0x00 ld l,(ix+12) ld h,(ix+13) @@ -498,12 +493,13 @@ l_ufi_read_write_sector_00105: ld l,(ix+10) ld h,(ix+11) push hl - ld b, a push bc ld a,(ix+6) push af inc sp - push de + ld hl,7 + add hl, sp + push hl ld l,(ix+4) ld h,(ix+5) push hl @@ -527,7 +523,8 @@ _ufi_format: ;source-doc/ufi-drv/class_ufi.c:130: const ufi_format_capacity_descriptor *const format) { ld hl,2 add hl, sp - push hl + ld e,l + ld d,h ld b,0x06 l_ufi_format_00104: xor a @@ -536,16 +533,15 @@ l_ufi_format_00104: ld (hl), a inc hl djnz l_ufi_format_00104 - pop bc ;source-doc/ufi-drv/class_ufi.c:133: ufi_format_parameter_list parameter_list; - ld hl,14 + push de + ld hl,16 add hl, sp ex de, hl - push bc ld bc,0x000c ld hl,__ufi_cmd_format ldir - pop bc + pop de ;source-doc/ufi-drv/class_ufi.c:136: ufi_format_command cmd; ld a,(ix+7) ld (ix-10),a @@ -554,60 +550,68 @@ l_ufi_format_00104: ;source-doc/ufi-drv/class_ufi.c:138: // memcpy(&cmd, &_ufi_cmd_format, sizeof(cmd)); ld (ix-4),0x0c ;source-doc/ufi-drv/class_ufi.c:140: cmd.track_number = track_number; - ld e, c - ld d, b - inc de + ld c, e + ld b, d + inc bc ld a,(ix+6) and 0x01 ld l, a - ld a, (de) + ld a, (bc) and 0xfe or l - ld (de), a + ld (bc), a ;source-doc/ufi-drv/class_ufi.c:141: cmd.interleave[1] = 0; ld l, e ld h, d + inc hl res 1, (hl) ;source-doc/ufi-drv/class_ufi.c:142: cmd.parameter_list_length[1] = sizeof(parameter_list); - ld l, e - ld h, d - ld a, (hl) + ld c, e + ld b, d + inc bc + ld a, (bc) and 0xf3 - ld (hl), a + ld (bc), a ;source-doc/ufi-drv/class_ufi.c:143: ld l, e ld h, d + inc hl set 4, (hl) ;source-doc/ufi-drv/class_ufi.c:144: parameter_list.defect_list_header.side = side; ld l, e ld h, d + inc hl set 5, (hl) ;source-doc/ufi-drv/class_ufi.c:145: parameter_list.defect_list_header.immediate = 0; ld l, e ld h, d + inc hl res 6, (hl) ;source-doc/ufi-drv/class_ufi.c:146: parameter_list.defect_list_header.reserved2 = 0; - ex de, hl + ld l, e + ld h, d + inc hl set 7, (hl) ;source-doc/ufi-drv/class_ufi.c:147: parameter_list.defect_list_header.single_track = 1; ld (ix-22),0x00 ;source-doc/ufi-drv/class_ufi.c:148: parameter_list.defect_list_header.dcrt = 1; ld (ix-21),0x08 ;source-doc/ufi-drv/class_ufi.c:149: parameter_list.defect_list_header.extend = 0; - ld e,(ix+8) - ld d,(ix+9) - push bc - ld hl,8 - add hl, sp - ex de, hl + inc de + inc de + inc de + inc de + ld l,(ix+8) + ld h,(ix+9) ld bc,0x0008 ldir - pop bc ;source-doc/ufi-drv/class_ufi.c:151: parameter_list.defect_list_header.defect_list_length_msb = 0; ld hl,0 add hl, sp push hl - push bc + ld hl,4 + add hl, sp + push hl ld hl,0x000c push hl ld a,0x01 @@ -639,13 +643,10 @@ _ufi_send_diagnostics: ;source-doc/ufi-drv/class_ufi.c:164: ld hl,0 add hl, sp - ld e,l - ld d,h - push hl + ex de, hl ld bc,0x000c ld hl,__ufi_cmd_send_diagnostic ldir - pop bc ;source-doc/ufi-drv/class_ufi.c:166: ufi_send_diagnostic_command ufi_cmd_send_diagnostic; ld hl,0x0000 push hl @@ -654,7 +655,9 @@ _ufi_send_diagnostics: ld a,0x01 push af inc sp - push bc + ld hl,7 + add hl, sp + push hl ld l,(ix+4) ld h,(ix+5) push hl @@ -678,28 +681,28 @@ _convert_from_msb_first: add hl, sp ex de, hl ;source-doc/ufi-drv/class_ufi.c:172: - ld c,(ix+4) - ld b,(ix+5) - inc bc - inc bc - inc bc + ld l,(ix+4) + ld h,(ix+5) + inc hl + inc hl + inc hl ;source-doc/ufi-drv/class_ufi.c:174: uint32_t result; - ld a, (bc) - dec bc + ld a, (hl) + dec hl ld (de), a inc de ;source-doc/ufi-drv/class_ufi.c:175: uint8_t *p_output = ((uint8_t *)&result); - ld a, (bc) - dec bc + ld a, (hl) + dec hl ld (de), a inc de ;source-doc/ufi-drv/class_ufi.c:176: const uint8_t *p_input = buffer + 3; - ld a, (bc) + ld a, (hl) ld (de), a inc de ;source-doc/ufi-drv/class_ufi.c:177: - dec bc - ld a, (bc) + dec hl + ld a, (hl) ld (de), a ;source-doc/ufi-drv/class_ufi.c:179: *p_output++ = *p_input--; pop hl diff --git a/Source/HBIOS/ch376-native/ufi-drv/ufi-init.c.s b/Source/HBIOS/ch376-native/ufi-drv/ufi-init.c.s index f613d00f..fa74e62a 100644 --- a/Source/HBIOS/ch376-native/ufi-drv/ufi-init.c.s +++ b/Source/HBIOS/ch376-native/ufi-drv/ufi-init.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -85,14 +85,16 @@ l_chufi_init_00105: ld h,0x00 push de call _print_uint16 +;source-doc/ufi-drv/ufi-init.c:25: print_string(":$"); ld hl,ufi_init_str_1 call _print_string pop de ;source-doc/ufi-drv/ufi-init.c:26: print_uint16(storage_count); - ld hl,(_storage_count) + ld hl, (_storage_count) ld h,0x00 push de call _print_uint16 +;source-doc/ufi-drv/ufi-init.c:27: print_string(" $"); ld hl,ufi_init_str_2 call _print_string pop de diff --git a/Source/HBIOS/ch376-native/ufi-drv/usb_cbi.c.s b/Source/HBIOS/ch376-native/ufi-drv/usb_cbi.c.s index 79d7c299..0db067ee 100644 --- a/Source/HBIOS/ch376-native/ufi-drv/usb_cbi.c.s +++ b/Source/HBIOS/ch376-native/ufi-drv/usb_cbi.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.4.0 #14648 (Linux) +; Version 4.5.0 #15248 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -72,7 +72,6 @@ _usb_execute_cbi: ;source-doc/ufi-drv/usb_cbi.c:20: adsc = cbi2_adsc; push de push bc - ex de, hl ld hl,4 add hl, sp ex de, hl @@ -216,7 +215,7 @@ l_usb_execute_cbi_00116: ;source-doc/ufi-drv/usb_cbi.c:66: critical_end(); call _critical_end ;source-doc/ufi-drv/usb_cbi.c:68: return result; - ld hl,(_result) + ld hl, (_result) ;source-doc/ufi-drv/usb_cbi.c:69: } ld sp, ix pop ix