Index: libgcc/config/rl78/divmodhi.S
===================================================================
--- libgcc/config/rl78/divmodhi.S	(revision 227024)
+++ libgcc/config/rl78/divmodhi.S	(working copy)
@@ -454,7 +454,11 @@
 	movw	ax, den
 	cmpw	ax, #0
 	bnz	$den_not_zero\which
+	.if \need_result
+	movw    quot, #0
+	.else
 	movw	num, #0
+	.endif
 	ret
 
 den_not_zero\which:
Index: libgcc/config/rl78/divmodqi.S
===================================================================
--- libgcc/config/rl78/divmodqi.S	(revision 227024)
+++ libgcc/config/rl78/divmodqi.S	(working copy)
@@ -63,7 +63,7 @@
 	ret
 	
 den_is_zero\which:
-	mov	r8, #0xff
+	mov	r8, #0x00
 	ret
 
 	;; These routines leave DE alone - the signed functions use DE
Index: libgcc/config/rl78/divmodsi.S
===================================================================
--- libgcc/config/rl78/divmodsi.S	(revision 227024)
+++ libgcc/config/rl78/divmodsi.S	(working copy)
@@ -688,9 +688,14 @@
 	or	a, denB3	; not x
 	cmpw	ax, #0
 	bnz	$den_not_zero\which
+	.if \need_result
+	movw	quotL, #0
+	movw	quotH, #0
+	.else
 	movw	numL, #0
 	movw	numH, #0
-	ret
+	.endif
+	br	$!main_loop_done_himode\which
 
 den_not_zero\which:
 	.if \need_result
