Skip to content

Commit d0ea26b

Browse files
author
Rodrigo Torres
committed
Implements another size optimization (size down to 506 bytes)
Moves "wait_TXINI" up, right after "process_Host2Device", which allows us to get rid of an "rcall/ret" combo. Last call to "wait_TXINI' within "process_Host2Device" is now simply a fall-through.
1 parent 52c89c0 commit d0ea26b

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

nanoBoot.S

+13-14
Original file line numberDiff line numberDiff line change
@@ -976,8 +976,20 @@ process_Host2Device:
976976
; Clear Transmitter Ready Flag
977977
rcall clear_TXINI ; This function uses r17 to clear the TXINI bit in UEINTX
978978

979+
; SIZE OPTIMIZATION: Fall through to wait_TXINI instead of rcall'ing it
979980
; Wait for TXINI (OK to transmit)
980-
rcall wait_TXINI ; This function loads r17 with value of UEINTX
981+
; rcall wait_TXINI ; This function loads r17 with value of UEINTX
982+
; ret ; Return from call
983+
984+
wait_TXINI:
985+
986+
; NOTE: This function uses r17, we can use this fact to code other stuff
987+
; that happens before and after this functions is called
988+
989+
; Wait for TXINI (OK to transmit)
990+
ldd r17, Y+oUEINTX ; Load r17 with the value in the USB Endpoint Interrupt Register (UEINTX)
991+
sbrs r17, TXINI ; Check the value of bit TXINI in r17, skip the next instruction if set
992+
rjmp wait_TXINI ; Bit TXINI is not set, keep waiting
981993

982994
ret ; Return from call
983995

@@ -1015,19 +1027,6 @@ clear_RXOUTI:
10151027
ret ; Return from call
10161028

10171029

1018-
wait_TXINI:
1019-
1020-
; NOTE: This function uses r17, we can use this fact to code other stuff
1021-
; that happens before and after this functions is called
1022-
1023-
; Wait for TXINI (OK to transmit)
1024-
ldd r17, Y+oUEINTX ; Load r17 with the value in the USB Endpoint Interrupt Register (UEINTX)
1025-
sbrs r17, TXINI ; Check the value of bit TXINI in r17, skip the next instruction if set
1026-
rjmp wait_TXINI ; Bit TXINI is not set, keep waiting
1027-
1028-
ret ; Return from call
1029-
1030-
10311030
wait_RXOUTI:
10321031

10331032
; NOTE: This function uses r17, we can use this fact to code other stuff

0 commit comments

Comments
 (0)