As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
We're funding a new Acquisitions Incorporated series on Kickstarter right now! Check it out at https://www.kickstarter.com/projects/pennyarcade/acquisitions-incorporated-the-series-2

The beginner programming thread

1495052545563

Posts

  • jackaljackal Fuck Yes. That is an orderly anal warehouse. Registered User regular
    edited October 2008
    Does LC-3 have a mod operator (or does integer division leave the remainder in a certain register)? The usual algorithm is to mod the value by 16 to get the least significant digit, and then divide by 16, and repeat to get the next least significant digit until you are left with zero. An example for F030 would be:

    61488 / 16 = 3843
    rem 0

    3843 / 16 = 240
    rem 3

    240 / 16 = 15
    rem 0

    15 / 16 = 0
    rem 15

    So you end up with F030. To convert the number 0 to 15, to the chars 0-F I would just create a lookup array and use the number as the offset.

    jackal on
  • urahonkyurahonky Registered User regular
    edited October 2008
    That's a great idea jackal. I didn't think about dividing by 16... The problem is, LC-3 only has the following operators: ADD, AND, NOT. That's it. I can't think of a way to divide by 16 using those.

    It looks like he's uploaded some code to "shift right" the digits for binary. Perhaps that could be of some use? I'm still at a loss.

    urahonky on
  • His CorkinessHis Corkiness Registered User regular
    edited October 2008
    Dividing by 16 is the same as shifting 4 bits to the right.

    Edit: Probably should've said "Shifting to the right 1 bit is the same as dividing by 2" and let you figure out the rest, though

    His Corkiness on
  • urahonkyurahonky Registered User regular
    edited October 2008
    Dividing by 16 is the same as shifting 4 bits to the right.

    Edit: Probably should've said "Shifting to the right 1 bit is the same as dividing by 2" and let you figure out the rest, though

    :) Yeah 2^4

    Here's the code he gave me, and I'm trying to decipher it:
    ; SHIFTR: Routine to SHIFT R0 right by 1 bit
    SHIFTR		ST  R1, R1SAVE		; Save callee-save registers
    		ST  R2, R2SAVE
    
    		AND R1, R1, #0		; R1 holds the itermediate result
    		AND R2, R2, #0		; R2 holds count for number of bits examined
    		ADD R2, R2, #15		
    
    NextBit		ADD R0, R0, #0		; Test MSB for 1 or 0
    		BRn MSBIS1		
    						
    MSBIS0		ADD R1, R1, R1		;shift result left 
    					;force LSB to 0
    		ADD R0, R0, R0		;shift original value left; check next bit
    		BR  TestDone
    
    MSBIS1		ADD R1, R1, R1		;shift running total right
    		ADD R1, R1, #1		;force LSB to 1
    		ADD R0, R0, R0		;shift original value left; check next bit
    
    TestDone	ADD R2, R2, #-1
    		BRP NextBit
    
    Done		ADD R0, R1, #0		; Move result to R0
    	        LD  R2, R2SAVE		; Restore callee-save registers
                    LD  R1, R1SAVE
                    RET
    
    R1SAVE		.BLKW 1
    R2SAVE		.BLKW 1
    
    		.END
    

    So does this make something that looks like: 0001 0000 1001 0101 look like 0000 0001 0000 1001? Is that how I'm reading it?

    urahonky on
  • KrisKris Registered User regular
    edited October 2008
    I figure this question doesn't warrant its own thread, so I figure this is the best place to ask it. If not, feel free to slap me around and tell me where to go. :P

    Long story short, I'm in my final semester at school, and we (my team of 4) are writing an inventory tracking and tool sign in/out system for a company, all apart of the "project" course for this semester. Client doesn't want to spend any money, so we've chosen to use C# (Express IDE) for the front-end (it's the language we've worked in most the past semesters), and PostgreSQL for the database.

    Problem: The client wants a handful of printable reports (example: employees tool history) to be generated. Up till now, we'd been using MSSQL in school, and learned how to generate reports using Crystal Reports. So since we're just learning PostgreSQL, we've been doing a bunch of research, trying to figure out if there is an equivalent to crystal reports. So far we've come up pretty empty.

    Is there any way to generate reports with PostgreSQL? Or if not, since we know the exact reports needed, can it be "hacked" using C# forms? Even just a nudge in a right direction would be extremely appreciated, cause we're pretty much treading water at this point. Thanks! :D

    Kris on
  • ecco the dolphinecco the dolphin Registered User regular
    edited October 2008
    urahonky wrote: »
    That's a great idea jackal. I didn't think about dividing by 16... The problem is, LC-3 only has the following operators: ADD, AND, NOT. That's it. I can't think of a way to divide by 16 using those.

    It looks like he's uploaded some code to "shift right" the digits for binary. Perhaps that could be of some use? I'm still at a loss.

    Hmmmm... hmmm.... I don't think you really need to shift right in this instance, especially in the absence of a right shift instruction. Also because you're displaying the leftmost bits first anyway.

    e.g. "1111 0000 0011 0000" is displayed, as you correctly say, as 0xF030

    See how the leftmost bits are the first characters shown? Then the next character shown is to the right, e.g. 1111 -> F, 0000 -> 0, 0011 -> 3, 0000 -> 0.

    If it were me, I'd be tempted to do something like:

    1.) Mask out everything apart from the top nibble
    2.) Convert the top nibble to a character and display the character
    3.) Left shift 4 bits
    4.) Repeat steps one to three 3 more times

    Step 2 might give you some trouble, but it's not too bad.

    Spoilers reveal a method to do step 2. Nested spoilers reveal more details.
    If only there was a way to convert:
    0000 0000 0000 0000 -> 0
    0001 0000 0000 0000 -> 1
    0010 0000 0000 0000 -> 2
    ...
    1111 0000 0000 0000 -> F
    Maybe if I subtracted 0x1000 from the value, and count how many times I could do that before it becomes zero?
    Since you don't have a subtract, you might need to use NOT somewhere...

    (Edit: Alternatively, if you've figured out how to do a rotate left bit shift, just do that four times to shift the top nibble to the lower nibble)

    ecco the dolphin on
    Penny Arcade Developers at PADev.net.
  • ASimPersonASimPerson Cold... and hard.Registered User regular
    edited October 2008
    urahonky:

    The LC-3 instruction set is Turing-complete. In practical terms, this means that every operation you can think of is possible in it. What I always did (and what we told our students to do) was write subroutines for multiply, divide, mod, etc. So whenever an assignment called for something like that, you just bust out the appropriate routine and off you go.

    Actually, looking back... divide and mod are done using the same routine. That may or may not help.

    Also, I think eecc is on the right track algorithm-wise. You probably want to "pick off" the leftmost bits. Spoilers below, use them as a last resort, if you will:
    From there, maybe just do a "brute force" method and compare the values to known values in memory (e.g., .FILL 0xF000, .FILL 0xE000, etc.). If the result is true, then print out a certain character that corresponds to that value, which you can also store in memory ahead of time.

    Anyway, good luck!

    ASimPerson on
  • LoneIgadzraLoneIgadzra Registered User regular
    edited October 2008
    Arsonide wrote: »
    So I'm back on the track of learning C++. Every so often I get determined to do so - I'm on about my tenth run now. [snip]

    Two things:

    1. C++ is a bitch language. Try to do anything complex and you will find that it's like nobody thought anything through with the language. Most of its idioms have serious shortcomings, much of its functionality is nightmarishly complicated while lacking real control (see operator overloading) etc. I wrote my first game in C++, but it was totally procedural and nothing I couldn't have done in C, and in the end I switched to Python/pygame because I can get twice as much done with half the pain. If you really want to get something done, you should consider switching to something else, because there are other languages out there in which it is much easier to learn good habits for writing real-world programs. (Even Java would be beneficial.)

    2. Just say "I am going to write space invaders", don't think ahead any further than that, and sit down and when you hit something you don't know how to do, think about it for a while, look up other peoples' code, do whatever it takes, just puzzle it out no matter how ugly your program ends up being. When you hit a problem, the question is not "how do I do this in a way I know?" but "how do I do this period?" spend a day google searching and reading if you have to. And once you're done, you have experience. Now you can write another program, and the architecture will be better, you'll be more familiar with language quirks, etc.

    Again, it doesn't matter if your first few programs using new concepts are shitty. Just write them.

    Your non-cheap exercise problem I find a bit strange because most people, when they start programming, immediately say "I want to make Halo 4!" and bite off way more than they can chew. Even though you will never finish Halo 4 with this method, you will learn a lot.

    I mean, space invaders is a pretty good exercise if you want one. Right off the bat you have to solve some good problems like "how do I make a window?" or "how do I store and blit a sprite to this window?" and this will probably lead you to SDL, which is totally fine because who wants to write a graphics library from scratch anyway.

    Also, the other guy who responded is right: breaking things up or writing small programs to try new things is a good way to go too. Say I want to write a GUI application to solve some problem, and I need some tabs. First I'd make a simple app to figure out all the ins and outs of tabs, and then incorporate that knowledge into the big project.

    tl;dr is if there's one concept I want to get across with this post, it's "decide on something you want to make in the abstract, then get it done no matter what." If you could elaborate on what it is in your thought process that leads you to write programs that don't help you grow as a programmer, I might be able to help more.

    LoneIgadzra on
  • dodosdodos Registered User regular
    edited October 2008
    I'm really starting to hate my math classes I have to take for this CS degree. Is it common to see no point in the classes themselves and rather focus your attention on work going towards the major?

    dodos on
  • ASimPersonASimPerson Cold... and hard.Registered User regular
    edited October 2008
    dodos wrote: »
    I'm really starting to hate my math classes I have to take for this CS degree. Is it common to see no point in the classes themselves and rather focus your attention on work going towards the major?

    Math classes suck, but the point of going to a university instead of, say, DeVry or ITT Tech is that you're going to be slightly more well-rounded.

    I got a D in Applied Combinatorics but still graduated with High Honors. :P Just buck up and you'll make it through.

    ASimPerson on
  • LoneIgadzraLoneIgadzra Registered User regular
    edited October 2008
    ASimPerson wrote: »
    dodos wrote: »
    I'm really starting to hate my math classes I have to take for this CS degree. Is it common to see no point in the classes themselves and rather focus your attention on work going towards the major?

    Math classes suck, but the point of going to a university instead of, say, DeVry or ITT Tech is that you're going to be slightly more well-rounded.

    I got a D in Applied Combinatorics but still graduated with High Honors. :P Just buck up and you'll make it through.

    The only math class I saw no purpose to was linear algebra, after we got done with transformations. How many do you have to take? My university just required a certain amount of math credits + "Foundations of Math" (a logic course). I ended up going through Calc I, II, and Linear Algebra of my own volition and that was it. Calculus isn't too bad really since high school should have given you a solid algebra grounding, and I love how it always starts by saying "we want to solve this problem that looks impossible" to grab your interest.

    LoneIgadzra on
  • NightslyrNightslyr Registered User regular
    edited October 2008
    Hey guys, quick namespace question.

    I'm having an argument with another PHP coder. Apparently, PHP is going to be adding namespace support in the next minor revision, 5.3. Of course, PHP is doing it the half-assed/ugly way, so the namespace resolution operator is '\'. In other words:
    namespace Foo
    {
       function bar()
       {
          echo "Namespace Foo";
       }
    }
    
    Foo\bar();
    

    I suggested that PHP simply use the standard scope resolution operator '::' with namespaces as well. The other person countered with:
    namespace Foo
    {
       function bar()
       {
          echo "Namespace Foo";
       }
    }
    
    class Foo
    {
       public static function bar()
       {
          echo "Class Foo";
       }
    }
    
    Foo::bar(); // <-- which one is actually being invoked?
    

    I thought that they were being purposely obtuse, and suggested the following as a hypothetical solution:
    namespace Foo
    {
       function bar()
       {
          echo "Namespace Foo";
       }
    }
    
    $myNamespace = Foo;
    
    class Foo
    {
       public static function bar()
       {
          echo "Class Foo";
       }
    }
    
    $myNamespace::bar();
    Foo::bar();
    

    Am I missing something here? I mean, provided the next version of PHP is written somewhat logically, why wouldn't that work? I know that other languages use '::' for both classes and namespaces, so I fail to see why PHP can't do the same, outside of their half-ass pedigree.

    Nightslyr on
    PSN/XBL/Nintendo/Origin/Steam: Nightslyr 3DS: 1607-1682-2948
    Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
  • Recoil42Recoil42 Registered User regular
    edited October 2008
    This was a huge deal on reddit over the weekend, you might be interested in reading the discussion there.


    http://www.reddit.com/r/programming/comments/79cut/php_is_going_to_use_backslash_as_a_namespace/


    I wish I knew what namespaces are so I could contribute. :P

    Recoil42 on
  • urahonkyurahonky Registered User regular
    edited October 2008
    ASimPerson and eeccoo, thanks for the information. I see exactly what you guys are saying. It's starting to finally make some sense. So basically I need to be making a metric TON of bridges using the .FILL command?

    I also started reading through the pdf to see what's going on... And I noticed this:
    10 points: 4-hex digit input: Your project must include an input routine that
    properly prompts the user for a 4-hex digit inputs. It must properly translate the
    ASCII inputs into a 16-bit value returned in R0.

    I was completely confused on what the hell that meant, so I sent him an email:
    > Dr Doom,
    >
    > I am currently finishing up my TRAP x40 routine and am a little confused by
    > the wording of the pdf file. It says:
    >
    > "10 points: 4-hex digit input: Your project must include an input routine
    > that
    > properly prompts the user for a 4-hex digit inputs. It must properly
    > translate the
    > ASCII inputs into a 16-bit value returned in R0."
    >
    > So if I have my program taking the user's input of: "xFE01" and storing them
    > into x3100 - x3104, would that be wrong?

    That would be, as you say, wrong. The 5 ASCII characters xFE01 are
    being entered to represented a 16-bit LC-3 memory address (xFE01).
    Each ASCII character is a seperate 8-bit value. You need to covert
    these characters and combine them into the appropriate 16-bit value
    that represents and LC-3 memory address in a single register (R0). It
    is _this_ value that you will use in your main program to access
    memory address that you will dump to the screen.

    So basically xFE01 needs to be represented in one 16 bit binary number, right? The problem is, I'm not quite sure how to do that.

    I guess I just ignore the x, right? And if they type in F, then I put 1111 in the left most spot, then...

    Wait. I would have to add whatever Hex number they type in, into a spot in memory. Oh I think I have an idea of what the hell to do. :P

    (Sorry, brainstorming out loud... I don't have anyone around me that is computer programming literate so I have to type everything out here.)

    e: which is exactly why he gave us the shift right command! For the output!

    urahonky on
  • JaninJanin Registered User regular
    edited October 2008
    Nightslyr wrote: »
    Hey guys, quick namespace question.

    I'm having an argument with another PHP coder. Apparently, PHP is going to be adding namespace support in the next minor revision, 5.3. Of course, PHP is doing it the half-assed/ugly way, so the namespace resolution operator is '\'. In other words:

    [...]

    Am I missing something here? I mean, provided the next version of PHP is written somewhat logically, why wouldn't that work? I know that other languages use '::' for both classes and namespaces, so I fail to see why PHP can't do the same, outside of their half-ass pedigree.

    HAHAHAHAHA

    PHP's parser is garbage. It can't differentiate between the same operator used in different contexts, so since :: is used for static method resolution it can't be used for namespaces. Same reason why you can't use a period to access object attributes, or plus to concatenate strings.

    Janin on
    [SIGPIC][/SIGPIC]
  • NightslyrNightslyr Registered User regular
    edited October 2008
    Janin wrote: »
    Nightslyr wrote: »
    Hey guys, quick namespace question.

    I'm having an argument with another PHP coder. Apparently, PHP is going to be adding namespace support in the next minor revision, 5.3. Of course, PHP is doing it the half-assed/ugly way, so the namespace resolution operator is '\'. In other words:

    [...]

    Am I missing something here? I mean, provided the next version of PHP is written somewhat logically, why wouldn't that work? I know that other languages use '::' for both classes and namespaces, so I fail to see why PHP can't do the same, outside of their half-ass pedigree.

    HAHAHAHAHA

    PHP's parser is garbage. It can't differentiate between the same operator used in different contexts, so since :: is used for static method resolution it can't be used for namespaces. Same reason why you can't use a period to access object attributes, or plus to concatenate strings.

    Ah, that explains it then. Honestly, though, WTF? They can't overload a simple operator? Christ....

    The 'arguments' I've read supporting the \ have been mind boggling. They're all pretty much along the lines of "Yeah, it'll take some getting used to, and it's ugly as sin, but at least there won't be any ambiguous code!" Of course, these are the same people bitching that PHP is becoming too much like Java for their liking.

    The more I deal with PHP, the more I see the flaws. A gazillion built-in functions, many redundant. No standard naming scheme for these functions (see: mysql_query() vs. htmlentities()). Magic quotes. OOP functionality, such as it is, tacked on. Namespaces tacked on. Retarded syntax (no dot-notation for objects, using . for string concatenation rather than +, etc).

    The boys at Zend should just rewrite the entire damn thing. The current language is a bloated mess with no clear sense of direction.

    Please tell me that Ruby on Rails and/or Python are better languages (I know, I know...Rails is a framework) than this. I like keeping an open source language under my belt, and PHP is wearing on me. I have no problem jumping from this sinking ship.

    Nightslyr on
    PSN/XBL/Nintendo/Origin/Steam: Nightslyr 3DS: 1607-1682-2948
    Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
  • LoneIgadzraLoneIgadzra Registered User regular
    edited October 2008
    Nightslyr wrote: »
    Please tell me that Ruby on Rails and/or Python are better languages (I know, I know...Rails is a framework) than this. I like keeping an open source language under my belt, and PHP is wearing on me. I have no problem jumping from this sinking ship.

    For quick and dirty server-side-generated pages I'm not really sure how to replace PHP, but Ruby on Rails is pretty awesome, though I haven't had much luck figuring out the basic architecture of it.

    LoneIgadzra on
  • NightslyrNightslyr Registered User regular
    edited October 2008
    Here are a few general, "should I know this" questions that have been nagging me:

    1. XML. I know that XML is commonly used as a simple data exchange format, but I've never really needed to use it. The only use I've seen, aside from things like RSS feeds, is as a config file for PHP apps. What other uses does it have? Is it really used widely in the 'real world'? What should I be comfortable with in dealing with XML? Should I be able to write my own schemas, or whatever else is used along with it?

    2. Good web design. I started dabbling with HTML when 640 x 480 was the norm. I don't really know what constitutes good, modern web design. Liquid layouts? A certain minimum size? How would I smartly use the 'above the fold' real estate for navigation (i.e., pixel sizes and/or percentages)? Are there any guidelines/best practices I should be aware of? I've never been great at visual design. I tend to go for safe, spartan looks that are hard to screw up. I plan on being more of a behind-the-scenes developer (read: backend), but I probably should be aware of these things.

    3. Application environment. I'm more comfortable developing on a *nix/Apache machine rather than an IIS machine. That said, I've never really had to play with the environment too much. I've set up an Ubuntu Apache server once, but I never had to touch it once it was up and running. So, does a developer really need to know much about the environment they're on? Obviously, knowing about your environment can't hurt, but how necessary is it in the 'real world'?

    Basically, I just want to know what tends to be expected of a developer in the real world. I'm trying to get through my studies as efficiently as possible so I can actually find a job, and I don't want to focus on things I won't really need. I figure that if I do need to be knowledgeable on all these fronts, now is the time to learn, rather than on the job while I cost my employer money.

    Nightslyr on
    PSN/XBL/Nintendo/Origin/Steam: Nightslyr 3DS: 1607-1682-2948
    Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
  • urahonkyurahonky Registered User regular
    edited October 2008
    Damn it all. I'm so very far into this program, but I have a bad feeling that I am doing this completely wrong.

    Here is what I'm reading that concerns me:
    Input (Trap x40): A Trap routine (invoked as TRAP x40) that queries the user for
    a 4-digit hex value and returns the value in R0. You will develop this trap routine
    and locate it in memory at address x4000.

    And this is what my Trap x40 looks like:
    .ORIG x4000
    		LEA R0, PROMPTST	; Prompt to enter starting memory
    		TRAP x22		; address
    		AND R3, R3, #0		; Ensures R3 is 0
    		ADD R3, R3, #5		; Adds 5 to R3 (makes this the counter)
    		TRAP x20		; Gets the input of the first char then outputs it
    		TRAP x21
    		ADD R3, R3, #-1		; Subtracts 1 from the counter
    		LD R2, NTLETTERX	; Loads in the "Not" of the letter x
    		AND R2, R2, R0		; ANDs them together to see if it's 0
    		BRZ LOOPST		; If zero, continue on to the loop
    WRONGST		LD R0, LF
    		TRAP x21
    		LEA R0, ENTERX
    		TRAP x22
    		TRAP x20		; Gets the input char then outputs it
    		TRAP x21
    		LD R2, NTLETTERX	; Loads in the "Not" of the letter x
    		AND R2, R2, R0		; ANDs them together to see if it's 0
    		BRNP WRONGST		; If zero, continue on
    LOOPST		TRAP x20		; Gets the input of the first char then outputs it
    		TRAP x21
    		LD R2, NTNINE		; Loads the !9 into R2, to test if it's a
    		ADD R2, R2, R0		; Letter or number
    		BRP LET			; If positive, then it's a number
    		LD R2, NTZERO
    		AND R2, R2, R0
    		BRN WRONGINPUT		; If it's still negative, then it's less than 0
    NUM		ADD R0, R0, #-16	; Converts it to the decimal number
    		ADD R0, R0, #-16	; NUM means that it is a number
    		ADD R0, R0, #-16
    		ADD R2, R3, #-4		; This checks if counter is 4
    		BRZ NCOUNTFOUR
    		ADD R2, R3, #-3
    		BRZ NCOUNTTHRE
    		ADD R2, R3, #-2
    		BRZ NCOUNTTWO
    		ADD R2, R3, #-1
    		ADD R1, R1, R0
    		ADD R3, R3, #-1
    		BRZ ENDADD
    NCOUNTFOUR	ADD R0, R0, R0		; If counter is 4, then you need to add
    		ADD R0, R0, R0		; To itself 12 times, so I set it up to
    		ADD R0, R0, R0		; Add 3 times and and reduce the counter
    		ADD R3, R3, #-1		; By one each time
    		BRP NCOUNTFOUR
    		AND R1, R1, #0
    		ADD R1, R0, #0
    		AND R3, R3, #0
    		ADD R3, R3, #3
    		BRNZP LOOPST
    NCOUNTTHRE	ADD R0, R0, R0		; If counter is 3, then you need to add to
    		ADD R0, R0, R0		; Itself 8 times, so I had it add to itself
    		ADD R3, R3, #-1		; Twice, and reduce the counter by one.
    		BRZP NCOUNTTHRE		; Including zero in its bridge
    		ADD R1, R1, R0
    		AND R3, R3, #0
    		ADD R3, R3, #2
    		BRNZP LOOPST
    NCOUNTTWO	ADD R0, R0, R0		; If counter is 2, then you only need to do
    		ADD R0, R0, R0		; it 4 times, so I multiplied it twice two
    		ADD R3, R3, #-1		; times.
    		BRP NCOUNTTWO
    		ADD R1, R1, R0
    		AND R3, R3, #0
    		ADD R3, R3, #1
    		BRNZP LOOPST
    LET		AND R3, R3, #0
    ; Ending Address
    ENDADD		LD R0, LF		; Places an endline to make output better
    		TRAP x21
    		LEA R0, PROMPTEN	; Outputs the prompt for the end memory address
    		TRAP x22
    		AND R3, R3, #0		; Ensures R3 is 0
    		ADD R3, R3, #5		; Adds 5 to R3 (counter)
    		TRAP x20		; Gets the input of the first char then outputs it
    		TRAP x21
    		ADD R3, R3, #-1		; Subtracts 1 from the counter
    		LD R2, NTLETTERX	; Loads in the "Not" of the letter x
    		AND R2, R2, R0		; ANDs them together to see if it's 0
    		BRZ LOOPEN		; If zero, continue on to the loop
    WRONGEN		LD R0, LF
    		TRAP x21
    		LEA R0, ENTERX
    		TRAP x22
    		TRAP x20		; Gets the input char then outputs it
    		TRAP x21
    		LD R2, NTLETTERX	; Loads in the "Not" of the letter x
    		AND R2, R2, R0		; ANDs them together to see if it's 0
    		BRNP WRONGEN		; If zero, continue on
    LOOPEN		TRAP x20		; Gets the input of the first char then outputs it
    		TRAP x21
    		ADD R3, R3, #-1		; Subtracts 1 from the counter
    		BRP LOOPEN		; If counter is still >0 then, run to the loop
    WRONGINPUT	LEA R0, INVALID
    		TRAP x22
    		HALT
    PROMPTST	.STRINGZ "Enter Starting Memory Address: "
    PROMPTEN	.STRINGZ "Enter Ending Memory Address: "
    ENTERX		.STRINGZ "Please enter the memory address starting with 'x': "
    INVALID		.STRINGZ "Invalid Hexidecimal number. Please re-enter: "
    LF		.FILL x000A
    NTLETTERX	.FILL xFF87
    NTZERO		.FILL xFFCF
    NTNINE		.FILL xFFC6
    NTA		.FILL xFFBE
    NTF		.FILL xFFB9
    FOUR		.FILL x0004
    .END
    

    And that's just for numbers, I have to make another one for the Letters. The problem I'm running into is that it says "A Trap routine (invoked as TRAP x40) that queries the user for a 4-digit hex value and returns the value in R0." So... Does that mean my main program should ask the user first? Then call the TRAP x40 function? Example:

    This is what the I/O should look like:
    Enter starting memory address:
    [B]x3000[/B]
    Enter ending memory address:
    [B]x3001[/B]
    Memory contents x3000 to x3001:
    x3000 xF030
    x3001 xF025
    

    Bolded is the user's input. My program, as it stands, does all this in TRAP x40. FUCK it's so hard to explain. Does anyone get what I'm saying?

    Should I trim my TRAP function to ONLY work with whatever is entered? Like... The main program puts up the prompt for the Starting address, then whatever's entered gets sent to this trap. Then it goes back to the main program and then it asks for the ending address... THEN it goes back to the trap again to do its job?

    urahonky on
  • urahonkyurahonky Registered User regular
    edited October 2008
    Son of a bitch. I don't get it. I am now getting an error:

    Line 9: Instruction references label "NTX" that cannot be referenced in 9 bit signed PC offset.

    Okay. But it has been working this entire fucking time. So I deleted the line that I just typed, and the error goes away. And it has NOTHING at all to do with the NTX label.

    This is the code:
    WRONGINPUT	LD R2, LF
    		TRAP x22
    		LEA R0, INVALID
    		TRAP x22
    		BRNZP LOOPST
    		HALT
    

    That gives the error.
    WRONGINPUT	LEA R0, INVALID
    		TRAP x22
    		BRNZP LOOPST
    		HALT
    

    Doesn't. It looks like it's doing it all around my entire program now. If I add a new line, no matter what it is, it gives me that error. Any ideas?

    urahonky on
  • JaninJanin Registered User regular
    edited October 2008
    Nightslyr wrote: »
    Please tell me that Ruby on Rails and/or Python are better languages (I know, I know...Rails is a framework) than this. I like keeping an open source language under my belt, and PHP is wearing on me. I have no problem jumping from this sinking ship.

    Yes, both Ruby and Python are significantly better languages than PHP. Both also have mature frameworks (Rails, Django) that easily surpass anything in the PHP world. I prefer Python's community -- many of the Ruby community are expats from PHP, and have carried the "as long as it works" mentality with them.
    Nightslyr wrote: »
    1. XML. I know that XML is commonly used as a simple data exchange format, but I've never really needed to use it. The only use I've seen, aside from things like RSS feeds, is as a config file for PHP apps. What other uses does it have? Is it really used widely in the 'real world'? What should I be comfortable with in dealing with XML? Should I be able to write my own schemas, or whatever else is used along with it?

    XML is heavily used -- in my opinion, over-used. You should have some idea about the difference between SAX and DOM parsers, and how to use XPath. Learn a schema language like RELAX NG.
    Nightslyr wrote: »
    2. Good web design. I started dabbling with HTML when 640 x 480 was the norm. I don't really know what constitutes good, modern web design. Liquid layouts? A certain minimum size? How would I smartly use the 'above the fold' real estate for navigation (i.e., pixel sizes and/or percentages)? Are there any guidelines/best practices I should be aware of? I've never been great at visual design. I tend to go for safe, spartan looks that are hard to screw up. I plan on being more of a behind-the-scenes developer (read: backend), but I probably should be aware of these things.

    Look at nice examples of modern web design, such as CSS Zen Garden. Prefer resizeable layouts, em- and percent- based sizes, and try to avoid layouts based on tables. There's nothing wrong with a spartan design -- a design is complete when there is nothing left to take away.
    Nightslyr wrote: »
    3. Application environment. I'm more comfortable developing on a *nix/Apache machine rather than an IIS machine. That said, I've never really had to play with the environment too much. I've set up an Ubuntu Apache server once, but I never had to touch it once it was up and running. So, does a developer really need to know much about the environment they're on? Obviously, knowing about your environment can't hurt, but how necessary is it in the 'real world'?

    Depends on the size of the company you'll be working at. Middle and large companies have system admins for servers, who will get touchy if a developer starts mucking about. If you're at a small company, you'll want to learn at least the basics of maintenance (log rotation, installing updates, apache configuration files, etc). Most developers are competent enough to set up a small server at home, at the least.

    Janin on
    [SIGPIC][/SIGPIC]
  • ASimPersonASimPerson Cold... and hard.Registered User regular
    edited October 2008
    urahonky wrote: »
    Son of a bitch. I don't get it. I am now getting an error:

    Line 9: Instruction references label "NTX" that cannot be referenced in 9 bit signed PC offset.

    Well, first, is the code you just added causing NTX to be more than 255 instructions away from the instruction that references it? Alternatively, did you spell the label correctly?

    By the way, "TRAP x22" and "PUTS" are the same, and the latter is easier to read.

    ASimPerson on
  • ASimPersonASimPerson Cold... and hard.Registered User regular
    edited October 2008
    Also, I think this is pretty straightforward:
    Input (Trap x40): A Trap routine (invoked as TRAP x40) that queries the user for a 4-digit hex value and returns the value in R0. You will develop this trap routine and locate it in memory at address x4000.

    TRAP x40 should ask the user for a 4-digit hex value and then store the value in R0. This routine should be at address x4000. I would interpret this to mean that the user calls the trap and then it asks for a hexadecimal number.

    ASimPerson on
  • Smug DucklingSmug Duckling Registered User regular
    edited October 2008
    PHP is the retarded child in the family, while Python and Ruby are the cool uncles and Perl is the weird creepy uncle who never brushes his hair and mumbles all the time (and yet is somehow fabulously wealthy).

    But seriously, PHP's design is an abomination. I much, much prefer using Perl CGI scripts for web stuff (but that's because I'm a Perl guy) and it is so great not having to deal with PHP's clunky syntax and millions of key words.
    Nightslyr wrote: »
    Here are a few general, "should I know this" questions that have been nagging me:

    1. XML. I know that XML is commonly used as a simple data exchange format, but I've never really needed to use it. The only use I've seen, aside from things like RSS feeds, is as a config file for PHP apps. What other uses does it have? Is it really used widely in the 'real world'? What should I be comfortable with in dealing with XML? Should I be able to write my own schemas, or whatever else is used along with it?

    XML is important. It's a great way to store configuration files for various things, and for simple applications, it's not a very complicated format. Definitely something worth looking in to.
    2. Good web design. I started dabbling with HTML when 640 x 480 was the norm. I don't really know what constitutes good, modern web design. Liquid layouts? A certain minimum size? How would I smartly use the 'above the fold' real estate for navigation (i.e., pixel sizes and/or percentages)? Are there any guidelines/best practices I should be aware of? I've never been great at visual design. I tend to go for safe, spartan looks that are hard to screw up. I plan on being more of a behind-the-scenes developer (read: backend), but I probably should be aware of these things.

    There are lots of general guidelines. Like you, I'm not very into the frontend web design stuff, but there are lots of good principles. If you're interested, grab a good book on web design and give it a read. It's quite an interesting area (although of course no two people will ever agree on it).
    3. Application environment. I'm more comfortable developing on a *nix/Apache machine rather than an IIS machine. That said, I've never really had to play with the environment too much. I've set up an Ubuntu Apache server once, but I never had to touch it once it was up and running. So, does a developer really need to know much about the environment they're on? Obviously, knowing about your environment can't hurt, but how necessary is it in the 'real world'?

    Basically, I just want to know what tends to be expected of a developer in the real world. I'm trying to get through my studies as efficiently as possible so I can actually find a job, and I don't want to focus on things I won't really need. I figure that if I do need to be knowledgeable on all these fronts, now is the time to learn, rather than on the job while I cost my employer money.

    I'm only a co-op student, but in my several work placements I've *never* had to deal with setting up or being intimately familiar with my environment, beyond knowing how to use it. That's what they have IT departments for. :)

    Smug Duckling on
    smugduckling,pc,days.png
  • urahonkyurahonky Registered User regular
    edited October 2008
    ASimPerson wrote: »
    Also, I think this is pretty straightforward:
    Input (Trap x40): A Trap routine (invoked as TRAP x40) that queries the user for a 4-digit hex value and returns the value in R0. You will develop this trap routine and locate it in memory at address x4000.

    TRAP x40 should ask the user for a 4-digit hex value and then store the value in R0. This routine should be at address x4000. I would interpret this to mean that the user calls the trap and then it asks for a hexadecimal number.

    Yeah it looks like that I am making it too complicated. The main program should be the one to ask for the user's input number. The TRAP x40 is only there to take the input (just like TRAP x20 is) and place the answer into R0, which the main uses to store it somewhere else in memory or whatever.

    Thanks for the replies ASimPerson. I went to bed pretty early last night. :P

    urahonky on
  • urahonkyurahonky Registered User regular
    edited October 2008
    Hmm. Anyone have any links to how to make a trap vector table? I've never heard this before. And right now my trap doesn't seem to work. :(

    The instructions say:
    tvp.asm: contents for the trap vector table necessary to enable your routine.

    The book has no information, and neither do the powerpoints that he has up on the net.

    urahonky on
  • urahonkyurahonky Registered User regular
    edited October 2008
    Looks like if I'm making TRAP x40 and TRAP x41 I need to put in the address where the corresponding trap is located. But my issue is that I'm not quite sure how to do that.

    So basically x0040 -> point to x4000
    And x0041 -> point to x5000

    urahonky on
  • jonxpjonxp [E] PC Security Registered User regular
    edited October 2008
    Regarding Math Requirements for CS:

    The tough math classes you take (especially things like linear algebra and the like) help you achieve optimized algorithms. If your code performs in O(1) and the other guy's performs at O(n), because you knew how to find a random spot in a sequence, then you're gonna be the one not laid off. These things may be useless for the most part when dealing with high level stuff (C#, PHP, Ruby) where algorithm optimization is "somebody else's problem", eventually you may want to, or need to, be that somebody else.

    jonxp on
    Every time you write parallel fifths, Bach kills a kitten.
    3DS Friend Code: 2707-1614-5576
    PAX Prime 2014 Buttoneering!
  • urahonkyurahonky Registered User regular
    edited October 2008
    jonxp wrote: »
    Regarding Math Requirements for CS:

    The tough math classes you take (especially things like linear algebra and the like) help you achieve optimized algorithms. If your code performs in O(1) and the other guy's performs at O(n), because you knew how to find a random spot in a sequence, then you're gonna be the one not laid off. These things may be useless for the most part when dealing with high level stuff (C#, PHP, Ruby) where algorithm optimization is "somebody else's problem", eventually you may want to, or need to, be that somebody else.

    You're talking about the Big O stuff right? Man, I couldn't get that at all in my Data Structures and Algorithms class. I'm retaking it next quarter.

    urahonky on
  • DaedalusDaedalus Registered User regular
    edited October 2008
    jonxp wrote: »
    Regarding Math Requirements for CS:

    The tough math classes you take (especially things like linear algebra and the like) help you achieve optimized algorithms. If your code performs in O(1) and the other guy's performs at O(n), because you knew how to find a random spot in a sequence, then you're gonna be the one not laid off. These things may be useless for the most part when dealing with high level stuff (C#, PHP, Ruby) where algorithm optimization is "somebody else's problem", eventually you may want to, or need to, be that somebody else.

    Also, linear algebra is ridiculously useful for graphics stuff, and statistics is useful in tons of ways. Some colleges have a catch-all "discrete mathematics" course that's also useful.

    Calculus not so much. I have a weird feeling that calculus is required in most CS curricula just because it's the math class that you're supposed to take when you're in college, or something.

    Daedalus on
  • urahonkyurahonky Registered User regular
    edited October 2008
    Man this LC3 crap is really annoying me. I realize it's nice to know that C++ and other languages are just a higher form of this... It just sucks to have to program in it.

    Any ideas on how to get the output to work correctly? Basically you pass in R0 that contains the memory address in the form of something like: x41FF, and then you have to output that memory address to the screen exactly as it's written above.

    I am able to get the x, then the 4. But once I get to the 0 it gets complicated. I need to find a way to subtract the 4 out of there. I've tried "NOT"ing the x0040 And then adding that to the x0041 but it doesn't seem to come out correctly.

    Partial code if you need to see it:
    SHIFTR		ST  R1, R1SAVE		; Save callee-save registers
    		ST  R2, R2SAVE
    		AND R1, R1, #0		; R1 holds the itermediate result
    		AND R2, R2, #0		; R2 holds count for number of bits examined
    		ADD R2, R2, #15		
    NextBit		ADD R0, R0, #0		; Test MSB for 1 or 0
    		BRn MSBIS1		
    MSBIS0		ADD R1, R1, R1		;shift result left 
    					;force LSB to 0
    		ADD R0, R0, R0		;shift original value left; check next bit
    		BR  TestDone
    
    MSBIS1		ADD R1, R1, R1		;shift running total right
    		ADD R1, R1, #1		;force LSB to 1
    		ADD R0, R0, R0		;shift original value left; check next bit
    
    TestDone	ADD R2, R2, #-1
    		ST R0, R0SAVE
    		ADD R3, R2, #-11
    		BRZ TWELVE
    		ADD R3, R2, #-7
    		BRZ EIGHT
    		ADD R3, R2, #-3
    		BRZ FOUR
    		ADD R3, R2, #0
    		BRZ ZERO
    NEXT		ADD R2, R2, #0
    		BRP NextBit
    Done		ADD R0, R1, #0		; Move result to R0
    	        LD  R2, R2SAVE		; Restore callee-save registers
                    LD  R1, R1SAVE
                    RET
    TWELVE		ADD R3, R1, #-10
    		BRZP TLET
    TNUM		AND R3, R3, #0
    		ADD R3, R1, #0
    		ADD R3, R3, #15
    		ADD R3, R3, #15
    		ADD R3, R3, #15
    		ADD R3, R3, #3
    		AND R0, R0, #0
    		ADD R0, R3, #0
    		TRAP x21
    		ST R3, R3SAVE
    		LD R0, R0SAVE
    		BRNZP NEXT		
    TLET		AND R3, R3, #0
    		ADD R3, R1, #0
    		ADD R3, R3, #15
    		ADD R3, R3, #15
    		ADD R3, R3, #15
    		ADD R3, R3, #10
    		AND R0, R0, #0
    		ADD R0, R3, #0
    		TRAP x21
    		ST R3, R3SAVE
    		LD R0, R0SAVE
    		BRNZP NEXT
    EIGHT		LD R3, R3SAVE
    		NOT R3, R3
    		ADD R3, R3, R1
    ENUM		AND R3, R3, #0
    ELET		AND R3, R3, #0
    FOUR		AND R3, R3, #0
    FNUM		AND R3, R3, #0
    FLET		AND R3, R3, #0
    ZERO		AND R3, R3, #0
    ZNUM		AND R3, R3, #0
    ZLET		AND R3, R3, #0
    

    The stuff at the end is just a placeholder for me.

    e: Finally figured out the trap vector thing. So incredibly easy!! BOO! Now to figure out why my main program and input function aren't playing very nice :(

    urahonky on
  • urahonkyurahonky Registered User regular
    edited October 2008
    I know I have been hounding this thread for the past few days, and I'm sorry. I just wish there was a person I could talk to in person to help me with this program.

    Now that I have the trap vector working, I can load up my main and my input function to test them. And it looks like when I type TRAP x40 it is working correctly, but I can't seem to figure out how to go back to the main program when my input function is complete. Using the RET command it goes straight back to the beginning of the input function and then gives me an error. I tried setting up a bridge to go back to the main program but it doesn't take.

    Here's what my main looks like (really sloppy right now):
    .ORIG x3000
    		LEA R0, PROMPTST	; Prompt to enter starting memory
    		TRAP x22		; address
    		TRAP x40
    		LD R0, LF		; Places an endline to make output better
    		TRAP x21
    		LEA R0, PROMPTEN	; Outputs the prompt for the end memory address
    		TRAP x22
    		HALT
    PROMPTST	.STRINGZ "Enter Starting Memory Address: "
    PROMPTEN	.STRINGZ "Enter Ending Memory Address: "
    LF		.FILL x000A
    .END
    
    And the input function:
    .ORIG x4000
    		AND R3, R3, #0		; Ensures R3 is 0
    		ADD R3, R3, #5		; Adds 5 to R3 (makes this the counter)
    		TRAP x20		; Gets the input of the first char then outputs it
    		TRAP x21
    		ADD R3, R3, #-1		; Subtracts 1 from the counter
    		LD R2, xFF87		; Loads in the "Not" of the letter x
    		AND R2, R2, R0		; ANDs them together to see if it's 0
    		BRZ LOOPST		; If zero, continue on to the loop
    WRONGST		LD R0, LF
    		TRAP x21
    		LEA R0, ENTERX
    		TRAP x22
    		TRAP x20		; Gets the input char then outputs it
    		TRAP x21
    		LD R2, NTX		; Loads in the "Not" of the letter x
    		AND R2, R2, R0		; ANDs them together to see if it's 0
    		BRNP WRONGST		; If zero, continue on
    LOOPST		TRAP x20		; Gets the input of the first char then outputs it
    		TRAP x21
    		LD R2, NTNINE		; Loads the !9 into R2, to test if it's a
    		ADD R2, R2, R0		; Letter or number
    		BRP LET			; If positive, then it's a number
    		LD R2, NTZERO
    		AND R2, R2, R0
    		BRN WRONGINPUT		; If it's still negative, then it's less than 0
    NUM		ADD R0, R0, #-16	; Converts it to the decimal number
    		ADD R0, R0, #-16	; NUM means that it is a number
    		ADD R0, R0, #-16
    		ADD R2, R3, #-4		; This checks if counter is 4
    		BRZ NCOUNTFOUR
    		ADD R2, R3, #-3
    		BRZ NCOUNTTHRE
    		ADD R2, R3, #-2
    		BRZ NCOUNTTWO
    		ADD R2, R3, #-1
    		ADD R1, R1, R0
    		ADD R3, R3, #-1
    		BRZ END
    NCOUNTFOUR	ADD R0, R0, R0		; If counter is 4, then you need to add
    		ADD R0, R0, R0		; To itself 12 times, so I set it up to
    		ADD R0, R0, R0		; Add 3 times and and reduce the counter
    		ADD R3, R3, #-1		; By one each time
    		BRP NCOUNTFOUR
    		AND R1, R1, #0
    		ADD R1, R0, #0
    		AND R3, R3, #0
    		ADD R3, R3, #3
    		BRNZP LOOPST
    NCOUNTTHRE	ADD R0, R0, R0		; If counter is 3, then you need to add to
    		ADD R0, R0, R0		; Itself 8 times, so I had it add to itself
    		ADD R3, R3, #-1		; Twice, and reduce the counter by one.
    		BRZP NCOUNTTHRE		; Including zero in its bridge
    		ADD R1, R1, R0
    		AND R3, R3, #0
    		ADD R3, R3, #2
    		BRNZP LOOPST
    NCOUNTTWO	ADD R0, R0, R0		; If counter is 2, then you only need to do
    		ADD R0, R0, R0		; it 4 times, so I multiplied it twice two
    		ADD R3, R3, #-1		; times.
    		BRP NCOUNTTWO
    		ADD R1, R1, R0
    		AND R3, R3, #0
    		ADD R3, R3, #1
    		BRNZP LOOPST
    LET		LD R2, NTF
    		ADD R2, R2, R0
    		ADD R2, R2, #1
    		BRP WRONGINPUT
    		ADD R0, R0, #-16
    		ADD R0, R0, #-16
    		ADD R0, R0, #-16
    		ADD R0, R0, #-7
    		ADD R2, R3, #-4		; This checks if counter is 4
    		BRZ LCOUNTFOUR
    		ADD R2, R3, #-3
    		BRZ LCOUNTTHRE
    		ADD R2, R3, #-2
    		BRZ LCOUNTTWO
    		ADD R2, R3, #-1
    		ADD R1, R1, R0
    		ADD R3, R3, #-1
    		BRZ END
    LCOUNTFOUR	ADD R0, R0, R0		; If counter is 4, then you need to add
    		ADD R0, R0, R0		; To itself 12 times, so I set it up to
    		ADD R0, R0, R0		; Add 3 times and and reduce the counter
    		ADD R3, R3, #-1		; By one each time
    		BRP LCOUNTFOUR
    		AND R1, R1, #0
    		ADD R1, R0, #0
    		AND R3, R3, #0
    		ADD R3, R3, #3
    		BRNZP LOOPST
    LCOUNTTHRE	ADD R0, R0, R0		; If counter is 3, then you need to add to
    		ADD R0, R0, R0		; Itself 8 times, so I had it add to itself
    		ADD R3, R3, #-1		; Twice, and reduce the counter by one.
    		BRZP LCOUNTTHRE		; Including zero in its bridge
    		ADD R1, R1, R0
    		AND R3, R3, #0
    		ADD R3, R3, #2
    		BRNZP LOOPST
    LCOUNTTWO	ADD R0, R0, R0		; If counter is 2, then you only need to do
    		ADD R0, R0, R0		; it 4 times, so I multiplied it twice two
    		ADD R3, R3, #-1		; times.
    		BRP LCOUNTTWO
    		ADD R1, R1, R0
    		AND R3, R3, #0
    		ADD R3, R3, #1
    		BRNZP LOOPST	
    WRONGINPUT	LD R2, LF
    		Trap x21		
    		LEA R0, INVALID
    		TRAP x22
    		BRNZP LOOPST
    END		AND R0, R0, #0
    		ADD R0, R1, R0
    		RET
    ENTERX		.STRINGZ "Please enter the memory address starting with 'x': "
    INVALID		.STRINGZ "Invalid Hexidecimal number. Please re-enter: "
    MAIN		.FILL x3003
    LF		.FILL x000A
    NTX		.FILL xFF87
    NTZERO		.FILL xFFCF
    NTNINE		.FILL xFFC6
    NTA		.FILL xFFBE
    NTF		.FILL xFFB9
    FOUR		.FILL x0004
    .END
    

    The RET at the end there forces it to go through the function again. I can't seem to figure out how to get back to the next line in the main function.

    urahonky on
  • SabanSaban Registered User regular
    edited October 2008
    I asked a bit ago about a good post with book recommendations but i didn't specify which language i was looking for.

    I'm looking for stuff relating to Visual C#/XNA stuff, but not just game programming books. I'd like books that set up good programming practices and such. I'm working my way through Microsoft C# Game programming for the absolute beginner right now, and i'm going to need some new stuff pretty quick.

    Saban on
    371839-1.png
  • ASimPersonASimPerson Cold... and hard.Registered User regular
    edited October 2008
    urahonky wrote: »
    I know I have been hounding this thread for the past few days, and I'm sorry. I just wish there was a person I could talk to in person to help me with this program.

    Now that I have the trap vector working, I can load up my main and my input function to test them. And it looks like when I type TRAP x40 it is working correctly, but I can't seem to figure out how to go back to the main program when my input function is complete. Using the RET command it goes straight back to the beginning of the input function and then gives me an error. I tried setting up a bridge to go back to the main program but it doesn't take.

    1) Does your class not have TAs, discussion boards, etc?
    2) How are the built-in TRAP commands implemented? Just use whatever instruction they use to return.

    Edit: More correctly, think about what RET does. Look at the documentation for TRAP and RET and see if you can figure out why it isn't working the way you want. (The crappy thing about assembly is that this is doing exactly what you're telling it to, you're just not telling it to do the correct thing... :))

    ASimPerson on
  • urahonkyurahonky Registered User regular
    edited October 2008
    ASimPerson wrote: »
    urahonky wrote: »
    I know I have been hounding this thread for the past few days, and I'm sorry. I just wish there was a person I could talk to in person to help me with this program.

    Now that I have the trap vector working, I can load up my main and my input function to test them. And it looks like when I type TRAP x40 it is working correctly, but I can't seem to figure out how to go back to the main program when my input function is complete. Using the RET command it goes straight back to the beginning of the input function and then gives me an error. I tried setting up a bridge to go back to the main program but it doesn't take.

    1) Does your class not have TAs, discussion boards, etc?
    2) How are the built-in TRAP commands implemented? Just use whatever instruction they use to return.

    Edit: More correctly, think about what RET does. Look at the documentation for TRAP and RET and see if you can figure out why it isn't working the way you want. (The crappy thing about assembly is that this is doing exactly what you're telling it to, you're just not telling it to do the correct thing... :))

    Aha! R7 is the location of wherever the RET returns to, so if I save R7 before loading my input program it works great!

    So right now my trap vector table, main, and input all work. Just working on my output. Which won't be so bad, but the way I'm doing it is incredibly inefficient.

    And I'm at the Help Room now. It's my own fault, because I don't start these programs till a few days till they are due. And the Help Room only happens on Tuesday and Friday. So by the time I start it (Sunday) and the time it's due (Tuesday) I screw myself. :P

    urahonky on
  • Airking850Airking850 Ottawa, ONRegistered User regular
    edited October 2008
    Saban wrote: »
    I asked a bit ago about a good post with book recommendations but i didn't specify which language i was looking for.

    I'm looking for stuff relating to Visual C#/XNA stuff, but not just game programming books. I'd like books that set up good programming practices and such. I'm working my way through Microsoft C# Game programming for the absolute beginner right now, and i'm going to need some new stuff pretty quick.

    Code Complete is THE book for good programming practices, no matter what language you're using. It contains basically any best practice that a software developer needs to know, and it's written in a way that makes everything accessible (McConnell is great at using analogies to explain software concepts).

    Since you mentioned game development, you're probably interested in designing solid, efficient algorithms; though I haven't read it myself, I've heard from a lot of people that Programming Pearls is great for that kind of thing. It goes through a series of common programming problems, detailing the steps taken to solve the problem then optimize the solution. Then it talks about what concepts from each problem can be extracted and used in different contexts, and gives a set of programming puzzles related to the concepts.

    Airking850 on
  • urahonkyurahonky Registered User regular
    edited October 2008
    Woot! It's working correctly! Oh holy shit this feels great!

    Now to put some comments in :(

    urahonky on
  • MalyonsusMalyonsus Registered User regular
    edited October 2008
    Oh snap. LC-3. That's what our CS oriented assembler class used. It was alright, but the fact that our teacher made us write our program in fake binary for the first half of the course soured me on the whole thing.

    I don't even understand why we had to do it for so long. It's like, yes I get that in real life assembly code can basically be directly converted to a binary sequence. I don't need to write 20 programs using only ones and zeros to get the point. It wasn't even really binary, since it was in text form like this:
    01010001
    10010010
    etc.

    Oh, for the person looking to learn more about web design, I'd recommend A List Apart (website). I haven't been there in ages, but I remember it being pretty good/interesting back in the day.

    Malyonsus on
  • His CorkinessHis Corkiness Registered User regular
    edited October 2008
    I just have to share this delicious piece of code somebody posted on Gamedev.net:
    int Add(int x, int y)
    {
    	char *p = 0;
    
    	return (int)&x[&p[y]];
    }
    
    int main()
    {
    	int eight = Add(5, 3);
    
    	return 0;
    }
    

    Kudos to anyone who figures out exactly how this works without reading the following info about array syntax:
    All that is required syntactically is that one of the expressions (eg the 5 or "array" in array[5]) be of pointer type and the other be of integral type - which is which doesn't matter. Thus the integral value could be before the brackets and the pointer value could be in the brackets, like 5[array]

    His Corkiness on
  • ASimPersonASimPerson Cold... and hard.Registered User regular
    edited October 2008
    Malyonsus wrote: »
    Oh snap. LC-3. That's what our CS oriented assembler class used. It was alright, but the fact that our teacher made us write our program in fake binary for the first half of the course soured me on the whole thing.

    I don't even understand why we had to do it for so long. It's like, yes I get that in real life assembly code can basically be directly converted to a binary sequence.

    Yeah, this is exactly why we did one lab and one homework assignment on "machine" code, since you're basically just asking the students to mechanically convert the assembly to "binary" anyway.

    ASimPerson on
This discussion has been closed.