Sometimes passion's gonna away

Pages: 12
Are you telling me that moving e.g. 400 into cpu_registers::ax.al will move 400 into cpu_registers::bx.bl as well?
No. For one, 400 doesn't fit into al, but what I was saying is this:
1
2
3
4
cpu_registers reg;
reg.ax.al=34;
if (reg.ax.al == reg.ax.ah && reg.ax.al==reg.ax.ax)
    //always true 

What you intended to do was
1
2
3
4
union {
    u16 ax;
    struct { u8 ah,al; };
};
No. For one, 400 doesn't fit into al

Oh yeah. :l
Well, if you assume that uint8 is actually typedef'd to a char/byte, then no... but it is typedef'd as such, so... yeah.

@
1
2
3
4
union {
    u16 ax;
    struct { u8 ah,al; };
};

Is that byte-ordering dependant? I assume it is.

Thank you.
I obviated the conditional compilation part, but I think you know what I mean.
Yes, I think so too.
Thanks.
How did the topic of programming passion degenerate into a discussion about emulation?

Passion was easy for me when I was coding in Python. I started every program with:

IMPORT INSPIRATION

Gotta love those modules!

That's what's great about the lounge. Threads start on-topic, but who knows where they'll end up? We had a thread about laziness in programmers recently that turned into a religious argument,..
lmao, this happens to all programmers...


listen to music
over the last 3 months, I've pretty much done nothing but tried to hone my skills in java and c++ while on holidays, by helping people on the forums and getting ideas for stuff to do... However I find this problem as well.
I will start doing projects in C++ just to learn new topics, or do more advanced stuff get bored because I get stuck on the semantics of the language so go back to java where I know I can program more complex things than I can in C++, but after a few days-week I get bored, because the people on java-forums.org are a pack of wankers. No shit, I absolutely hate those forums with a passion, Cplusplus forums are great most of the regulars on here are nice (and forgiving).

Java forums, I was helping someone because he couldn't compile on the command line his first post said exactly his problem and I knew the answer to resolve it. Basically it was only back in November, so current JDK was 1.6.16 he posted he windows environment variable, which was jdk 1.5.28, and said he had just installed the latest JDK but it wasn't working when he typed on the command line.
So naturally I looked at the download page, grabbed the latest release number which was 1.6.16 and noticed there was business edition supporting 1.4.19 or something. So I said "on the download page the latest JDK is 1.6... and business release is back at 1.4 and linked to the download page. you may want to check you have the latest release and update your path." Then I was met by one of the elitist question mark "?" so I had a look at the download page again to make sure, clicked the link which took me to business page and it states that business edition is long term support release. (which naturally costs money).

(I had a fight with this guy earlier because he kept telling me to RTFM and posting a link to the manual, when my code did not need a manual my problem was a syntacatical error. anyway me and someone else on my side ended up fighting with him about it, and I was being nice, but he kept repeating "don't worry in future I won't help you" w/e like i need someone throwing a manual at me when I have an error, turns out this was not an easy to find thing either I can only assume he was lokking at something else thinking it was wrong)...

back OT: I replied about the question mark "Business release is long term support dating back to 1.4, the OP has 1.5 in his path, and the current release is 1.6". He replied "Don't post on the forums when you don't know what your talking about, business release is NOT at 1.4. It's people like you who are arrogant enough to think they can come on here and reply to peoples problems but all you do is lead to more confusion and frustration for the OP" Then another moron chimed in "blah blah Business is 1.6.16 just like the current jdk, it however costs money and I don't think the OP was interested in purchasing I can't see anywhere in his post where he claimed he was interested in buying business release...." Then he went on to ask the OP if there was a javac (exe) in the jdk folder....

Because they both seemly called me a nub, arrogant and an idiot all in the one post, I replied with "Most intelligent people would realise that while I'm not exactly 100% sure of what I'm saying I make a very good point about the OP's problem and seemly have his best interest at heart...." I then go on to explain the problem again...

They chime back in with more abuse and tell the OP to ignore me, this continues on for 5 pages and 3 days. Them asking the OP stupid questions about different folders and javac, and java, and jre and jdk... and abusing me in the middle of their ranting...
Eventually they loose it and start really swearing. So I leave the post. (eventually after the 3 days, it was resolved that he had to update the path, wow what a coinkydink!)

This again happened recently, on a Quiz post. the idea is if you solve a problem to post a new problem. I did this, however posted some code and said Why does the compiler complain there is no main in this code... I meant to say JVM, but I don't typically get caught up in semantics. Needless to say how the rest of the post turned out, But it ended up getting mvoed the admin only forum there was so much abuse. Plus I posted the youtube link of the "Crazy German Kid" and said the poster resembled him. So it apparently turned into a racism argument as well... nothing to do with the kid being a. 12, b.fat, or c. completely raging moron. apparently i was a racist!.

yea, shit like that almost turns me off java for life.

or maybe I just have it too easy here?
Last edited on
hmm no replies that's not a good sign... LOL
Sorry to resurrect such an old topic, but...

@helios,
How does that work for 64 and 32-bit registers?
Does this work:
1
2
3
4
5
6
7
8
9
10
11
12
    /* RAX -> EAX -> AX -> AH/AL */
    union {
        uint64 rax; /* RAX: full 64-bit register */
        uint32 eax; /* EAX: low 32-bits of RAX */
        uint16  ax; /*  AX: low 16-bits of EAX */
        /* AH and AL: high and low 8-bits of AX, respectively */
    #ifdef _BIG_ENDIAN
        union { uint8 ah, al };
    #else
        union { uint8 al, ah };
    #endif
    };


@gcampton,
I read your post, just didn't reply.
Incredible.... a 1-month necrobump!
Still not working. ah and al occupy the same place.
Oh yeah. But if those were structs, then it would be OK?

1
2
3
4
5
6
7
8
9
10
    union {
        qword rax;
        dword eax;
        word ax;
#ifdef BIG_ENDIAN
        struct { byte ah, al; };
#else
        struct { byte al, ah; };
#endif
    } rax;

That's what I have them as at the moment, I don't know why I used unions there...

There's also this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
    /* Note: resN refers to a bit field that is reserved */
    union {
        /* FLAGS */
        struct {
            unsigned int carry          : 1;
            unsigned int res0           : 1;
            unsigned int parity         : 1;
            unsigned int res1           : 1;
            unsigned int adjust         : 1;
            unsigned int res2           : 1;
            unsigned int zero           : 1;
            unsigned int sign           : 1;
            unsigned int trap           : 1;
            unsigned int interrupt      : 1;
            unsigned int direction      : 1;
            unsigned int overflow       : 1;
            unsigned int io_priv_lvl    : 2;
            unsigned int nested_task    : 1;
            unsigned int res3           : 1;
        };

        /* EFLAGS */
        struct {
            unsigned int resume         : 1;
            unsigned int v8086mode      : 1;
            unsigned int align_check    : 1;
            unsigned int vint           : 1;
            unsigned int vint_pending   : 1;
            unsigned int identification : 1;
            unsigned int res4           : (31 - 22); /* Bits 22 to 31 inclusive */
        };

        /* RFLAGS */
        struct {
            unsigned int res5           : (63 - 32); /* Bits 32 to 63 inclusive */
        };
    } rflags;


Anyway, so otherwise, that should work?
Last edited on
Yeah, now it works.
Yay :)

I wasn't sure about the bit fields because I've never used them before; but I thought they would work.

I just realised those bitfields are wrong (res4 and res5). They're not inclusive; I need to add 1 to both of them to make them inclusive.
Last edited on
Topic archived. No new replies allowed.
Pages: 12