code logs -> 2007 -> Wed, 11 Apr 2007< code.20070410.log - code.20070412.log >
--- Log opened Wed Apr 11 00:00:53 2007
00:01
<@ToxicFrog>
Shiny.
00:01
<@McMartin>
Interaction still doesn't work the way I think it should, though.
00:01
<@McMartin>
In particular, scrolling the list of games scrolls the headers out of visibility, which is WRONG WRONG WRONG
00:01
<@ToxicFrog>
o.O
00:02
<@McMartin>
I must conclude that a ListView inside a ScrolledWindow are not intended to have headers enabled.
00:03
<@Vornicus>
Shouldn't ListView create its own scrollbar inside it, if necessary? That's what other systems do.
00:03
<@McMartin>
Also, the arrow keys correctly control the ListView, but it does not scroll to track the selection.
00:03
<@McMartin>
No, the ListView makes the window larger or cuts itself off.
00:03
<@McMartin>
If you have, say, 200 files, it tries to make a 2000 pixel-tall widget and resizes appropriately.
00:03
<@Vornicus>
cute.
00:03 * McMartin had similar problems with the Image widget.
00:04
<@McMartin>
Well, TreeView, not ListView.
00:05 * McMartin checks the method list.
00:06
<@McMartin>
OK, there is a scroll-to-cell method.
00:07
< Doctor_Nick>
currrrrrrsed
00:08 MyCatVerbs is now known as MyCatSleeps
00:09
<@McMartin>
It doesn't appear to actually do anything though.
00:44
<@McMartin>
Ha HA
00:44 * McMartin gets it.
00:45 * McMartin needs to add() it to the ScrolledWindow, not add_with_viewport() it.
00:45
<@Vornicus>
aha
00:46
<@McMartin>
The unresizable cover-art widget is less of an issue.
00:54 * Vornicus tries to figure out some structs for things.
01:15 * Vornicus examines the GBA programming guide.
01:20 * Vornicus determines that it is not that useful.
01:21 * Vornicus needs heavy-duty analysis tools!
01:22
<@McMartin>
ARM disassemblers shouldn't be too hard to find.
01:22
<@Vornicus>
I like how "ARM disassembler Mac" gives me... IDA Pro, because it can disassemble Mac programs.
01:23
< Doctor_Nick>
Ida Pro is good stuff
01:23
<@Vornicus>
If only it came in flavors other than Windows.
01:23
<@McMartin>
I just had HTE recommended to me.
01:23
<@McMartin>
I don't think it does ARM though.
01:23
< Doctor_Nick>
I thought there was a linux binary?
01:23
< Doctor_Nick>
let me check the developers forum
01:23
<@McMartin>
http://hte.sourceforge.net/
01:26 * McMartin goes to actually try it out
01:26 * Vornicus is reminded that he has wanted to write something like a pluggable ResEdit for a long time.
01:27
< Doctor_Nick>
huh
01:27
< Doctor_Nick>
i guess not
01:27
<@McMartin>
ls
01:27
<@McMartin>
Oops
01:27
<@Vornicus>
Even if there were a Linux binary, that assumes I can run a Linux binary.
01:27
< Doctor_Nick>
there's no mac binary either :P
01:29 * Vornicus buildinates HTE
01:30 * Vornicus ...can't buildinate HTE, it assumes the existence of numeric types that it does not check for.
01:34
<@McMartin>
Argh
01:34
<@McMartin>
HTE assumes that you don't have your function keys bound to anything.
01:34
<@McMartin>
Or, you know, Alt-F.
01:34
<@Vornicus>
Cute.
01:54
<@ToxicFrog>
HTA?
01:55
<@ToxicFrog>
HTE, rather?
01:55
<@ToxicFrog>
Oh. Disassembler.
01:56 * Vornicus mashed together the two acronyms and thought "Dinner is MEAT. RAW meat."
01:59 * ToxicFrog was thinking "<something> the Echidna"
01:59 gnolam [lenin@Nightstar-13557.8.5.253.se.wasadata.net] has quit [Quit: Z?]
02:00
<@Vornicus>
Harangue, clearly.
03:53 Thaqui [~Thaqui@Nightstar-763.worldnet.co.nz] has joined #code
03:53 mode/#code [+o Thaqui] by ChanServ
04:13 Chalcedon [Chalceon@Nightstar-2427.dialup.ihug.co.nz] has joined #code
04:13 mode/#code [+o Chalcedon] by ChanServ
04:30 Chalcedon [Chalceon@Nightstar-2427.dialup.ihug.co.nz] has quit [Quit: ]
04:35
<@Vornicus>
Arg. I haven't gotten anywhere.
04:35
<@Vornicus>
I am half-tempted to write a disassembler.
04:35
<@McMartin>
They're kind of fun.
04:36 * Vornicus needs an ARM reference document.
04:40
<@McMartin>
Should be foindable
04:40
<@McMartin>
The ARM/THUMB distinction will suck.
04:41
<@Vornicus>
THUMB being the 16-bit extra-fast mode?
04:41
<@McMartin>
Yeah
04:43 * Vornicus hunts around
04:43
<@Vornicus>
Okay, so far the only reference I've "found" links to a squatter site
04:44
<@Vornicus>
here's one that gives the commands but not the codes...
04:45 * Vornicus pokes at his Official Romhacking Resource.
04:45
<@Vornicus>
TF! Heelp!
04:45 Chalcedon [Chalceon@Nightstar-1031.dialup.ihug.co.nz] has joined #code
04:45 mode/#code [+o Chalcedon] by ChanServ
04:45
<@ToxicFrog>
augh
04:46
<@ToxicFrog>
http://www.romhacking.net/docs/GBA%20Programming%20Manual%20v1.1.pdf ?
04:46
<@ToxicFrog>
I don't know if that includes the opcodes, though.
04:47
<@Vornicus>
That doesn't have any actual information on the opcodes or anything of the ARM processor
04:47
<@Vornicus>
I think I've found something, I looked up "re-eject" and found a decent cribsheet
04:49
<@ToxicFrog>
http://www.arm.com/documentation/ARMProcessor_Cores/index.html
04:50
<@Vornicus>
THis is called "places I should have looked in the first place"
04:50
<@ToxicFrog>
Shockingly, the processor manufacturer often has reference materials~
04:51
<@McMartin>
But only often.
04:51
<@McMartin>
Fanpages are better for the 6502 variants.
04:52 * Vornicus finds the right ARM processor: ARM7TDMI
04:53
< Doctor_Nick>
wikipedia has everything
04:53
<@McMartin>
No.
04:53
<@McMartin>
Wikipedia often has references to the actual data.
04:53
<@McMartin>
It very rarely actually has the reliable data itself
04:54
< Doctor_Nick>
Vornicus: there's multiple arm processors on the GBA? I thought it was just the arm and the z80?
04:54
<@McMartin>
Doctor_Nick, you really need to start reading every line in the conversation instead of every fifth one.
04:54
<@McMartin>
His goal here is to write a disassembler for the GBA ROMs.
04:54
<@McMartin>
In order to do this, he needs to know which numbers mean which instructions.
04:54
<@McMartin>
There are about 14,000 different ARM cores.
04:55
<@McMartin>
ARM7TDMI is the one that matters.
04:55
<@ToxicFrog>
Remind me, why is Doctor_Nick in this channel?
04:56
<@Vornicus>
Because he's not as much of an idiot as Mischief
05:01
<@ToxicFrog>
And?
05:01
<@Vornicus>
Granted, that says little
05:07 * Vornicus examines the cribsheet and the arm reference.
05:08
<@McMartin>
Ha ha
05:08 * McMartin finds a rule he can loot
05:09
<@Vornicus>
Looks like there's also an "Architectural REference Manual", which they don't offer for download
05:09
<@McMartin>
And ARM ARM?
05:09
<@McMartin>
s/And/An/
05:09
<@Vornicus>
Funny you should say that, I have located a thing that calls it ARM ARM
05:10
<@Vornicus>
Ah, there one is.
05:11
<@McMartin>
"WARNING FOR THE REALITY-IMPAIRED: This game is a work of fiction based upon a pack of lies."
05:11
<@Vornicus>
Heh
05:11 * Vornicus needs a printer.
05:12 * Vornicus now has the ARM ARM.
05:12
<@McMartin>
ARM disassembly should be less painful than x86, anyway.
05:13
<@McMartin>
ISTR it having fixed-size instructions.
05:14
<@Vornicus>
It has 32-bit instructions
05:18
< Doctor_Nick>
McMartin: I thought he meant "right" as in "to the right of something"
05:18
< Doctor_Nick>
and I was thinking of the DS, which has an ARM9 and an ARM7
05:41 Thaqui [~Thaqui@Nightstar-763.worldnet.co.nz] has left #code [Leaving]
05:45 * Vornicus fiddles
05:51
<@Vornicus>
Oh. THAT is how it does it.
05:52
<@ToxicFrog>
?
05:53
<@Vornicus>
ARM processors can encode a condition into any given instruction; if the condition is not met (by what?) then the instruction is skipped
05:53
<@ToxicFrog>
o.O
05:53
<@McMartin>
Yeah.
05:53
<@McMartin>
"Skip if zero flag not set"
05:53
<@McMartin>
It lets you do small conditional tests without fuxx0ring your branch predictor.
05:55
<@Vornicus>
now if I could find a reference for all these single letter things...
05:55
<@ToxicFrog>
That is pretty sweet.
05:56
<@Vornicus>
I think the flags are set by the results of the last instruction
05:56
<@McMartin>
Yes
05:56
<@McMartin>
It's like the Zero/Neg/Overflow flags on 6502 (and x86?)
05:56
<@McMartin>
My ARM-fu is weak.
05:56
<@McMartin>
But I remember reading up on this once, so that I could more credibly mock the Itanic.
05:57 McMartin is now known as McMartin[afk]
06:00 ReivZzz is now known as Reiver
06:01
< Doctor_Nick>
McMartin: That's like picking on the retarded kid at school :/
06:02
<@ToxicFrog>
McMartin[afk]: the x86 and 68k have similar flags, yes.
06:03
<@ToxicFrog>
The ability to set a skipifZ flag on any instruction is really quite sweet.
06:04
<@Vornicus>
you can also do it on negative, overflow, carry, various comparisons (though I'm not sure how that madness works)...
06:12 McMartin[afk] is now known as McMartin
06:13
<@McMartin>
The Itanic had something like 20 of those.
06:14
<@Vornicus>
The ARM has 16 different conditional checks available, but one is technically "never" and is not used.
06:16
<@Vornicus>
(well, one instruction with a "never" command is used to transition to THUMB)
06:33 mode/#code [+ooo EvilDarkLord MyCatSleeps TheWatcher[zZzZ]] by Reiver
06:33 mode/#code [+v KarmaBot] by Reiver
06:34 Thaqui [~Thaqui@Nightstar-27386.jetstream.xtra.co.nz] has joined #code
06:34 mode/#code [+o Thaqui] by ChanServ
06:34
<@Reiver:@#Code>
if Doctor_Nick gets too annoying, bear in mind that Code is not Officially an Official channel, and thus our rules on what is bootworthy and isn't are vastly more lax... and I personally don't much care whether annoyances stay or leave, myself. >.>
06:35 * Vornicus breaks out the Python and the ctypes module.
06:35
<@McMartin>
Oooh! And struct!
06:35
<@McMartin>
Don't forget struct
06:35
<@ToxicFrog>
Mmm struct.
06:35
<@Vornicus>
And struct.
06:35
<@ToxicFrog>
Mine's better ??
06:35 * McMartin would start with just a "Dissassemble range" command, and not worry about dataflow until Later.
06:36
<@Vornicus>
of course.
06:36 * McMartin has 6502 dissassembling python around here somewhere that did a bit of dataflow; he used it to pick apart Gradius's main loop.
06:36 * Vornicus is currently working on "decode instruction"
06:36
<@McMartin>
Hum, though actually.
06:36
<@McMartin>
Do ARM instructions have to be word-aligned?
06:36
<@McMartin>
If so, the code/data distinction is way less important.
06:37
<@Vornicus>
They're a whole word long, I think they are word-aligned. Let me see if I can find a definite statement.
06:39
<@Vornicus>
ARM is word-aligned; THUMB is half-word-aligned.
06:39
<@McMartin>
Mmm. Life is less good, then.
06:39
<@McMartin>
You have to distinguish between ARM and THUMB.
06:40
<@Vornicus>
Right - but even if I have to do that I can easily decode both.
06:40
<@McMartin>
But in either case accidentally disassembling data won't throw off instruction starts.
06:40
<@McMartin>
IIRC most ARM code will be written to be relocated for the GBA, and core code will be THUMB.
06:41
<@Vornicus>
what do you mean, "relocated"?
06:42
<@McMartin>
So, the GBA has a 16-bit bus to ROM, and a 32-bit bus to its RAM.
06:43
<@McMartin>
ARM code is likely to be written to be loaded into RAM and run there, where entire words can be fetched at once.
06:43
<@Vornicus>
Ah, so it will copy the ARM code to RAM so it's faster
06:43
<@McMartin>
Yeah.
06:45 Chalcedon [Chalceon@Nightstar-1031.dialup.ihug.co.nz] has quit [Quit: ]
06:54
<@Raif:@#Code>
Err... Wrong alias.
06:55
<@Vornicus:@#code>
Don't look at me, I'm indifferent.
06:55
<@Raif:@#Code>
Oh, you're different all right.
06:56
<@Raif>
So why are you trying to emulate ARM anyway?
06:57
<@McMartin>
Disassemble it. So he can rip data from Metroid Zero Mission.
06:57
<@Thaqui>
Would someone explain to me why half a million PM windows just popped up? o.O
06:59
<@Vornicus>
Because somehow I went from reading RLE data from a few select places in MZM to trying to /find/ these select places to trying to figure out what the hell is pointing at what to trying to figure out what the various structures are like to ...
06:59 Doctor_Nick [~fdsaf@Nightstar-27777.rag-a.fsu.edu] has quit [Ping Timeout]
06:59
<@Vornicus>
and it just kind of went downhill from there.
06:59
<@Vornicus>
That said, I have wanted to write a disassembler for quite some time.
07:00
<@ToxicFrog>
Thaqui: someone messaging @#Code, I think.
07:02
<@Reiver>
Don't look at me, I notice Code. On real IRC clients, that shows up in-channel. ¬¬
07:03
<@Reiver>
And I don't personally have a problem with Doctor_Nick. But if he's annoying people, *shrug*
07:03
<@Reiver>
I'm not going to hold a torch against a "You annoy me. *boot*". :p
07:03 * Vornicus doesn't see it, obviously
07:12
<@ToxicFrog>
He wasn't that bad today, actually.
07:13
<@ToxicFrog>
But most of the time he's either completely random and offtopic, or openly irritating.
07:13
<@ToxicFrog>
Thankfully, he rarely talks.
07:13
<@ToxicFrog>
Anyways, sleeptime.
07:13
<@Thaqui>
In other news, now I'm trying Objective C, I may talk more.
07:17
<@McMartin>
I think Vorn's the closest thing we have to an expert on that
07:17
<@McMartin>
Though it's possible that you may end up the expert.
07:19 * Vornicus has used Objective C exactly twice, and didn't get it.
07:23
<@Thaqui>
I plan on writing stuff for OSX.
07:24 * McMartin nods
07:24 * Vornicus IS the expert on OSX.
07:25
<@Reiver>
Objective C?
07:26
<@Thaqui>
As opposed to Emotional C.
07:26
<@Vornicus>
Take C and push it toward Smalltalk instead of C++.
07:26
<@Reiver>
-.^
07:26
<@Reiver>
Smalltalk being...
07:26
<@Vornicus>
A language.
07:27
<@Reiver>
I figured that
07:27
<@Reiver>
I was more wondering, uh
07:27
<@Vornicus>
One of the Great Granddaddies of object-oriented programming, alongside Simula
07:27
<@Reiver>
Ahhhhh.
07:27
<@Vornicus>
It is /wacky/ and /strange/
07:28
<@Vornicus>
And everybody who programs in it seems to look down on every other programming language ever
07:29
<@Thaqui>
I find that strange.
07:29
<@Thaqui>
Programmers... being able to *look down* on others?
07:30
<@McMartin>
Very common.
07:31
<@McMartin>
It's got all the arrogance that is the lot of writers, plus the stuff they write can jump, dance, and do tricks.
07:32
<@Vornicus>
But the whole "smalltalk rules your world" thing pisses me off.
07:33
<@Vornicus>
-- mainly because I have found lots of reasons to not use it (not least being it runs entirely in a crappy little sandbox) and and no reasons to use it.
07:41 * Vornicus gets condition testing right. now what?
07:45
<@McMartin>
Giant, hopefully auto-generated, dictionary mapping opcode to mnemonic.
07:45
<@McMartin>
If you've got that, then operands.
07:46
<@Vornicus>
It looks like it gets more specific as I go down; next three bits are an approximate operand type
08:06 Thaqui [~Thaqui@Nightstar-27386.jetstream.xtra.co.nz] has quit [Ping Timeout]
08:13 Thaqui [~Thaqui@Nightstar-11312.jetstream.xtra.co.nz] has joined #code
08:13 mode/#code [+o Thaqui] by ChanServ
08:33 Thaqui [~Thaqui@Nightstar-11312.jetstream.xtra.co.nz] has quit [Quit: Leaving]
08:49
<@Vornicus>
...and because of the richness of the conditional thing, it's used to create all the actual branching things.
08:50
<@Vornicus>
okay, I /really/ like ARM.
08:54 Thaqui [~Thaqui@Nightstar-11312.jetstream.xtra.co.nz] has joined #code
08:54 mode/#code [+o Thaqui] by ChanServ
09:07
<@McMartin>
Hmm. At some point it really should be cheaper to do the branch.
09:08
<@Reiver>
Is ARM a programming langauge, or a quirk of the codebase Vorn is reverse engineering?
09:08
<@Vornicus>
ARM is a processor architecture.
09:08
<@Vornicus>
Used in the GBA.
09:11 Serah [~Z@87.72.36.ns-26407] has quit [Ping Timeout]
09:11
<@Vornicus>
I am reverse engineering a published GBA game, and I am looking at raw data and machine code.
09:12
<@Vornicus>
8 megabytes of it.
09:15
<@Reiver>
I see
09:16
<@Reiver>
And you are approving of this structure?
09:16
<@Vornicus>
as I read more about ARM I like it more. the only thing missing is "predictive branching".
09:17
<@McMartin>
That takes lots and lots of logic.
09:18
<@McMartin>
I bet the conditional execution is faster.
09:18
<@McMartin>
At least most of the time.
09:18
<@McMartin>
Or at least simpler.
09:18
<@McMartin>
Actually, scratch that
09:18
<@McMartin>
If it were faster, SPARC and x86_64 would have had it
09:18
<@McMartin>
It must be simpler.
09:19
<@Vornicus>
I like it.
09:20
<@Vornicus>
That said, it is not as mindlessly simple as MMIX, which is, well
09:20
<@Vornicus>
Every instruction on MMIX looks /exactly the same/
09:30
<@Vornicus>
...only thing is, ARM doesn't have a divider.
09:40
<@Vornicus>
or, at that, an on-chip floating point unit.
09:51
<@McMartin>
Well, the ARM7TDMI doesn't, anyway.
09:51
<@McMartin>
Integer division and mult isn't that tough, all told. I've done 32-bit and 16-bit versions for the 6502.
09:52
<@Vornicus>
It's got mult with double-wide result.
09:53
<@Vornicus>
It does not have division but I know how to do it.
09:53 * Vornicus just didn't want to write it.
09:54
<@McMartin>
I thought you were disassembling code, not writing it.
09:54
<@Vornicus>
Well, yeah, but
09:54 * McMartin just let libgcc handle it.
09:55
<@McMartin>
I think I may still have my GBA Mystify.
09:55 Serah [~Z@87.72.36.ns-26407] has joined #Code
09:55 mode/#code [+o Serah] by ChanServ
09:57
<@McMartin>
Ha HA!
09:57
<@McMartin>
I do.
09:57
<@McMartin>
Three demos.
09:57 * McMartin tries to install a GBA emu to see if they work.
09:59 * McMartin totally fails to do so.
10:00
<@McMartin>
In any event. http://www.stanford.edu/~mcmartin/mystify.gba
10:00
<@McMartin>
Also mystify2.gba and starfield.gba
10:01
<@McMartin>
starfield.gba isn't actually *my* code, but I did a port of it to GBA to learn the hardware.
10:02
<@Vornicus>
what's the difference between mystify and mystify2, other than a changed background color?
10:03
<@McMartin>
I don't have the slightest idea, since I can't run either.
10:03
<@McMartin>
I only seem to have source for Mystify2, though.
10:03
<@McMartin>
And it's apparently in C++. o_O
10:03
<@Vornicus>
All hail gcc, it can do that.
10:04
<@McMartin>
does Starfield work?
10:04
<@Vornicus>
Yeah
10:04
<@Vornicus>
the stars are... dark purple, but it's like I'm back in the early 90s and everybody has discovered their screensavers.
10:05
<@McMartin>
It's easy to code~
10:05
<@Vornicus>
I know~
10:05
<@McMartin>
I did implement my own version of Bresenham's for mystify, though.
10:05
<@Vornicus>
wootence
10:06
<@McMartin>
Wow, this code is so bad
10:21
<@Vornicus>
I can only imagine
10:27
<@McMartin>
It is, shall we say, unpleasantly Enterprisey.
10:28
<@Vornicus>
heh
10:28
<@McMartin>
As you might guess from the tenfold increase in size over the C-based Starfield.
10:28
<@Vornicus>
Ouch
10:34 Mahal is now known as MahalGone
10:38
<@Vornicus>
10:38
<@Vornicus>
wacky printf tricks, Python edition:
10:38
<@Vornicus>
>>> "%.*f" % (3,pi)
10:38
<@Vornicus>
'3.142'
10:38
<@Reiver>
10:38
<@Reiver>
That, um, could do with some work maybe?
10:39
<@Vornicus>
>>> "%.*f" % (5,pi)
10:39
<@Vornicus>
'3.14159'
10:45 Pi [~sysop@Nightstar-23945.hsd1.wa.comcast.net] has quit [Ping Timeout]
10:46 Pi [~sysop@Nightstar-23945.hsd1.wa.comcast.net] has joined #code
10:46 mode/#code [+o Pi] by ChanServ
11:05 Vornicus is now known as Vornicus-Latens
11:22 You're now known as TheWatcher
13:10 Serah [~Z@87.72.36.ns-26407] has quit [Connection reset by peer]
13:49 Serah [~Z@87.72.36.ns-26407] has joined #Code
13:49 mode/#code [+o Serah] by ChanServ
14:04 gnolam [lenin@Nightstar-13557.8.5.253.se.wasadata.net] has joined #Code
14:04 mode/#code [+o gnolam] by ChanServ
14:13 Thaqui [~Thaqui@Nightstar-11312.jetstream.xtra.co.nz] has left #code [Leaving]
14:16 Kamilla [~portualkJ@Nightstar-28350.westnet.dnet.ru] has joined #Code
14:32
< Kamilla>
hi)
14:40 Serah [~Z@87.72.36.ns-26407] has quit [Connection reset by peer]
14:48 Serah [~Z@87.72.36.ns-26407] has joined #Code
14:48 mode/#code [+o Serah] by ChanServ
15:18 Kamilla [~portualkJ@Nightstar-28350.westnet.dnet.ru] has quit [Quit: ]
15:48 Serah [~Z@87.72.36.ns-26407] has quit [Quit: Don't try to read the quit message, that is impossible. Instead only realize the truth; "there is no quit message" and you will see it is not you who read the quit message but the quit message who reads you.]
15:50 Serah [~Z@87.72.36.ns-26407] has joined #Code
15:50 mode/#code [+o Serah] by ChanServ
15:54 Doctor_Nick [~fdsaf@Nightstar-27777.rag-a.fsu.edu] has joined #code
15:58 MyCatSleeps is now known as MyCatVerbs
16:52 Reiver is now known as ReivZzz
17:14 You're now known as TheWatcher[afk]
17:27 AnnoDomini [~farkoff@Nightstar-29752.neoplus.adsl.tpnet.pl] has quit [Ping Timeout]
17:40 AnnoDomini [~farkoff@Nightstar-29752.neoplus.adsl.tpnet.pl] has joined #Code
17:40 mode/#code [+o AnnoDomini] by ChanServ
17:59 Serah [~Z@87.72.36.ns-26407] has quit [Connection reset by peer]
17:59 Serah [~Z@87.72.36.ns-26407] has joined #Code
17:59 mode/#code [+o Serah] by ChanServ
18:27
<@MyCatVerbs>
...
18:27 * MyCatVerbs bitchslaps gcc.
18:27
<@MyCatVerbs>
No, wait.
18:27 * MyCatVerbs bitchslaps C.
18:27
<@MyCatVerbs>
Why is my pointer into a character string pointing into another, entirely incidental block of... already freed memory.
18:27
<@MyCatVerbs>
Bloody fucking HELL I am an idiot.
18:29
<@MyCatVerbs>
Mental note, NURR NURR YE CAN NOT MAINTAIN POINTERS TO FREED MEMORY
18:32 You're now known as TheWatcher
18:34
<@jerith>
You can.
18:34
<@jerith>
It just bites you.
18:35
<@MyCatVerbs>
jerith: in the face. :/
18:35
<@MyCatVerbs>
That's like saying I can, if I want, attempt to clean a shotgun with my tongue while test-firing it.
18:36
<@MyCatVerbs>
Yes, it's possible, but also quite decidedly suboptimal.
18:36
<@jerith>
Sure. But you *can*.
18:42
<@MyCatVerbs>
:(
18:44 * jerith hands MyCatVerbs an Erlang interpreter.
18:45
<@jerith>
Go forth and be enlightened, my child.
18:46
<@jerith>
(That's "my child" in a figurative sense. You're not actually the fruit of my loins.)
18:46 * MyCatVerbs eyes Erlang nervously.
18:47
<@MyCatVerbs>
Full of strange, wonderful concepts that I'm pretty certain I do not yet understand.
18:47
<@MyCatVerbs>
Would you not mind if I were to try to actually get off my lazy arse and finish SICP first?
18:47
<@jerith>
Go for it.
18:47
<@MyCatVerbs>
\o/
18:48
<@MyCatVerbs>
Heh. Wish I'd made a few more of those DVDs. I could've had a spare copy here, too. ^^
18:48
<@jerith>
But immutable varables win lots.
18:48
<@jerith>
Copies of those are all over the country now. :-)
18:48
<@MyCatVerbs>
jerith: I have hugs and ghc. Variables? What the Hell would you be wanting to do with such a silly concept as those?
18:49
<@MyCatVerbs>
Oh, sweet! Awesome! I brought enlightenment and CS to an entire country?
18:49
<@jerith>
Well, selected bits of it.
18:49
<@jerith>
:-)
18:49
<@MyCatVerbs>
I mean, yeah, you did all the hard work, but still. XD
18:49 * jerith grins.
18:49
<@MyCatVerbs>
\o/ o// \\o \o_ _o/ _o_
18:49
<@ToxicFrog>
Immutables give me the jibblies.
18:49
<@MyCatVerbs>
&c
18:49
<@MyCatVerbs>
ToxicFrog: $_
18:50
<@MyCatVerbs>
^^ surely that's rather nastier? =D
18:50
<@jerith>
ToxicFrog: Likewise. Until I used them for a bit.
18:51
<@jerith>
It's functional, so all your varying is done in function parameters and such.
18:51
<@MyCatVerbs>
.!?
18:51
<@MyCatVerbs>
Wow, that's wierd.
18:51
<@ToxicFrog>
(part of this may be because my two Big Projects are ss1edit and Spellcast, which are all about large, mutable states)
18:51 * jerith grins.
18:53
<@jerith>
map(Fun, [Head|List]) -> [Fun(Head) | map(Fun, List)];
18:53
<@jerith>
map(_Fun, []) -> [].
18:54
<@ToxicFrog>
It's true that's not quite as elegant in Lua unless you implement car and cdr as well.
18:55
<@ToxicFrog>
This doesn't change the fact that I don't want to have to manage eight players worth of state using immutables.
18:55 * jerith grins.
18:55
<@MyCatVerbs>
ToxicFrog: easy, you just make a function that maps one (fuck-off huge) n-tuple of gamestate-plus-commands to the next (fuck-off huge) n-tuple of gamestate.
18:56
<@ToxicFrog>
Aah. That makes sense.
18:56
<@ToxicFrog>
In a horribly inconvenient way.
18:57
<@jerith>
Indeed.
18:57
<@MyCatVerbs>
That's all you're actually doing when you write a videogame in a Clike - you create a function that maps state_now onto state_next and put it in a while(1) { }, with a "break;" in there somewhere for when somebody ends the game.
18:57
<@jerith>
But it works nicely if you're only changing little bits of state at a time.
18:57
<@ToxicFrog>
Clike?
18:57
<@jerith>
C-like
18:57
<@MyCatVerbs>
Except that if you do it in a functional language, you'll be doing it explicitly, whereas if you do it in a Clike you'll be doing it informally.
18:58
<@MyCatVerbs>
ToxicFrog: C, C++, Java, etc. I'm arbitrarily defining the term "Clike" to mean "any procedural language with pointers and/or references whose expressive power sucks"
18:58
<@ToxicFrog>
Aah yes.
18:58
<@ToxicFrog>
And, yeah, the difference is that in a C-like - or, for that matter, in a hybrid like Lua or Python - you can incrementally adjust the state without copying it.
18:59
<@MyCatVerbs>
Yes.
18:59
<@MyCatVerbs>
Though there's nothing stopping the compiler from optimizing it down to a state-adjustment - aside from it being bloody difficult, of course.
19:00
<@MyCatVerbs>
If you write it as tail-recursive, I wouldn't be exceptionally surprised if it *did*. ^^
19:11 * ToxicFrog determines how to correctly read two's-complement signed numbers using only the +-%^ operations.
19:11
<@MyCatVerbs>
WHEEEEEEEEE!!!!
19:12 * MyCatVerbs endlessly pipes random lines from Alice in Wonderland through his terminal. XD
19:12
<@MyCatVerbs>
Isn't it just wonderful when a trivial string-manip function actually works? ^^
19:26
<@McMartin>
Regarding "optimizing it down to a state adjustment": this happens kind of automatically as long as you have one bit of infrastructure and one optimization
19:26 AnnoDomini [~farkoff@Nightstar-29752.neoplus.adsl.tpnet.pl] has quit [Ping Timeout]
19:26 KBot [~karma.bot@Nightstar-28983.neoplus.adsl.tpnet.pl] has joined #Code
19:26
<@McMartin>
Well, two bits.
19:26
<@McMartin>
The infrastructure is that it has to be the callee who cleans up his stack frame.
19:27 KarmaBot [~karma.bot@Nightstar-29752.neoplus.adsl.tpnet.pl] has quit [Ping Timeout]
19:27
<@McMartin>
The optimization is tail call elimination (turning the JSR to a JMP) and constant-factor removal (so that the stack pointer edits for the return and the call are collapsed into a single operation, which is then eliminated as a no-op)
19:27 KBot is now known as KarmaBot
19:32 AnnoDomini [~farkoff@Nightstar-28983.neoplus.adsl.tpnet.pl] has joined #Code
19:32 mode/#code [+o AnnoDomini] by ChanServ
19:42 Vornicus-Latens is now known as Vornicus
19:48
<@MyCatVerbs>
McMartin: the second part is in all my favourite languages, but callee who cleans up the stack frame? Isn't that kinda, um, rare?
19:49
<@McMartin>
Not in functional languages, for this exact reason~
19:49
<@ToxicFrog>
unpack_ops['i'] = function(fin, width)
19:49
<@ToxicFrog>
local val = unpack_ops.u(fin, width)
19:49
<@ToxicFrog>
if val < 2^(width*8 - 1) then
19:49
<@ToxicFrog>
return val
19:49
<@ToxicFrog>
end
19:49
<@ToxicFrog>
return val - 2^(width*8)
19:49
<@ToxicFrog>
end
19:49
<@ToxicFrog>
Does this look sane?
19:50
<@Vornicus>
is ^ xor or exp, and what's the i format do?
19:50
<@ToxicFrog>
i is signed ints, ^ is exp.
19:50
<@McMartin>
The Is are tabs.
19:50
<@MyCatVerbs>
I see. But what makes me scratch my head here is that I don't actually know what the calling conventions for all my favourite programming languages are.
19:51
<@McMartin>
I'd have to bust out a disassembler, but ABIs are cross-language mostly these days.
19:51
<@McMartin>
Which is one reason OCaml binaries tend to be humongous, because they have to carry their own translation layer; but I forget which bit breaks the standard ABI.
19:51
<@ToxicFrog>
The idea here is that if you're reading a two's-complement signed int, if the value you read is less than 2^(width-1) it's positive, otherwise it's negative and subtracting (2^width) will get you the actual value.
19:51
<@ToxicFrog>
I think this is correct but want confirmation.
19:52
<@Vornicus>
looks sane.
19:55
<@ToxicFrog>
Excellent. That just leaves bdfmxz.
19:56
<@MyCatVerbs>
McMartin: ? Couldn't they just stuff the translation layer into a dynamic library, or am I being silly here?
19:56
<@McMartin>
MCV: But then you have to do it and its reverse every time you touch libc.
19:56
<@MyCatVerbs>
Ouch.
19:57
<@McMartin>
I haven't actually checked since libocaml became standard.
20:01 Syloq [Syloq@NetAdmin.Nightstar.Net] has joined #code
20:05
<@ToxicFrog>
Hmm. Design question.
20:06
<@ToxicFrog>
If I say 'z128' (z being null-terminated string), does that mean 'read 128 bytes, and return everything up to the first null', or 'read up to the first null and return what was read, but no more than 128 bytes'?
20:06
<@ToxicFrog>
I can think of cases for both.
20:07
<@McMartin>
The latter. The former is b128 with some post-processing.
20:07
<@MyCatVerbs>
The latter sounds more sensible.
20:07
<@ToxicFrog>
Point.
20:07
<@MyCatVerbs>
The latter sounds like strncpy(), the former like an odd violation of strcpy()'s semantic.
20:07
<@MyCatVerbs>
*semantics
20:08
<@Vornicus>
THe latter.
20:08
<@MyCatVerbs>
The only use cases I can think of for the former would involve seriously fucking with peoples' heads and would just be a horrible, horrible edge case with BRAIN HURT NEURONS ONS FIRES>
20:08
<@ToxicFrog>
The former is totally useful for ss1edit.
20:09
<@ToxicFrog>
SS1's data formats are full of fixed-width fields containing null-terminated strings.
20:09
<@McMartin>
The other consideration is that you can do the former in terms of the other primitives, but you can't do the latter in those terms.
20:09
<@McMartin>
Those are b32s or whatnot, then.
20:09
<@McMartin>
(Assuming b is "byte")
20:09
<@ToxicFrog>
Followed by find('^([^%z]*)')
20:10
<@McMartin>
Yeah
20:10
<@ToxicFrog>
Lua doesn't really draw a distinction between byte buffers and strings; I'm using sN to mean 'N bytes of raw data'
20:10
<@McMartin>
While otherwise you have to read a byte at a time until you reach a zero if you've got a bunch of packed strings.
20:10 * ToxicFrog nods
20:11
<@ToxicFrog>
(b is boolean)
20:11
<@McMartin>
c?
20:12
<@McMartin>
Oh, s.
20:12
<@ToxicFrog>
Unused. Like I said, there's no real difference between "N bytes", "N characters", and "a string of length N"
20:12
<@McMartin>
Yeah
20:12 * McMartin concludes that it is lunchtime.
20:12
<@ToxicFrog>
Since the Lua idiom for storing raw binary data is the string, I'm using s.
20:39
<@gnolam>
http://video.google.com/videoplay?docid=-5830318882717959520
20:40
<@gnolam>
(Erlang: The Movie)
20:43
< Doctor_Nick>
Gnalre
20:45
<@jerith>
Is that the one full of moustachioed engineers fixing bugs in a telecoms system?
20:46 MahalGone is now known as Mahal
20:46
<@gnolam>
Yes.
20:47
<@gnolam>
Never underestimate the power of an Engineer's Moustache and Ericsson English.
20:47
<@gnolam>
But the best thing about that video is people's body language.
20:48
<@gnolam>
The guy in the PBX looks so desperate to escape I was expecting him to start gnawing off his leg at any moment.
20:49 * jerith grins.
20:52 Janus [~Cerulean@Nightstar-10302.columbus.res.rr.com] has joined #Code
21:02
<@MyCatVerbs>
I need to re-watch that and pay closer attention to the body language.
21:03
<@jerith>
I'm not very good at body language.
21:03
<@MyCatVerbs>
I've seen it, but didn't notice anything whatsoever except for, "Whoa, nice programming language," and, "Engineer's Moustache!"
21:04
<@jerith>
I tend to miss subtleties. Like people throwing things at me.
21:04 * MyCatVerbs hands jerith a cookie.
21:04 * jerith ponders growing an Engineer's Moustache.
21:04
<@jerith>
Perhaps even a Swedish Engineer's Moustache.
21:04
<@MyCatVerbs>
.?
21:05
<@MyCatVerbs>
How does one perform such a task?
21:05
<@jerith>
(The same thing, just dyed Viking Blonde.)
21:05 * MyCatVerbs has never managed anything more than a Dinner Lady Moustache. :/
21:05
<@jerith>
MyCatVerbs: Lots of fertiliser.
21:05
<@MyCatVerbs>
jerith: I draw the line at putting poo on my upper lip.
21:05
<@gnolam>
I honestly think the moustache is a requirement to work at Ericsson.
21:05
<@MyCatVerbs>
Heehee
21:06
<@jerith>
I tend to range from "scruffily unshaven" to "scarily hirsute".
21:06
<@jerith>
gnolam: For the girls as well?
21:06 * Vornicus is much like jerith in that sense.
21:06
<@gnolam>
There are girl engineers?
21:07
<@jerith>
gnolam: So I'm told.
21:07
<@Vornicus>
there are girl engineers.
21:07
<@Vornicus>
Sucky thing is they're all married already. At least, out here.
21:07
<@MyCatVerbs>
"Hello, I will be your first interviewer for today, so, ah, let's get all the preliminary questions out of the way immediately, shall we now? Righto. Firstly, why do you wish to work at Sony Eriksson?"
21:08
<@MyCatVerbs>
"Well, firstly there's this language you developed, Erlang? I kinda fell in love with it a couple years back and I would just love to work alongside the people who came up with it. Secondly, my moustache wouldn't allow me to fit in anywhere else."
21:16 * ToxicFrog idly whips (a) game designers who think that 'magi' is singular and (b) game designers who think that 'static' means 'full of electricity'
21:16
<@Vornicus>
heh
21:17 * jerith concurs, offers a sjambok.
21:28 * Serah orders her magi to use static field on TF to electrocute him!!
21:37 * McMartin throws a baseball through a dog.
21:38
<@McMartin>
http://worsethanfailure.com/Articles/It_0x27_s_Gonna_Be_a_While.aspx ;_;
21:38 * Vornicus eyes McM
21:38
<@gnolam>
Who are you, Victor Hugo?
21:39
<@McMartin>
MY SECRET IS REVEALED
21:39 * McMartin hasn't really done much hacking in Hugo, though.
21:44 * Vornicus fiddles with his ARM disassembler thingy.
21:50 * McMartin crashes evince.
22:00 Serah [~Z@87.72.36.ns-26407] has quit [Connection reset by peer]
22:00 Serah [~Z@87.72.36.ns-26407] has joined #Code
22:00 mode/#code [+o Serah] by ChanServ
22:21 You're now known as TheWatcher[T-2]
22:22 You're now known as TheWatcher[zZzZ]
22:28 Janus [~Cerulean@Nightstar-10302.columbus.res.rr.com] has quit [Quit: A prize to anyone with the best nyoro~n]
22:34
<@ToxicFrog>
Ok. everything implemenented but dfm, and I think I'm going to have to use C for d and f.
22:36 * Vornicus ponders
22:36 * gnolam tokenizes.
22:37
<@Vornicus>
If you can do decent bit manipulation you should be able to pull off d and f.
22:37
<@McMartin>
Yes, but you can do it in zero assembly instructions if you do it in C.
22:37
<@Vornicus>
heh, true that.
22:37
<@McMartin>
Since it's a reinterpret-cast through a type-punned union.
22:38
<@Vornicus>
type-punned?
22:38
<@McMartin>
Type punning is when you deliberately write to one element of a union and then read from a different one.
22:38
<@Vornicus>
ah
22:38
<@McMartin>
C++ uses reinterpret_cast for that.
22:38
<@McMartin>
I think.
22:38
<@MyCatVerbs>
Yes.
22:38
<@Vornicus>
I think so.
22:38 * McMartin was never clear on the difference between reinterpret_cast and static_cast.
22:39
<@MyCatVerbs>
Though I'm not sure if reinterpret_cast is actually legal for variables themselves.
22:39
<@Vornicus>
static_cast checks for casting operators, or something.
22:39
<@MyCatVerbs>
The only examples I have ever seen of reinterpret_cast were those done on *pointers*.
22:39
<@McMartin>
And the only one I ever thought it was remotely sensible to use was dynamic_cast, and even then that ends up being nonportable. >_<
22:40
<@MyCatVerbs>
As in, int b; float* p = reinterpret_cast<float*> a;
22:40
<@McMartin>
Implementations differ as to whether RTTI is available for all classes or just ones with virtual methods, and most C++ compilers have a switch that will let you disable RTTI entirely as a build flag, without producing errors until run-time.
22:41
<@MyCatVerbs>
Or was the syntax something completely different? Anyway. Fucking ugly and sick and wrong and if you're doing that much bit-twiddling, what the Hell do you think you're up to, working in C++, eh? This is a job for C.
22:41
<@McMartin>
Quite so.
22:41
<@MyCatVerbs>
Hee
22:41
<@McMartin>
(Or Java's library, which has native callouts for just this problem)
22:41
<@MyCatVerbs>
C++ is to Scheme as communism to fascism.
22:42
<@MyCatVerbs>
C++ implementations all differ wildly because the language standard is so huge that no one ever actually implements the whole thing correctly.
22:42
<@McMartin>
Also, most of the implementations are older than the standard.
22:42
<@McMartin>
RTTI was still experimental and proposed when MSVC 6 was out.
22:42
<@MyCatVerbs>
Scheme implementations all differ wildly because the language is so tiny that millions of people all implement it for fun and every single implementation extends the language in a different way.
22:42 * Vornicus prefers Java's language for most things over C++, but still misses, like, operator overloads.
22:43
<@ToxicFrog>
McMartin: static_cast attempts to actually look at the data and convert it to a new format.
22:43
<@McMartin>
TF: Aha. Thanks.
22:43
<@ToxicFrog>
reinterpret_cast just changes the type marker in the compiler, so it's the same byte pattern looked at differently.
22:43
<@MyCatVerbs>
The difference is that Schemers consider this a good thing, from the perspective of being able to try a few different approaches on every neccessary aspect of, um, everything. And then picking the best one. ^^
22:44
<@McMartin>
Schemers also win because R5RS code actually runs on all of them.
22:44
<@Vornicus>
R5RS?
22:44
<@McMartin>
Unless it involves call/cc, in which case all bets are off, but correct behavior is still specified so when it doesn't work it's a bug in the compiler~
22:44
<@MyCatVerbs>
The other difference is that C++ coders actually get high-performance, albeit horribly buggy and unportable, things done. :(
22:44
<@McMartin>
Revised^5 Report on Scheme.
22:44
<@Vornicus>
aha
22:44
<@McMartin>
MCV: Have you looked at Bigloo?
22:44
<@ToxicFrog>
Vornicus: R5RS is the current Scheme standard.
22:45
<@Vornicus>
aha aha.
22:45
<@MyCatVerbs>
R5RS, plus SRFIs.
22:45
<@ToxicFrog>
MCV: so do schemers, except replace "buggy and unportable" with "hard to distribute"
22:45
<@MyCatVerbs>
SRFIs are Scheme Requests For Implementations, which as I understand it are something like proposed standard extensions which implementations support optionally?
22:45
<@ToxicFrog>
And, yeah, the way to handle this is fread() followed by reinterpret_cast<>.
22:46
<@MyCatVerbs>
McMartin: no, but the name sounds familiar. Onward, fair Google!
22:46
<@ToxicFrog>
I think I may actually need a reinterpret_cast (from byte buffer to IEEE floating-point) and then a static_cast (from floating point to lua_Number).
22:46
<@ToxicFrog>
At least for floats.
22:46
<@McMartin>
Right, lua_Numbers are secretly doubles under the hood
22:46
<@McMartin>
But!
22:46
<@ToxicFrog>
Doubles should work fine as long as lua_Number is, in fact, a double.
22:46
<@McMartin>
Assigning a float to a double does the extension automatically.
22:46
<@ToxicFrog>
But I should probably static_cast those as well, since the type of lua_Number is configurable.
22:46
<@ToxicFrog>
What if lua_number is an int?
22:47
<@McMartin>
Then it truncates automatically and some compilers generate a warning.
22:47
<@McMartin>
That's why you have to go through unions to do the reinterpretation in C.
22:47
<@ToxicFrog>
Then I don't need the static_cast after all.
22:47
<@ToxicFrog>
In C I would have done it with a pointercast, actually.
22:47
<@MyCatVerbs>
...?
22:47 * McMartin prefers the union approach because it's clearer what's happening.
22:48
<@MyCatVerbs>
McMartin: is that that horribly aggressive optimizing Scheme-to-C compiler which embeds the boehm-GC?
22:48
<@McMartin>
union { int i; float f; } u; u.i = arg; return u.f;
22:48
<@McMartin>
(Warning: assumes sizeof(int) = 4)
22:49
<@MyCatVerbs>
!?!
22:49
<@McMartin>
MCV: Sort of. It doesn't handle general tail calls, though, just simple recursion.
22:49
<@MyCatVerbs>
Oh, snap.
22:49
<@McMartin>
Well, it translates to C.
22:49
<@ToxicFrog>
I'm not sure that's really clearer.
22:49
<@McMartin>
See previous commentary re: necessary requirements that C ABI doesn't do.
22:49
<@MyCatVerbs>
McMartin: was gonna say, two to four times slower than C? But doesn't GHC hit about that same figure, without being anywhere near so perf-centric?
22:50
<@ToxicFrog>
Hmm. Is sizeof() resolved at compile time?
22:50
<@McMartin>
GHC changes the ABI, IIRC; there was a stink of some kind about it.
22:50
<@McMartin>
TF: Yes.
22:50
<@ToxicFrog>
If so, can I say: uint8_t buf[sizeof(float)]; ?
22:50
<@McMartin>
... Pretty sure.
22:50
<@MyCatVerbs>
McMartin: jah, but what's the ABI got to do with anything? There's a foreign function interface in there for a damn good reason, y'know?
22:50
<@McMartin>
My labmates agree that sizeof is static.
22:51 * MyCatVerbs agrees.
22:51
<@MyCatVerbs>
There's no way it'd be able to judge the size at runtime.
22:51
<@McMartin>
Well
22:51
<@McMartin>
The link-loader could pack a table or something.
22:51
<@MyCatVerbs>
McMartin: not without a lot of overhead which C doesn't have. ¬¬
22:51
<@ToxicFrog>
Also, there's a difference between "resolvable at compile time" and "usable for array initialization".
22:52
<@MyCatVerbs>
Again, not without a whole lot more overhead than the link-loader actually has in practice.
22:52
<@McMartin>
And cross-linking is an issue when ABIs differ, because of the cost of crossing the variable.
22:52 * ToxicFrog points at nested array/struct initialization woes.
22:52
<@McMartin>
TF: Point, but I'm 90% sure the sizeof thing should work.
22:52
<@McMartin>
Because you can have char buf[MAXSTRLEN+1]
22:53
<@MyCatVerbs>
ToxicFrog: sizeof(array)/ sizeof(array[0]) is legal and a common idiom in some places.
22:53
<@ToxicFrog>
MyCatVerbs: for static array sizing?
22:53
<@ToxicFrog>
No it isn't.
22:53
<@MyCatVerbs>
ToxicFrog: yes..
22:54
<@MyCatVerbs>
Yes, it is. I've seen it in a dozen damn places.
22:54
<@ToxicFrog>
You can't write: uint8_t array[sizeof(array)/sizeof(array[0])]
22:54
<@MyCatVerbs>
...
22:54 * MyCatVerbs thwaps ToxicFrog upside the head with a newspaper.
22:54
<@ToxicFrog>
Which, if you read back about half a page, is what I'm talking about.
22:54
<@ToxicFrog>
I have no interest in getting the size of an existing array.
22:55
<@MyCatVerbs>
That's recursive. sizeof(array)/sizeof(array[0]) gives you nmemb. Why the HELL would you attempt to allocate an array whose size is its own size?
22:55
<@ToxicFrog>
THAT'S WHAT I'M ASKING YOU!
22:55
<@ToxicFrog>
You're the one who suggested it!
22:55
<@MyCatVerbs>
I was saying it was a common idiom - for completely different purposes.
22:56
<@MyCatVerbs>
Just that it shows that, yes, sizeof() is resolved at compile time.
22:56 * ToxicFrog idly designs an array implementation for which that resolves at runtime.
22:56
<@ToxicFrog>
Trivially, even.
22:57
<@MyCatVerbs>
Great, TF. Guess how many compilers will, commercial or otherwise?
22:57 Mahal is now known as MahalGone
22:57
<@ToxicFrog>
None, to my knowledge.
22:57
<@ToxicFrog>
However, my point is, the fact that you can write that says bugger all about whether sizeof is resolved at compile or run time.
22:58
<@MyCatVerbs>
ToxicFrog: for fuck's sake.
22:58
<@ToxicFrog>
And is completely irrelevant because we've already established that, in practice, it's resolved at compile time, and that hasn't been the issue for over a page now.
23:00
<@MyCatVerbs>
So why the Hell were you buggering on about it?
23:02
<@MyCatVerbs>
ToxicFrog: g++ -S resolves it at compile time. Happy now, or would you like me to go buy copies of every single commercial C++ compiler on Earth and try them, too?
23:02
<@ToxicFrog>
...I wasn't. You're the one who asserted that you could use a recursize sizeof to initialize a static array.
23:02
<@ToxicFrog>
Which is flatly insane.
23:02
<@MyCatVerbs>
No, no I wasn't.
23:03
<@ToxicFrog>
Yes you bloody well were. I was talking about using sizeof() as the static array-length initializer. You then said that sizeof(array)/sizeof(array[0]) was legal for that.
23:03
<@MyCatVerbs>
"ToxicFrog: sizeof(array)/ sizeof(array[0]) is legal and a common idiom in some places." <-- I did not say it had anything with initialising a static array.
23:03
<@ToxicFrog>
Then you should have realized what the topic of conversation was and qualified your statement accordingly.
23:03
<@MyCatVerbs>
I said it was a common idiom. I did not say it was a common idiom for what *you* were doing. Far from it, even.
23:04
<@MyCatVerbs>
Congratulations to ten minutes ago.
23:04
<@MyCatVerbs>
*Congratulations and welcome to ten minutes ago. <--- I suck at communication, in case you haven't noticed. ^^
23:05
<@MyCatVerbs>
"22:55 <@MyCatVerbs> I was saying it was a common idiom - for completely different purposes." <--- look familiar?
23:05
<@ToxicFrog>
I kind of noticed your lack of communication skills ten minutes ago, yes.
23:05 MyCatVerbs was kicked from #code by MyCatVerbs [STFU]
23:05
<@ToxicFrog>
o.O
23:07 * Vornicus eyes
23:08
<@Vornicus>
I... don't see where you got the statement here: < ToxicFrog> You can't write: uint8_t array[sizeof(array)/sizeof(array[0])]
23:08
<@Vornicus>
I mean, the part inside the [] is fine, but I don't see why your wrapped it like that.
23:09
<@ToxicFrog>
Because the conversation was about what you could use as a static array size for initialization.
23:10
<@ToxicFrog>
I was wondering if you could use sizeof, ie, uint8_t foo[sizeof(bar)]
23:10
<@ToxicFrog>
He said that sizeof(array)/sizeof(array[0]) was legal.
23:10
<@Vornicus>
Well, in and of itself it is. What do you mean "static array size"?
23:10
<@ToxicFrog>
I assumed he meant "for array size initialization", since that's what we were talking about.
23:10
<@ToxicFrog>
A static array is one allocated at compile time in that manner rather than at runtime using malloc()
23:12
<@Vornicus>
ah
23:13
<@Vornicus>
I think sizeof() gets figured out at approximately compile time.
23:15
<@ToxicFrog>
We established that a while ago.
23:15
<@ToxicFrog>
That doesn't guarantee it's usable in this manner, though.
23:15
<@ToxicFrog>
Since C array and struct initializations have lots of wackiness that means that things that are resolved at compile time, and should work, don't.
23:18 * McMartin found his dev diary last night from a GBA program he did years ago. He got burned by the difference between a header declaring an int * and one declaring an int[].
23:20
<@ToxicFrog>
...what is the difference?
23:22
<@McMartin>
One is an array of unspecified size. The other is a four-byte pointer value.
23:22
<@McMartin>
I had declared int * and defined int[] in a .c file. This led to the second .c file attempting to interpret the first int the array as a pointer and dereferencing it.
23:23
<@McMartin>
This is the One Place In All C that pointers and arrays are different.
23:24 * ToxicFrog blinkblinks
23:25
<@McMartin>
Er. THe declared int * was in a .h
23:27
<@ToxicFrog>
So, hang on. Header file declares int * foo. C file #1 defines int[] foo. C file #2...attempts to access foo[0]?
23:27
<@ToxicFrog>
I'm not really following what went wrong here.
23:28
<@McMartin>
C file #2 attempts to access foo[0].
23:28
<@McMartin>
This compiles to "MOV AX, [foo]"
23:28
<@McMartin>
Er, no
23:28
<@McMartin>
"MOV EBX, [foo]; MOV EAX, [EBX]"
23:29
<@McMartin>
While if it had been declared as int[], it would have been "MOV EAX, [foo]", which was what was correct in this circumstance.
23:29
<@McMartin>
Also, it was ARM assembler, not x86.
23:30
<@McMartin>
Which, IIRC, I disassembled with objdump.
23:30
<@McMartin>
But then, I had the .o files.
23:34
<@ToxicFrog>
So...it treated foo like an int*[] or int** rather than int[].
23:34
<@McMartin>
No
23:34
<@McMartin>
Look at what the .bss looks like for these.
23:34
<@McMartin>
int *foo; is a four-byte value with a pointer inside of it.
23:35
<@ToxicFrog>
So is int[] foo, I thought; it's int[x] foo that's just a block of data.
23:35
<@McMartin>
int foo[16] is 64 bytes of integer data and no pointers at all; "foo" is a static symbol in the code segment.
23:35
<@ToxicFrog>
Aah.
23:36
<@McMartin>
And int h[]; does not mean "pointer to int", it means "static array on the heap of unspecified size".
23:36
<@McMartin>
Well, in the .data segment.
23:36
<@ToxicFrog>
h[] also gets used for dynamic arrays, though.
23:37
<@ToxicFrog>
I see it in function signatures fairly frequently to mean 'this is an array pointer rather than a singleton pointer'
23:37
<@McMartin>
For uses that aren't at global scope, int * and int[] are synonymous.
23:37
<@McMartin>
It is only when declaring at global scope that there is a distinction.
23:38
<@ToxicFrog>
....aah.
23:38
<@ToxicFrog>
Goddamnit, C.
23:41
<@McMartin>
Well, if there weren't a distinction you'd be wasting four bytes of data!
23:42
<@McMartin>
And an unnecessary memory access on each access to the array!
23:43
<@Vornicus>
Heh
23:43
<@McMartin>
Actually, that latter I would begrudge on a lot of 8-bit architectures.
23:44
<@McMartin>
Pointer code on the 6502 is Made Of Ass.
23:45
<@ToxicFrog>
Bitmask. Should it be endian?
23:45
<@Vornicus>
Yes.
23:45
<@Vornicus>
Well, okay, let me clarify
23:45
<@ToxicFrog>
Ie, if I ask for a two-byte bitmask, should it read 7 6 5 4 3 2 1 0 F E D C B A 9 8, or F E D C B A 9 8 7 6 5 4 3 2 1 0?
23:45
<@McMartin>
The distinction between the extra code and the short one is "three bytes of instruction, 4 cycles, can touch anywhere in memory, trashes one register" and "twelve bytes of code, at least 20 cycles, trashes two registers and at least two bytes in the first 256 addressable"
23:46
<@ToxicFrog>
...ew
23:46
<@Vornicus>
the ARM architecture is bi-endian; if you set it to bigendian, you get bigendian instructions, and if you set it to littlendian, you get littleendian instructions
23:48
<@ToxicFrog>
I'm talking about for struct, not for disARM.
23:49
<@Vornicus>
i know, but your thing sounds approximately like something I'd want to do in disARM.
23:49
<@Vornicus>
-- which is a cool name and I am stealing it.
23:49
<@Vornicus>
(as payment for "Bitch With Extra Bitch Sauce")
23:49
<@McMartin>
Put him to the THUMBscrews!
23:50
<@ToxicFrog>
...that wasn't already its name?
23:50
<@Vornicus>
no.
23:50
<@ToxicFrog>
Huh.
23:50
<@ToxicFrog>
I thought of it when you first mentioned making an ARM disassembler, and assumed that it was a sufficiently obvious name that it's what you were using :P
23:50
<@McMartin>
Also, TF, I'd use < > markers as per Python struct.
23:51
<@McMartin>
Everything should be bi-endian.
23:51
<@ToxicFrog>
McMartin: in the works. The question is whether bitmasks should behave like, eg, strings in not being affected by endianness.
23:52
<@McMartin>
Many bitmasks are 32-bit numbers stored in native endianness, so no.
23:52
<@McMartin>
... while we're at it, how is it that bitmasks are not just integers of various widths?
23:53
<@ToxicFrog>
"bitmask" returns/accepts an array of booleans.
23:54
<@ToxicFrog>
Lua lacks bitwise operators, and this also means you can go mask[n] to clearly refer to the n'th bit.
23:54
<@McMartin>
I think it would be safest to instead use an explode operator that converts integers to and from them.
23:54
<@ToxicFrog>
Rather than mask & 1<<n, which is also clear, but...less so.
23:55
<@ToxicFrog>
Well. Now that we've decided that bitmasks are affected by endianness, that's how it's implemented internally.
23:55
<@ToxicFrog>
unpack.m -> explode(unpack.u)
23:56
<@Vornicus>
explode!
--- Log closed Thu Apr 12 00:00:53 2007
code logs -> 2007 -> Wed, 11 Apr 2007< code.20070410.log - code.20070412.log >