Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress warning on unaligned pointer #3

Closed
wants to merge 1 commit into from

Conversation

Marcussacapuces91
Copy link

Using TDM-GCC 9.2.0 with Embarcadero Dev-C++ 6.3 (under Windows 10)
sources\Z80.c [Warning] taking address of packed member of 'union ' may result in an unaligned pointer value [-Waddress-of-packed-member]

Using TDM-GCC 9.2.0 with Embarcadero Dev-C++ 6.3 (under Windows 10)
sources\Z80.c	[Warning] taking address of packed member of 'union <anonymous>' may result in an unaligned pointer value [-Waddress-of-packed-member]
@redcode
Copy link
Owner

redcode commented Aug 1, 2021

what about this instead?

#define ADD_RR_NN(RR, NN)							      \
	zuint16 nn = NN;							      \
	zuint16 t  = RR + nn;							      \
										      \
	F =	F_SZP				     | /* SF, ZF, PF unchanged	   */ \
		((t >> 8) & YXF)		     | /* YF = high-Y; XF = high-X */ \
		(((zuint16)(RR ^ nn ^ t) >> 8) & HF) | /* HF = high-half-carry	   */ \
		((zuint32)RR + nn > 65535);	       /* CF = carry		   */ \
						       /* NF = 0		   */ \
	RR = t;

@redcode
Copy link
Owner

redcode commented Aug 1, 2021

This version of the Z80 library is very old. I'm going to release a new version very soon with the following changes:

  1. Changed the license from GPL to LGPL (by popular request).
  2. Moved the public header from <emulation/CPU/Z80.h> to <Z80.h>.
  3. Switched the build system from Premake to CMake.
  4. Switched to Z v0.1.
  5. Added CocoaPods support.
  6. Added pkg-config support.
  7. Added the THANKS file.
  8. Added the .vimrc dotfile.
  9. Added detailed documentation.
  10. Added tests.
  11. Removed the Xcode project.
  12. Fixed a bug in the sll instruction.
  13. Fixed a bug in the INX and OUTX macros affecting the N flag.
  14. Fixed a bug in the OUTX macro affecting the MSByte of the port number.
  15. Fixed the clock cycles of the dec XY and in (c) instructions.
  16. Fixed the read_16 function to prevent invoking the Z80::read callback in
    reverse order on some compilers.
  17. Fixed the handling of illegal instructions to avoid stack overflow in long
    sequences of DDh/FDh prefixes.
  18. Fixed several implicit conversions to avoid warnings about loss of sign or
    precision.
  19. Fixed some bitwise operations to avoid undefined behavior and arithmetic
    right shifts on signed integers.
  20. Fixed violations of the C standard in several identifiers.
  21. Renamed the 8-bit register lists: X/Y as J/K; J/K and P/Q as O/P.
  22. Replaced all P/V overflow computation functions with a single, faster macro.
  23. Replaced all register resolution functions with macros.
  24. Replaced all ld J,K instructions that have the same source and destination
    register with nop.
  25. Reimplemented the HALT state. The emulation should now be fully accurate.
  26. Added optional emulation of the normal RESET and the special RESET signals,
    along with the new z80_normal_reset and z80_special_reset functions to
    trigger them. The z80_reset function has been renamed to z80_instant_reset
    and still performs an immediate normal RESET ouside the z80_run function.
  27. Added a disregarded opcode fetch to the NMI acknowledge cyle.
  28. Added optional full interrupt mode 0 emulation.
  29. Added MEMPTR emulation. The bit N,(hl) instruction now produces a correct
    value of F.
  30. Added optional emulation of the Q "register". When enabled, the ccf and
    scf instructions produce a correct value of F.
  31. Added CPU model selection.
  32. Added emulation of the out (c),255 instruction (Zilog Z80 CMOS).
  33. Added optional emulation of the P/V bug (Zilog Z80 NMOS).
  34. Added hooking functionality through the ld h,h instruction.
  35. Added new callbacks: Z80::fetch, Z80::hook, Z80::inta, Z80::read_bus and
    Z80::reti.
  36. Removed Z80::int_data (use Z80::read_bus instead).
  37. Removed Z80::state. Replaced with individual members for the registers, the
    interrupt enable flip-flops and the maskable interrupt mode.
  38. Removed the uneeded EI flag. The opcode of the last instruction is checked
    instead. This is faster and makes the Z80 object smaller.
  39. Removed all module-related stuff.
  40. Optimizations in flag computation and condition resolution.
  41. New source code comments and improvements to existing ones.
  42. Improved code aesthetics.
  43. Other improvements and minor changes.

So, you will have to excuse me, but I'm not going to merge your pull request, because that warning is already solved in the new version.

Thanks.

@redcode redcode closed this Aug 1, 2021
@Marcussacapuces91
Copy link
Author

You are all excused!
Thanks for this amazing work.

@redcode redcode added the warning Something produces a warning label Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
warning Something produces a warning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants