Although it looks long, it's quite simple. Don't worry xD
The trading mechanics are the same in Gen IV (HGSS) and Gen V (BW(2)), in Gen VI (XY) it's a little different.
Firstly, you don't need a cord to trade on the DS systems. Don't worry. xD
You will need a second Nintendo DS though, and a second Gen IV game. You will need another Generation VI game (Diamond, Pearl, Platinum, HeartGold, SoulSilver) in order to trade. Then, on both games, go up to the women upstairs (in the Pokemon Center) and talk to the one that allows you to enter the Union Room. You have to enable Wi-Fi (I'm pretty sure that the DS's Wi-Fi is always enabled, but if I'm wrong turn it on on both systems) and enter the Union Room and you will see your alter ego from the other game in the Union Room. xD Talk to him/her and ask him/her to trade. Then, happy trading! The Gen V games are generally the same as well, but you will need two games from Gen V. (Black, White, Black 2, White 2)
However, if you only want to trade just for the purpose of evolving Machoke and Kadabra, you can use the GTS! However, the GTS services will be closing on May 14, 2014 so be quick about it! If you want to use the GTS go the GTS in the games (in DPPt it's Jubilife, in HGSS it's Goldenrod. You must have beaten the the first/third gym leader, respectively) and talk to the lady in there. You have to make sure your DS is connected to the internet. Get in and you can ask for a Kadabra/Machoke, and when you get your Kadabra/Machoke it will evolve! Though remember the GTS will no longer work after May 14, so be quick about it.
In Gen VI it works slightly differently. Assuming you've flicked the wireless switch on the side of the 3DS system, your trading partner (or your other game, which has to be either another copy of X or Y) will appear in the 'Passersby' sections. Click on the dude you have and then click 'Trade', then do everything the game tells you from there. You can also use the GTS by clicking the menu circle on the top of the bottom screen and find the GTS button. Click that, and assuming you have internet access, you'll be on! :D Unlike the Gen IV-V one, the Gen VI GTS is not closing. No need to rush on this one! So yeah.
I hope I explained everything well. xD
This seems rather complicated - if you have any question feel free to comment. :D
Hope I helped. :)