|
Wordle 1,083 4/6
β¬β¬β¬π©β¬
β¬β¬β¬π©π©
β¬π©π¨π©π©
π©π©π©π©π©
|
|
|
|
|
Wordle 1,083 6/6
π¨β¬β¬β¬β¬
β¬π¨π¨β¬β¬
β¬β¬β¬β¬β¬
π¨π¨π¨β¬β¬
β¬π¨β¬π©β¬
π©π©π©π©π©
|
|
|
|
|
Wordle 1,083 4/6
β¬β¬β¬β¬π¨
π¨π¨β¬π©β¬
β¬π©β¬π©π©
π©π©π©π©π©
Ok, I have had my coffee, so you can all come out now!
|
|
|
|
|
This might be interesting.
Background
I'm learning RISC-V assembly and I've written an article (here on CP) on how to run a RISC-V-based version of Debian via QEMU on your machine.
You can run QEMU on Windows, Mac or Linux and then emulate the RISC-V-based Debian on any of those systems. QEMU emualtion is fairly lightweight and very cool. The android emulator, for example, runs via QEMU.
It's a nice easy (safe) way to learn RISC-V Assembly.
The Main Story
I was thinking about how I'd also like to learn x86_64 Assembly on Windows because of this book, The Art of 64-Bit Assembly, Volume 1: x86-64 Machine Organization and Programming[^]
I'm on a Mac right now and I'm normally on a desktop running Ubuntu 22.04.4.
I started thinking, "Hey, can I emulate Windows / DOS in QEMU so I can run MASM and learn Assembly there?"
Nope! Not really.
I know I can run Windows via VirtualBox but wow, that is interesting that Microsoft OS is such a huge bloatware that you can't really run just a "command-line version" of it.
There are so many options with Linux that it really is amazing.
Also, I know I shouldn't even have thought of doing this bec "it's windows, after all", but just thought it was an interesting point that displays how different Windows v Linux really is.
EDIT UPDATE
And, of course, I can always learn x86_64 assembly on the Linux side and one of my top-5 all-time favorite authors updated his book on it recently: x64 Assembly Language Step-by-Step: Programming with Linux [^]
|
|
|
|
|
This reminds of an amusing story about emulation. This was quite some time ago but when I was in college a few friends wrote an emulator for the Control Data mainframe the school had. You could take programs written for the mainframe, which I believe was a 36-bit machine, and run them in their emulator with file and terminal I/O and just about everything. The funny part was their emulator running on an 80286 ran the programs faster than the actual machine did. We all get a good chuckle out of that.
"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?"
|
|
|
|
|
Rick York wrote: their emulator running on an 80286 ran the programs faster than the actual machine did. We all get a good chuckle out of that.
Very cool! Devs can do amazing things when they are motivated.
Usually the motivation has nothing to do with managers, but instead some technical challenge that "can't be done".
|
|
|
|
|
I guess if you are bored or into sadomasochism you decide to learn assembly today. Pure C does it better. I recommend gardening with chainsaws or plowing with explosives. I'm messing with you... But to this day, the ONLY reason I can see injecting assembly into a code base is for a very, very special occasion - say a space craft on its way out of the solar system with 8k of ram.
History - my first and only assembly class was on, I $hit you not, an IBM 360 mainframe where 200+ of us delved into the mysteries of computer architecture. WTF is a stack, and why is it important? How do I code for a subroutine and maintain data? And on. After the vikings got done beating on us, the lights came on and we raped and pillaged their villages.
To this day, 40+ years later, I can visualize a stack and actually explain it to someone with a masters degree in CS. Mind you, this was all on punch cards and printouts. I was in engineering school - we were not allowed to use the terminals.
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.
|
|
|
|
|
charlieg wrote: ...if you are bored or into sadomasochism you decide to learn assembly... Naw, directly coding the hardware is cool.
There are no solutions, only trade-offs. - Thomas Sowell
A day can really slip by when you're deliberately avoiding what you're supposed to do. - Calvin (Bill Watterson, Calvin & Hobbes)
|
|
|
|
|
I know, I know
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.
|
|
|
|
|
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.
|
|
|
|
|