Upvote:2
Germany and Spain are both in the Schengen area, so your 90-day limit applies to them together (along with all the other Schengen countries). The 90-day limit applies to every 180-day period, regardless of the number of times you leave and re-enter the Schengen area.
Because you spent three calendar days entirely outside the Schengen area (namely in the UK from 26 August through 28 August), the last day for you to leave the Schengen area is 8 October 2017. (That's 49 days from 8 July to 25 August, plus 41 days from 29 August to 8 October.)
If you leave on 8 October, you won't be able to enter the Schengen area until 4 January 2018 (180 days after 8 July 2017). If you leave earlier, then you can re-enter earlier.
Upvote:3
If you stay within the Schengen area, 90 days that started on 8 July will end on midnight after 5 October. If you leave the area on the last possible day, you then need to stay outside for 90 days before you can enter again.
The 90 days you can be inside Schengen have to last you for the entire 180-day period from 8 July until 3 January. You can spread them out however you want, as long as there are no more than 90 different dates where you are inside Schengen for any part of that date.
Exiting and re-entering will not change that -- the only* way to get "more days" would be to get a national long-stay visa or residence permit from one of the member countries, which is not likely on short notice.
(After 3 January, counting gets a bit more involved because it's a rolling 180-day period, but that needs not concern you right now).