|
Otto Skorzeny posted:Things I love - just one test gotta pass tonight, got a +1 here in this loop to write i write tests *do* *do* *do* *do-do* we all write tests
|
# ? Sep 28, 2011 20:18 |
|
|
# ? Jun 8, 2024 07:28 |
|
Alright, I'm just starting learning Intel assembly, and I'm trying to write a simple program. The problem is that it segfaults, and I'm either blind, retarded, or fundamentally misunderstanding something because I can't find it. http://pastebin.com/0iUPjcTE
|
# ? Sep 29, 2011 16:55 |
|
How do I make a regular expression that matches either two or three letters at the end of a match, and NOT match any html tags. For example, I have " - Ben Rothlesbuger | PIT" followed by a </span> tag. I was able to set up a regex that finds the match if the abbreviation is three letters. If the abbreviation is only two letters, however, it also matches the "<" in the </span> tag. Any help? This is what I have so far. " - .* \| ..." minus the quotes.
|
# ? Sep 29, 2011 21:48 |
|
I think this instead of "..." should do what you want? [A-Z]{2,3}
|
# ? Sep 29, 2011 22:01 |
|
Emong posted:Alright, I'm just starting learning Intel assembly, and I'm trying to write a simple program. The problem is that it segfaults, and I'm either blind, retarded, or fundamentally misunderstanding something because I can't find it. Are you sure you're using the right calling convention? Been a long time since I've done any asm, but everything tends to be pass by register these days.
|
# ? Sep 29, 2011 22:54 |
|
Vanadium posted:I think this instead of "..." should do what you want? [A-Z]{2,3} drat! How can I buy you a beer or a coffee?
|
# ? Sep 29, 2011 22:55 |
|
Zombywuf posted:Are you sure you're using the right calling convention? Been a long time since I've done any asm, but everything tends to be pass by register these days. I'm pretty sure I am, since I've been trying to check it against an example program that compiles and runs perfectly.
|
# ? Sep 29, 2011 23:18 |
|
Your final two printf calls take two arguments, so you should be adding 8 to %esp, not 4. Also, some x86 platforms require 16-byte stack alignment, whereas you're only giving 4-byte alignment. If those aren't enough, use a debugger to figure out *where* your program is segfaulting — if the PC is completely screwed up, I suggest putting a breakpoint before the ret instruction. Minor point: there's no need to reload speed between those compares. rjmccall fucked around with this message at 23:36 on Sep 29, 2011 |
# ? Sep 29, 2011 23:34 |
|
Gonna repost my question since nobody said anything on it, and I'm still confused Tw1tchy posted:Hmh. I've been thinking for the past few weeks on the best way to structure code and objects. Structuring things is my weak point, and I need to get better at it so everything I make doesn't become jumbled messes within the first day.
|
# ? Sep 30, 2011 04:13 |
|
rjmccall posted:Your final two printf calls take two arguments, so you should be adding 8 to %esp, not 4. Also, some x86 platforms require 16-byte stack alignment, whereas you're only giving 4-byte alignment. If those aren't enough, use a debugger to figure out *where* your program is segfaulting — if the PC is completely screwed up, I suggest putting a breakpoint before the ret instruction. Debugger tells me "0x080484a2 in exit ()" which I assume means that the segfault is happening on exit? I've never used a debugger before and I have no idea what I'm doing here. EDIT: Hmm, if I replace LEAVE CALL exit with MOVL $1, %eax MOVL $11, %ebx INT $0x80 the segfault stops. Huh. Emong fucked around with this message at 15:31 on Sep 30, 2011 |
# ? Sep 30, 2011 07:55 |
|
Tw1tchy posted:XML deserialization The basic goal here is to make objects out of the XML (I'll just go ahead and suggest you avoid XML and aim for JSON or YAML or anything else for readability but whatever). What kind of objects and how the XML attributes and child tags are thrown into the objects is up to you. You could simply throw everything into your language's generic dictionary type, or maybe you specialize a bit and make a class or two for game entities, then parse the XML and make new game entities as you go through a Template tag's attributes and children. Something like code:
Your question was quite generic and I wasn't sure how to answer it, so maybe this helps?
|
# ? Sep 30, 2011 08:29 |
|
pokeyman posted:The basic goal here is to make objects out of the XML (I'll just go ahead and suggest you avoid XML and aim for JSON or YAML or anything else for readability but whatever). What kind of objects and how the XML attributes and child tags are thrown into the objects is up to you. You could simply throw everything into your language's generic dictionary type, or maybe you specialize a bit and make a class or two for game entities, then parse the XML and make new game entities as you go through a Template tag's attributes and children. Yeah, that definitely does open up my mind a bit to think about it easier. I'll sit down see what I can whip up some time.
|
# ? Sep 30, 2011 08:42 |
|
Emong posted:Debugger tells me "0x080484a2 in exit ()" which I assume means that the segfault is happening on exit? I've never used a debugger before and I have no idea what I'm doing here. The segfault is happening during the call to exit. When writing assembly, you should assume that means you're breaking the preconditions of the call, usually in one of two ways: either you're passing bad arguments or you've fouled up the stack pointer. In this case, both are true. First, exit takes an argument that you're not passing; generally you want to pass zero, to indicate successful completion. That's not causing your crash, though, because exit doesn't actually do anything with its argument except propagate it onward. It's easy to detect a screwed-up stack pointer — just look at the crash in the debugger and print the contents of your registers. You should see that %esp is some completely crazy value. If you step through your function, you should see that it's fine until you get to leave. You're not actually setting up a proper call frame in your prologue, so doing a leave just pops some random value into %esp. Not doing the leave should fix that, or you can set up a frame.
|
# ? Sep 30, 2011 19:49 |
|
Several things are suspect: - You didn't use ENTER, which means LEAVE will attempt to restore a stack state that was never stored and ruin everything - Functions are expected to save EBX, ESI, and EDI from the caller - Your stack cleanup after calls is hosed, you're calling printf with 8 bytes of arguments (two PUSHL) and then adding 4 to ESP instead of 8 during cleanup. If you're using cdecl, you usually to do this: code:
OneEightHundred fucked around with this message at 21:34 on Sep 30, 2011 |
# ? Sep 30, 2011 20:58 |
|
Emong posted:I've never used a debugger before and I have no idea what I'm doing here. You're really handicapping yourself as a programmer if you don't know how to use a debugger. That's probably the most important skill you can be developing right now, so get to it ASAP.
|
# ? Sep 30, 2011 22:04 |
|
Yeah, what he said. You can kind of get away with for high level languages that have good error event trapping and messaging, but ASM is neither of those.
|
# ? Sep 30, 2011 22:23 |
|
OneEightHundred posted:- Functions are expected to save EBX, ESI, and EDI from the caller Only if they touch them. The contract is to leave them with their original values, not to save them unconditionally.
|
# ? Sep 30, 2011 23:34 |
|
OneEightHundred posted:- You didn't use ENTER, which means LEAVE will attempt to restore a stack state that was never stored and ruin everything ENTER and LEAVE don't have to be paired. (And in fact never are in modern code, ENTER is microcoded, while LEAVE is a real instruction.)
|
# ? Sep 30, 2011 23:42 |
|
pseudorandom name posted:ENTER and LEAVE don't have to be paired
|
# ? Oct 1, 2011 00:30 |
|
Well, yeah, LEAVE obviously expects a specific stack layout. But you don't have to produce that using ENTER. And nobody does, because ENTER is terrible. OTOH, LEAVE isn't, and the general rule of x86 assembly programming is to use the fewest instructions possible (i.e. take advantage of the complex addressing modes, use the instructions that do multiple things, etc.).
|
# ? Oct 1, 2011 00:33 |
|
I thought they all aliased internally anyway. MSVC doesn't output either, it just dumps out push/pop/move instructions, and GCC I think just uses MOV/SUB. Either way, it is a problem that LEAVE is being called without proper stack setup.
|
# ? Oct 1, 2011 00:52 |
|
Sorry, I'm out of date, everybody microcodes LEAVE now. Never use it.
|
# ? Oct 1, 2011 00:57 |
|
pseudorandom name posted:Sorry, I'm out of date, everybody microcodes LEAVE now. Never use it. I'm pretty sure I'm just confused by your terminology, but what instructions do you think don't get microcoded?
|
# ? Oct 1, 2011 17:00 |
|
The ones that aren't listed as "microcoded" in AMD's optimization manual.
|
# ? Oct 1, 2011 20:11 |
|
What's the 'best' (friendliest API, most useful, best designed) web server abstraction layer? ie wsgi, rack, et cetera? any language, I need to port one of them to erlang.
|
# ? Oct 2, 2011 03:23 |
|
aren't wsgi, psgi, rack roughly the same? the problem is that you might find that the wsgi-style abstraction is a better fit over more imperative, less concurrent languages. i.e instead of passing a context & function in, you could pass a process in which responds to specific messages to manage the connection that said it seems other people have done straight forward ports of wsgi to erlang already https://github.com/skarab/ewgi
|
# ? Oct 2, 2011 15:47 |
|
edit: Actually I eliminated the majority of my shift/reduce problems with a grammar I'm writing. I am still getting it on the following grammar though. Does anyone know why?code:
code:
Super Dude fucked around with this message at 19:03 on Oct 2, 2011 |
# ? Oct 2, 2011 17:49 |
|
...
maskenfreiheit fucked around with this message at 23:11 on Oct 2, 2011 |
# ? Oct 2, 2011 22:26 |
|
You don't reset i to zero once you've gone through your inner while loop. Also, you don't break out of the while loop once you've found the character you were looking for. Is there a reason you don't just compare the character to the range you want instead of the while loop?
|
# ? Oct 2, 2011 22:34 |
|
Because you're reusing the loop variable "i" and aren't setting it to 0 before the while loop, so it's re-entering with the value it had the last time it exited the loop. Also look up "sets", they're an easier way to do this.
|
# ? Oct 2, 2011 22:35 |
|
For future reference, pastebin is a handy tool for sharing a large body of text without cluttering your posts.
|
# ? Oct 2, 2011 22:44 |
|
Anyone have an idea about mine?
|
# ? Oct 2, 2011 22:45 |
|
.
maskenfreiheit fucked around with this message at 21:27 on Apr 28, 2019 |
# ? Oct 2, 2011 23:05 |
|
Any reason why you edited out your post? Kind of annoying when there's already replies to it.
|
# ? Oct 2, 2011 23:37 |
|
.
maskenfreiheit fucked around with this message at 21:27 on Apr 28, 2019 |
# ? Oct 2, 2011 23:58 |
|
.
maskenfreiheit fucked around with this message at 21:27 on Apr 28, 2019 |
# ? Oct 2, 2011 23:59 |
GregNorc posted:also, how do I print an integer and a string in the same line? Depends on whether you're using Python 2.x or Python 3.x, since print was changed from being a keyword/statement to being a regular function in Python 3. In Python 2: code:
code:
code:
code:
nielsm fucked around with this message at 00:13 on Oct 3, 2011 |
|
# ? Oct 3, 2011 00:10 |
|
Super Dude posted:edit: Actually I eliminated the majority of my shift/reduce problems with a grammar I'm writing. I am still getting it on the following grammar though. Does anyone know why? Have you defined any precedence or associativity for the binary operators?
|
# ? Oct 3, 2011 03:31 |
|
tef posted:Have you defined any precedence or associativity for the binary operators? code:
|
# ? Oct 3, 2011 04:30 |
|
|
# ? Jun 8, 2024 07:28 |
|
It would help some if you pastebin'd your entire grammar
|
# ? Oct 3, 2011 07:10 |