|
charlieg wrote: I guess if you are bored or into sadomasochism you decide to learn assembly today.
Yeah, I don't like pain much, but a little mental pain is ok, I guess.
I cannot find a reason to learn Assembly either, but I do have my excuses.
1. I will understand what is really happening better.
2. I work with some electronics components (embedded) so I just wondered what was possible if I better understand assembly.
Here's a very weird thing. I was reading the 1st ed. of C++ For Dummies (pub in 1994) the other day and I stumbled upon this quote:
"However, a register variable is not stored in memory but cached in a register of the processor. Becuase register variables are not in memory they have no address."
And then much later in the book...
"Null pointer assignment is Borland and Turbo C's way of telling you that you screwed up the the pointer and wrote to location 0 in the default data segment."
I read that book back in 1994 & had no idea what it was talking about.
Now that I'm learning Assembly and I've discovered the .data segment of my programs I know what it means. So, you can plainly see how important this is, I'm sure.
|
|
|
|
|
well like I said, having to do it slammed home the concept of pushing things on the stack. Once we got through the next few homework assignments, you could see the light bulbs coming on. Pushing and popping off the stack went from some sort of supernatural operation to an oh, of course. The classmates survived transformed it to a tool. Move forward 30+ years. Ask your next job candidate to explain stack operations, the difference between passing by pointer or reference, etc. Be prepared to watch their heads explode.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
follow up - yes sir, been there.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
Completely agree.
C/C++ programmer really understands, how things are working, only having Assembly knowledge.
I am not writing Assembly, but Assembly knowledge helps me to write much better C/C++/C# code.
BTW, one practical Assembly usage in my work is debugging optimized code.
|
|
|
|
|
Ah memories (if we had any)
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
My takeaway from Microsoft is they have the best code editors and IDEs, but the worst environments and toolchains in terms of development.
Linux is all around a better all purpose development platform if you had to pick one.
The reason I main windows is because I can use WSL and WSA, plus I have a lot of apps that are windows only, but if i was strictly doing like, embedded dev I'd probably main linux.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
honey the codewitch wrote: My takeaway from Microsoft is they have the best code editors and IDEs, but the worst environments and toolchains in terms of development.
That comment is full of insight. I thought about it for a long while and that really is exactly it.
I've always liked Microsoft's Visual Studio (which started out as Visual C++ and Visual Basic).
The IDE has always been great and now I really like Visual Studio Code.
You're right about the toolchains etc. Just a kludged up mess really.
Once you use Linux and get used to some of the light-weight tools you really see the how ugly stuff is under Windows.
|
|
|
|
|
I blame AAPL.
Seriously... they're more than a little bit responsible for the 90s antitrust stuff.
Linux has grown to be a good hosting platform.
A good platform to actually try to get things done on though? No. No, I do not believe it's quite remotely close to Windows yet.
Toolchains? Yeah sure let me go figure out how to even start building one... First step, let's sort out this makefile so we can compile a binary. Oh but we need that other version of C... What? Why does this need Python?
|
|
|
|
|
You can use DOS alone if you only want to learn x86 asm using MASM...
"If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization." ― Gerald Weinberg
|
|
|
|
|
The first few applications I ever wrote for PCs were in 8086 assembler. But when I moved on to C and its derivatives I sort of forgot it all. I have recently been writing some simple assembler applications and discovering how easy it is to access the Windows API from it. I found a free download of https://www.amazon.co.uk/Modern-X86-Assembly-Language-Programming/dp/1484240626[^] but cannot find where I got it from now.
|
|
|
|
|
Sounds like you are having an interesting, and learning, adventure. Keep in mind that back in the day (can you say the '60's?) resources were rather scarce. The language choice, on some of the systems I worked on, was Assembler or Fortran! Base system had 4K of 16 bit, core storage memory, either 2 or 4 microsecond. Paging to and from (small) disk was painful. The level below assembler was machine language input via bit switches.
Real time systems required assembler. 4 levels of interrupts and 15 levels of cycle steal. Creating re-entrant subroutines was challenging. One hasn't lived until assembling and linking a program written on paper tape, on a 4K system.
>64
It’s weird being the same age as old people. Live every day like it is your last; one day, it will be.
|
|
|
|
|
|
I'm programming a 2D RPG game that uses an array of derived class instance pointers. For clarity I provide a code example in C++. I would like to sort the elements of the entities array based on the worldY value of each element.
main.cpp:
<pre lang="C++">
/*
* result:
* player
* object
* object
* npc
* npc
* 2 npc y: 30
* 1 npc y: 6
* 1 object y: 20
* 2 object y: 10
* player y: 0
*/
#include <iostream>
#include <vector>
#include <algorithm>
#include "Entity.h"
#include "Npc.h"
#include "Player.h"
#include "Object.h"
int main()
{
Player* player = new Player();
std::vector<Entity*> objs;
std::vector<Entity*> npcs;
std::vector<Entity*> entities;
Entity* tmp = new OBJ_o();
objs.push_back(tmp);
objs.at(0)->worldY = 20;
objs.at(0)->ID = "1";
tmp = new OBJ_o();
objs.push_back(tmp);
objs.at(1)->worldY = 10;
objs.at(1)->ID = "2";
tmp = new NPC();
npcs.push_back(tmp);
npcs.at(0)->worldY = 6;
npcs.at(0)->ID = "1";
tmp = new NPC();
npcs.push_back(tmp);
npcs.at(1)->worldY = 30;
npcs.at(1)->ID = "2";
//--------------- update -------------------
player->update();
for (auto iter_objs = objs.begin(); iter_objs != objs.end(); ++iter_objs)
{
(*iter_objs)->update();
}
for (auto iter_npcs = npcs.begin(); iter_npcs != npcs.end(); ++iter_npcs)
{
(*iter_npcs)->update();
}
//-------------- entities --------------------
entities.push_back(player);
for (int i = 0; i < objs.size(); i++)
{
if (!objs.at(i)->name.empty())
{
entities.push_back(objs.at(i));
}
}
for (int i = 0; i < npcs.size(); i++)
{
if (!npcs.at(i)->name.empty())
{
entities.push_back(npcs.at(i));
}
}
// sort entities
std::sort(entities.begin(), entities.end());
//---------------- draw entities ------------------
for (auto iter = entities.begin(); iter != entities.end(); ++iter)
{
std::cout << (*iter)->ID << " ";
(*iter)->draw();
}
return 0;
}
Entity.h
#pragma once
#include <iostream>
class Entity
{
public:
int worldY = 0;
std::string name;
std::string ID;
public:
virtual void update() { std::cout << "base" << std::endl; }
virtual void draw() { std::cout << "base y: -\n"; }
bool operator<(const Entity& obj) const
{
return worldY < obj.worldY;
}
};
Npc.h
#pragma once
#include "Entity.h"
class NPC : public Entity
{
public:
NPC();
void update() override;
void draw() override;
};
Npc.cpp
#include "Npc.h"
#include <iostream>
NPC::NPC() { name = "npc"; }
void NPC::update() { std::cout << name << std::endl; }
void NPC::draw() { std::cout << "npc y: " << worldY << std::endl; }
Player.h
#pragma once
#include "Entity.h"
class Player : public Entity
{
public:
Player();
void update() override;
void draw() override;
};
Player.cpp
#include "Player.h"
#include <iostream>
Player::Player() { name = "player"; }
void Player::update() { std::cout << name << std::endl; }
void Player::draw() { std::cout << "player y: " << worldY << std::endl; }
Object.h
#pragma once
#include "Entity.h"
class OBJ_o : public Entity
{
public:
OBJ_o();
void update() override;
void draw() override;
};
Object.cpp
#include "Object.h"
#include <iostream>
OBJ_o::OBJ_o() { name = "object"; }
void OBJ_o::update() { std::cout << name << std::endl; }
void OBJ_o::draw() { std::cout << "object y: " << worldY << std::endl; }
(see result put as comment at the beginning of Main.cpp).
How should I do an increasing order of y (worldY) ?
Using:
std::sort(entities.begin(), entities.end());
I don't get the desired result:
player
object
object
npc
npc
player y: 0
1 npc y: 6
2 object y: 10
1 object y: 20
2 npc y: 30
|
|
|
|
|
Please read the red text a little bit above your post. It talks about how this is not the appropriate place for a post of this nature.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
As many people are about to tell you. There are no programming questions in the lounge. You should probably post this in the Quick Answers instead.
|
|
|
|
|
|
Working on a remote server for a customer - has VS 2015 installed. Microsoft has decided through it's "magic" that I don't have a license anymore. Fine, I'll update you to community edition. Nope, have to uninstall first. Okayyyy, go to the Apps and Features for VS 2015 - no uninstall option. I have to "modify" the installation. Okayyyy... it's been going for 4 hours now.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
Wouldn't it be the customer who needs the license, since it's installed on their machine?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
technically maybe? I'm a small company so on occasion I will install CE to complete some debug work. Then I remove it. Today's phrase is "if I Can remove it."
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
The risk here is that you end up partially removing the older version, and failing to install the new one. Then you have two problems on your hands - getting the original reinstalled, and solving its license problem.
|
|
|
|
|
Hey! No spoilers in the lounge!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
well sure, but I *know* it's a vm, SO, YOU GO BACK TO THE ORIGINAL. Damn new keyboard... sorry about that
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
I didn't bring it up, but that's exactly what I was thinking. Checkpoint, tinker with it all you need, if it works, re-merge to make it the latest, otherwise roll back.
|
|
|
|
|
A colleague once installed the wrong version of VS on a fresh Windows version. Once he saw the uninstall (lack of) progress indicator he did the smart thing and wiped the disk and reinstalled Windows.
|
|
|
|
|