Session Start (FFHacktics:#ffhs): Sat Mar 24 15:23:16 2012 -0700
*** Aero[homework] has joined #ffhs
<formerdeathcorps> hey Aero
<formerdeathcorps> ready for the lesson?
*** iRyu has quit IRC: Ping timeout: 204 seconds
<Aero[homework]> nope
<Aero[homework]> i'm just preparing
<Aero[homework]> in case you start without me
<formerdeathcorps> I'm not
<Aero[homework]> that way I can follow along
<formerdeathcorps> as no students have shown up
<Aero[homework]> =/
<Aero[homework]> I'll be ready in... an hour tops
<Aero[homework]> I'm going to do a small portion of my homework and try to finish everything tomorrow
<Aero[homework]> I guess I work better with a fire lit under my ass
*** Pride has joined #ffhs
<formerdeathcorps> Pride, do you have the revised weapon XA hack with you?
<Pride> (Link:
http://ffhacktics.com/wiki/Base_Weapon_XA_Rewrite)http://ffhacktics.com/wiki/Base_Weapon_XA_Rewrite<secondadvent> should i throw in some graphical code to be mean? :v
<secondadvent> or to be really mean, BoF3 code?

<formerdeathcorps> in the lesson itself?
<formerdeathcorps> not yet
<secondadvent> what -not- to do
<formerdeathcorps> oh yeah
<formerdeathcorps> but no human being is that stupid
<formerdeathcorps> only compilers doing type casts can
<formerdeathcorps> do that
<formerdeathcorps> SA, actually I want you to talk about disk sectors
<formerdeathcorps> and compression
<formerdeathcorps> you know more about both than me
<formerdeathcorps> but that won't be necessary until we talk about "special topics"
<secondadvent> (Link:
http://www.gamefront.com/files/21463912/facepalm.txt)http://www.gamefront.com/files/21463912/facepalm.txt<secondadvent> while these two routines are badly done, it should still be something that's somewhat easy to read/get started with

<secondadvent> not FFT, but still
<Aero[homework]> why hasn't someone rewritten most of the game yet?
<Aero[homework]> i mean small patches are nice, but you'd think with all this information sweeping optimizations would have been made
<Aero[homework]> in at least one area, anyways
<Aero[homework]> or am I uninformed?
<formerdeathcorps> Have you written code before, Aero?
<Aero[homework]> not ASM for FFT
<Aero[homework]> is it overbearing?
<Aero[homework]> *overwhelming
<formerdeathcorps> It's worse than Squarecode
<Aero[homework]> You mean code Square uses for games other than FFT?
<formerdeathcorps> No
<formerdeathcorps> I mean code written by kids just out of college
<formerdeathcorps> who forgot their Data Structures class
<Aero[homework]> ... I was talking about that word "Squarecode"
<formerdeathcorps> No, Aero...that's Square's code
<formerdeathcorps> for any game
<formerdeathcorps> FFT/FFVII anything
<formerdeathcorps> though...to be honest, FFI was atrocious
<formerdeathcorps> it's gotten better over time
<Aero[homework]> okay, so then you confused what I was referring to
<Aero[homework]> I am not talking about BoF3
<formerdeathcorps> maybe I did get confused
<formerdeathcorps> what were you trying to say?
<Aero[homework]> why hasn't someone done some major changes to FFT outside of small patches?
<Aero[homework]> optimizations, restructuring, stuff like that?
<formerdeathcorps> have you written code before?
<Aero[homework]> same answer, eh?
<formerdeathcorps> My point is that
<formerdeathcorps> if you have
<formerdeathcorps> you'd know that in any High LEvel Language
<formerdeathcorps> the logic of whatever you write
<formerdeathcorps> usually takes up a few KB at most
<formerdeathcorps> after weeks of work
<formerdeathcorps> the rest is simply filler space
<formerdeathcorps> now...BATTLE.BIN is 1.5 MB
<Aero[homework]> ah
<formerdeathcorps> or something close to that
<Aero[homework]> it's hard to find routines, yes?
<formerdeathcorps> no.
<formerdeathcorps> rather...
<formerdeathcorps> imagine if we had to replace 20 KB
<formerdeathcorps> of routines
<formerdeathcorps> entirely customly
<formerdeathcorps> that's the equivalent of doing this as a full time job for about 4 months
<formerdeathcorps> and because of the support structure
<Aero[homework]> i can't imagine it taking that long for someone as talented as you
<Aero[homework]> o_O
<formerdeathcorps> your custom stuff has to "fit"
<formerdeathcorps> within the rest of it.
<formerdeathcorps> you know...let's say I wanted to expand the item table to 512 items
<Aero[homework]> if it were written in an even higher level like c++
<formerdeathcorps> to do that reuiqres changing every single instance that reads items
<Aero[homework]> and you could see the miles of data structures and stuff
<formerdeathcorps> to halfword
<formerdeathcorps> correct, Aero
<formerdeathcorps> but there's one thing...doing that
<Aero[homework]> I still can't imagine taking more than 2 months to do a full overhaul of one aspect
<formerdeathcorps> *we can't increase file-size AEro
<Aero[homework]> oh
<Aero[homework]> you know, that could have been the first thing you said
<Aero[homework]> I'd understand that
<Aero[homework]> same issue with hacking sonic games
*** Aero[homework] is now known as Aero
<Aero> in any case, i'm finishing homework tomorrow
<secondadvent> there's also testing/planning/rewriting of your own code
<secondadvent> sometimes a single mistake can require a ton of changes that could set you back a ways
<secondadvent> and then there's occasionally times when you can't figure out why something isn't working correctly, which requires time to debug/change code to fix it
<Aero> well, i do that all the time with my fangame
<formerdeathcorps> because the RAM is 2 MB
<formerdeathcorps> and because we don't know ROM expansion
<formerdeathcorps> seeing miles of data structures is fine...we already do...but fixing them requires you do fix all the cross-references...something that's much harder to do in ASM than with a nice comipler pointing out the entire run cycle for you
<formerdeathcorps> *fixing them entirely as you want
<formerdeathcorps> and much of the cross-reference "linker" routines are uncharted territory because they're not as much the "meat" as the code that actually determines damage and stuff
<formerdeathcorps> but if you want to change the data strucutres, you need to fix those too
<formerdeathcorps> The problem is also...if you tried reverse transcribing FFT into C
<formerdeathcorps> you'll also get stuff that will be marked poorly or left out with ???
<formerdeathcorps> exactly, the trials of a coder
<formerdeathcorps> Pokeytax wrote close to 2 KB of code
<formerdeathcorps> and a 10 KB data structure
<Aero> whoa, wtf?
<formerdeathcorps> ...it took him 4 months?
<Aero> my internet must have hiccuped
<formerdeathcorps> and seriously...it wore him out
*** -NickServ- This nickname is registered. Please choose a different nickname, or identify via /msg NickServ identify <password>.
<Aero> hold on
<formerdeathcorps> and is bugged like crazy
*** -to NickServ-: r@gingst0rm
*** -NickServ- Invalid command. Use /msg NickServ help for a command listing.
<formerdeathcorps> sorry
*** -to NickServ-: identify r@gingst0rm
*** -NickServ- You are now identified for Aero.
<formerdeathcorps> all right
<formerdeathcorps> ready, AEro?
<Aero> hold on, just reread what my dumb internet had backlogged somehow
<Aero> at least, I think it was me
<formerdeathcorps> I read it.
<Aero> <Aero> well, i do that all the time with my fangame
<Aero> whos post was directly before this one?
<formerdeathcorps> oh, must have missed that one
<Aero> *message
<Aero> ^
<secondadvent> my internet seemed to hiccup as well
<Aero> it might be fdc, or the server
<Aero> or something
<Aero> anyways, i was responding to 2nd
<Aero> but it doesn't matter
<Aero> that longass explanation fdc gave convinced me
<Aero> I guess I'm ready
<formerdeathcorps> all right
<formerdeathcorps> we left off yesterday at mult
<formerdeathcorps> I think you got the hang of how to create fractions
<Aero> yes
<formerdeathcorps> just as a quick exercise
<formerdeathcorps> how would you do 30%?
<Aero> it's wierd that square would do it that way, but I guess it's so they can still have numeric values up to 4294967295
<Aero> as for your question
<formerdeathcorps> right.
<Aero> 3 * 5555 5556
<Aero> although it wouldn't really be 30%
<formerdeathcorps> it's not
<Aero> it's be more like 33.3333333%
<Aero> *it'd
<formerdeathcorps> in short...we did the unit fraction case last night
<formerdeathcorps> if we were to do non-unit fractions, how would you proceed?
<Aero> what would be different about it?
<formerdeathcorps> well...go through the process and you tell me
<Aero> hmm
<Aero> 30% is 3/10
<formerdeathcorps> right
<Aero> so it'd be 3 * 1/10
<formerdeathcorps> ok
<Aero> which is 3 * 1000 0000
<Aero> erm... hmmm
<Aero> derp
<Aero> 3 * 1999999A
<Aero> ... still no
<Aero> fuck
<formerdeathcorps> hint...
<formerdeathcorps> take FFFFFFFF as a decimal
<formerdeathcorps> multiply by 3/10
<formerdeathcorps> and then round up
<Aero> oh
<Aero> i keep just dividing by 10
<Aero> or rather A
<Aero> for 1/10
<formerdeathcorps> right
<secondadvent> i usually go 0x100000000 instead of FFFFFFFF
<Aero> but then just multiplying by 3 wouldn't teh same
<Aero> *wouldn't be the same
<Aero> would it?
<Aero> or would my answer just be incomplete
<Aero> duh, of course it would
<Aero> 3 * 1999999A
<formerdeathcorps> you divide last
<Aero> ... oh
<formerdeathcorps> so you do 3 * FFFF FFFF first
<formerdeathcorps> and then divide
<formerdeathcorps> and add 1
<Aero> 4CCCCCCD
<formerdeathcorps> do you see why?
<Aero> what, but...
<formerdeathcorps> you do this rather than the opposite?
<Aero> the way I did it before was just as good an answer
<formerdeathcorps> except there's one problem...
<formerdeathcorps> the +1 part?
<Aero> it isn't closest to the factional equivalent?
<formerdeathcorps> was to estimate right?
<formerdeathcorps> a roundoff error
<Aero> oh
<formerdeathcorps> you also want to make that roundoff error last
<formerdeathcorps> in any list of calculations
<Aero> can't round off until after all is said and done
<formerdeathcorps> to limit total error
<formerdeathcorps> right
<Aero> hold on
<formerdeathcorps> FFFF FFFF / A
<Aero> 19999999
<formerdeathcorps> you add 1
<formerdeathcorps> to get 1/10
<Aero> 1999 999A
<formerdeathcorps> but that leaves a roundoff error there
<formerdeathcorps> which you then amplify by multiplication
<Aero> =/
<secondadvent> what i usually do is use wincalc in scientific mode, enter the decimal value i want, * 0x100000000 and get the value i want (still need to round though)

<formerdeathcorps> now...let's see some examples from Square
<formerdeathcorps> The DEFUP code
<formerdeathcorps> is * 2/3 right?
<Aero> that'd be [(FFFF FFFF * 2)/3]+1
<Aero> which is AAAAAAAB
<formerdeathcorps> you would think so
<formerdeathcorps> Square, however
<formerdeathcorps> does not do that
<formerdeathcorps> they split the steps up
<Aero> -_-;
<formerdeathcorps> 1) XA * 2
<formerdeathcorps> then divide by 3
<secondadvent> they do * 1/3 then sll 0x1 right?
<formerdeathcorps> do they, SA?
<secondadvent> i forget
<secondadvent>

<formerdeathcorps> that's even worse, that leaves round off errors
<formerdeathcorps> point is...Square is inefficient
<secondadvent> i'm working on no sleep here
<formerdeathcorps> Aero, want to guess the reason why they don't do that?
<Aero> well, i don't expect them to process the whole calculation in one line
<Aero> ASM can't do that
<formerdeathcorps> ASM can
<formerdeathcorps> simply type in AAAA AAAB
<secondadvent> yep
<Aero> ... oh
<formerdeathcorps> and have your compiler figure out properly how to do fractions
<Aero> derp, forgot that's how it's used
<formerdeathcorps> but guess why Square didn't
<formerdeathcorps> (hint...remember the discussion we had yesterday about signed numbers)
<Aero> okay... why doesn't square do it that way?
<Aero> oh
<Aero> is the damage signed?
<Aero> due to absorb?
<formerdeathcorps> yeah
<Aero> ah
<formerdeathcorps> there's two forms of sign
<formerdeathcorps> *mult
<formerdeathcorps> rather
<formerdeathcorps> mult and multu
<formerdeathcorps> signed and unsigned
<formerdeathcorps> as a practice, to stop stupidity, always use multu
<formerdeathcorps> just so you can express all fractions
<Aero> k
<formerdeathcorps> there is another way...slightly less precise
<formerdeathcorps> but it's the way SA and I use
<formerdeathcorps> we simply multiply by a byte
<formerdeathcorps> and divide by 128
<secondadvent> oh derp, i had the order reversed
<secondadvent> i need sleep
<formerdeathcorps> (i.e. srl 0x07)
<formerdeathcorps> Square never does this
<formerdeathcorps> but you'll see this in my code and SA's
<Aero> ic
<formerdeathcorps> in that system
<formerdeathcorps> 56 is 1/3
<formerdeathcorps> 34 is 1/5
<formerdeathcorps> err...no
<Aero> ;p;
<Aero> *lol
<formerdeathcorps> 2B is 1/3
<formerdeathcorps> anyways...the advantages here
<formerdeathcorps> is that you only need to multiply by one byte
<formerdeathcorps> so you can just extract your number from lo
<formerdeathcorps> and that you can use small numbers (faster operations when you do the srl)
<Aero> cool
<formerdeathcorps> also...you can express all multipliers
<formerdeathcorps> from 0 to 2
<Aero> how'd you determine the bytes?
<Aero> FF / 128?
<formerdeathcorps> the same way as you did before, Aero
<formerdeathcorps> no
<formerdeathcorps> 7F * MULT + 1
<Aero> where MULT is?
<formerdeathcorps> your desired multiplier
<formerdeathcorps> between 0 and 2
<formerdeathcorps> obviously, if your multiplier is 0
<formerdeathcorps> just clear out your variable
<formerdeathcorps> and if it's a power of two, use the shift right / left logicals
<Aero> okay, i'm getting like damned now, though
<formerdeathcorps> sorry
<Aero> why only between 0 and 2
<Aero> *?
<Aero> show me an example
<Aero> show me how you got 2B
<formerdeathcorps> 7F * 1/3 + 1
<formerdeathcorps> 7F * 1/3 = 2A
<formerdeathcorps> +1 is 2B
<Aero> oh
<formerdeathcorps> why is it only between 0 and 2?
<Aero> you cut the fraction down to 7 bytes?
<formerdeathcorps> yeah
<Aero> interesting
<formerdeathcorps> this is just a simple way of doing fractions by bytes
<formerdeathcorps> that way people don't need to remember large numbers
<formerdeathcorps> obviously, if you have large denominators like 100, you don't have a choice
<Aero> OH DERP
<Aero> i got confused again, but I figured it out
<Aero> instead of FFFF FFFF, you used 7F
<formerdeathcorps> but for small fractions, this approximation holds for all values up to around 60 or so
<formerdeathcorps> right
<Aero> now I wonder how I got the wrong numbers before
<Aero> what was I thinking?
<Aero> o_O
<formerdeathcorps> do you see why the multipliers are between 0 and 2?
<Aero> yes
<formerdeathcorps> ok
<formerdeathcorps> now...
<formerdeathcorps> Square, sadly, is not this smart
<Aero> there aren't enough bytes to properly represent fractions larger than 2
<formerdeathcorps> correct, Aero
<formerdeathcorps> just like base 10 can't represent anything not a power of 2 or 5
<formerdeathcorps> SA, care to explain how Square does percents?
<Aero> I wouldn't blanket term them
<Aero> we have interviews and such, don't we
<Aero> it was a very poor, very specific team
<formerdeathcorps> ok, sure
<Aero> that is probably no longer working there
<formerdeathcorps> SA, can you explain how FFT coded percents?
<Aero> lol
<formerdeathcorps> just to give a comparison?
<formerdeathcorps> all right... I will
<formerdeathcorps> FFT does percents
<secondadvent> you go ahead, i'm ready to pass out. i'll try to be more helpful tomorrow

<formerdeathcorps> by dividing by 1/320 or something like that
<Aero> o_O
<formerdeathcorps> and then multiplies by 2^5
<formerdeathcorps> and divides by 10
<formerdeathcorps> it's awful
<Pride> lol
<Aero> so... they round it to 1/100th then they scale back up?
<formerdeathcorps> yeah
<Aero> >_<
<formerdeathcorps> The reason why Square does this?
<formerdeathcorps> Speed
<formerdeathcorps> sll / srl
<formerdeathcorps> are the fastest operations
<formerdeathcorps> mind you...this wastes space
<formerdeathcorps> ...and that's what matters most to us
<Aero> so you took a trade-off - ease of user for slight speed disadvantage?
<formerdeathcorps> Aero, since most of us use emulators
<formerdeathcorps> on machines far stronger than the PSX
<formerdeathcorps> That's hardly an issue since the same thing would run on the real machine
<formerdeathcorps> just a few microseconds slower
<Aero> yeah, I get you
<Aero> Knowing that they did it for speed, though
<Aero> I wouldn't blame 'em
<formerdeathcorps> back to your earlier question yesterday
<Aero> They still ended up with slowdown, but they tried
<Aero> =/
<formerdeathcorps> why don't we just multiply and divide
<formerdeathcorps> divide exists also as a FFT function
<formerdeathcorps> but there's two things to know immediately
<formerdeathcorps> DIV / DIVU
<formerdeathcorps> is a very costly operation
<formerdeathcorps> it is twice as costly as multiplication
<formerdeathcorps> and if you think about why...it makes sense
<Aero> of course
* Pride didn't know that
<Aero> division operators are always more costly
<formerdeathcorps> to be able to divide you need to be able to multiply
<Aero> apparently
<formerdeathcorps> and subtract
<Aero> it's simpler to multiply by a fraction than directly divide an integer.
<formerdeathcorps> correct
<Aero> for some reason
<formerdeathcorps> which is why Square does what it does
<formerdeathcorps> in MIPS
<formerdeathcorps> the reason is simple
<formerdeathcorps> everything is an int
<formerdeathcorps> floating point does not exist
<Aero> ah
<formerdeathcorps> video game systems tend to have fast integer based engines
<Aero> so extra processor time is spent rounding off the excess
<formerdeathcorps> most consoles have floating point
<formerdeathcorps> exactly
<Aero> that makes sense
<formerdeathcorps> *most PCs I mean
<formerdeathcorps> *most consoles have the integer engines
<formerdeathcorps> anyways...
<formerdeathcorps> the only time square uses divide
<formerdeathcorps> is usually when the number they are dividing by
<formerdeathcorps> is variable
<formerdeathcorps> and not constant
<Aero> so they can't readily conver it
<Aero> *convert
<formerdeathcorps> right
<formerdeathcorps> which is why your computer must be stronger a processor than the console
<formerdeathcorps> which is also why emulating the PS2 is so hard
<formerdeathcorps> it uses SO much resources
<formerdeathcorps> because we need to remember that just based on processor speed, for when it was released, the PS2 was several years ahead of its field
<formerdeathcorps> anyhow...this is a serious digression
<formerdeathcorps> you just need to remember that div
<formerdeathcorps> stores the result in hi
<formerdeathcorps> and the remainder in lo
<Aero> k
<formerdeathcorps> the only thing is...the remainder is virtually never used in FFT
<formerdeathcorps> even though I found it quite useful...mathematically
<Aero> because they round EVERYTHING
<formerdeathcorps> well, no
<formerdeathcorps> let's say you want to calculate patterns in the Zodiac
<formerdeathcorps> the easy way is to use modular divison
<formerdeathcorps> the stupid way is to waste space the way Square did
<Pride> lol
<formerdeathcorps> ...making separate flags for when units had opposite alignment and stuff
<Aero> can't even stay consistent with their own design ethic
<Aero> dur, zodiac patterns are good place to break our edict on saving processor speed hur!
<formerdeathcorps> the result is their routine is longer
<formerdeathcorps> and actually just as bad
<Aero> actually, i should ask this
<formerdeathcorps> mm?
<Aero> why does the filesize need to be maintained?
<formerdeathcorps> you can't make the file larger
<secondadvent> their way FFT usually does it is -> base - (base / X * X)
<formerdeathcorps> because each file is given a fixed number of disk sectors
<formerdeathcorps> and after each file is the next one
<formerdeathcorps> on the disk
<Aero> oh
<formerdeathcorps> thus, if you made one file larger
<Aero> that can't be adjusted?
<formerdeathcorps> you'll have to edit every other file
<secondadvent> i can increase filesize in BoF3 though
<Aero> or is it just too costly
<formerdeathcorps> *not easily, Aero
<Aero> okay
<formerdeathcorps> also...you have to adjust it in RAM
<Aero> just curious
<secondadvent> since it has a neat little LBA table
<formerdeathcorps> and that's the really nasty part
<formerdeathcorps> because if I made BATTLE.BIN larger
<formerdeathcorps> I'd have to make another file smaller
<secondadvent> and has a file header for how large the subfiles are, and where to load in RAM
<formerdeathcorps> and adjust every single pointer to that second file
<Aero> what a hassle
<formerdeathcorps> exactly
<formerdeathcorps> which is why I'd prefer not to think about it
<Pride> A shame really
<formerdeathcorps> now...onwards to OPCODES
<secondadvent> nop
<Pride>

* secondadvent losing powe...
<formerdeathcorps> these make up the basic instructions of MIPS
<formerdeathcorps> I've already introduced you to some, Aero
<formerdeathcorps> shifts
<formerdeathcorps> adds
<formerdeathcorps> subtracts
<formerdeathcorps> you probably should remember these
<formerdeathcorps> as an example
<formerdeathcorps> add r1, r2, r3
<formerdeathcorps> what does this mean?
<formerdeathcorps> it takes r2 and r3
<formerdeathcorps> the values in them
<formerdeathcorps> adds them
<formerdeathcorps> and puts the result in r1
<formerdeathcorps> in general, when you read opcodes
<formerdeathcorps> the first register given
<Aero> so if you just wanted one or the other, it'd be
<Aero> add r1, r2?
<formerdeathcorps> is always the one whose value gets replaced
<Aero> or addi, r1, r2, 0?
<formerdeathcorps> right
<formerdeathcorps> except since MIPS is 32-bit
<Aero> ... erm, which one
<formerdeathcorps> you always have 3 arguments
<Aero> oh
<Aero> k
<formerdeathcorps> the first one is always the value that gets replaced
<Aero> i do remember argument order
<Aero> from my class
<formerdeathcorps> right.
<formerdeathcorps> just know that since 32-bit commands
<formerdeathcorps> have 3 arguments
<formerdeathcorps> the first one has no place
<formerdeathcorps> in the calculation itself
<Aero> k
<Aero> argument1 is the destination
<formerdeathcorps> right
<Aero> argument2 is formula argument 1
<formerdeathcorps> hence known as the rd
<formerdeathcorps> rs
<Aero> argument3 is formula argument2
<formerdeathcorps> right
<formerdeathcorps> but argument 3 is sometimes a constant
<Aero> right
<formerdeathcorps> (all constants in MIPS are halfwords
<formerdeathcorps> i.e. 2 bytes
<Aero> so they can't be larger than FF FF?
<formerdeathcorps> right
<Aero> i guess 65536 is sufficiently large
<formerdeathcorps> also...one thing to note
<Aero> *6553
<Aero> *5
<formerdeathcorps> all constants are signed
<Aero> ugh
<Aero> so it's not even that
<formerdeathcorps> except for logic commands
<formerdeathcorps> like and / xor
<formerdeathcorps> err...
<formerdeathcorps> andi / xori / ori
<Aero> it's {-255, 255}
<Aero> lame
<formerdeathcorps> no
<formerdeathcorps> more like (-2^15, 2^15)
<formerdeathcorps> a very large space
<formerdeathcorps> now...let's refer to my list
<Aero> {-32768, 32768}
<formerdeathcorps> (Link:
http://ffhacktics.com/smf/index.php?topic=6728.0)http://ffhacktics.com/smf/index.php?topic=6728.0<Aero> onto your list
<Aero> ah
<Aero> okay, so now you guy's code snippets make sense
<Aero> first 2 bytes is the opcode
<Aero> all others are arguments
<Aero> right?
<formerdeathcorps> right
<Aero> so I just gotta memorize the op codes
<Aero> hmmm
<formerdeathcorps> back in the old days...yes
<formerdeathcorps> you did
<formerdeathcorps> now we have massHex
<Aero> oh
<formerdeathcorps> and you just need to be able to write opcodes
<formerdeathcorps> symbolically
<Aero> ah
<secondadvent> i still do it in a hex editor though
<formerdeathcorps> correct
<formerdeathcorps> because of that
<formerdeathcorps> it is still advised you memorize opcodes
<Aero> the snippets are just how your compiler exports the high level language
<Pride> I'm surprised you don't have Jump Register on that list
<Aero> figures
<formerdeathcorps> I don't?
<Aero> he doesn't?
<formerdeathcorps> yes I do
<Pride> Oh I see it
<Pride> nvm
<formerdeathcorps> it's under R commands
<Pride> Yeah I was just looking under the jump commands
<Aero> in my class, we use visual studio to write ASM
<Aero> so we didn't have to remember the opcodes in hex
<Aero> just the shorthands
<Aero> so I know some of them
<formerdeathcorps> Aero, to know the opcodes you have to deconstruct the commands in binary
<Aero> but not the IDs
<formerdeathcorps> let's give an example
<formerdeathcorps> add r1, r2, r3
<formerdeathcorps> the first is add
<Aero> oh dur
<formerdeathcorps> 100 000
<formerdeathcorps> or 1000 00
<formerdeathcorps> err...wait
<Aero> wait, no
<formerdeathcorps> 10 0000
<Aero> hmmm
<formerdeathcorps> notice that is hex for 20
<Aero> where'd you get that number?
<formerdeathcorps> the first four zeroes
<formerdeathcorps> form the 0 byte
<formerdeathcorps> *0 hex digit
<Aero> no
<Aero> not the 20
<Aero> the binary
<formerdeathcorps> right
<formerdeathcorps> 10 0000 = 0010 0000
<formerdeathcorps> the first hex digit is 0
<formerdeathcorps> 0010 is 2
<formerdeathcorps> right?
<Aero> ...
<Aero> NO
<Aero> not the 20
<formerdeathcorps> what?
<Aero> where'd you get 0010 0000
<Aero> *?
<formerdeathcorps> look at the tutorial
<Aero> they're predefined, then?
<formerdeathcorps> the opcode for ADD is 10 0000
<formerdeathcorps> yeah
<Aero> why'd you say: <formerdeathcorps> Aero, to know the opcodes you have to deconstruct the commands in binary
<formerdeathcorps> because 20 = 10 0000 in binary?
<Aero> <Aero> in my class, we use visual studio to write ASM <Aero> so we didn't have to remember the opcodes in hex <Aero> just the shorthands <Aero> so I know some of them
<formerdeathcorps> right.
<Aero> semantics: you were complaining that I said that i didn't need to know them in hex, but they're in binary first
<Aero> semantics
<Aero> you know what I meant. >_<
<formerdeathcorps> you don't need to know them in hex, because we have the tools to ignore this
<formerdeathcorps> but if you want to know it
<Aero> ....
<formerdeathcorps> you need to be able to use binary to decompose stuff
<Aero> seems you didn't know what I meant
<Aero> my point was, i didn't need to know the opcodes
<Aero> before
<Aero> nothing more
<Aero> semantics
<formerdeathcorps> oh, right
<formerdeathcorps> ok...are we cool now?
<Aero> yes
<formerdeathcorps> in the example add r1, r2, r3
<formerdeathcorps> add has opcode of 10 0000
<formerdeathcorps> or 20
<formerdeathcorps> this means
<formerdeathcorps> you have byte 1 as 20
<formerdeathcorps> now...the r1 would be 08
<formerdeathcorps> r2 would be 10
<formerdeathcorps> and so on...
<Aero> already understood that
<formerdeathcorps> so you have 20 0 8
<formerdeathcorps> *20 08
<formerdeathcorps> next is the other two registers
<formerdeathcorps> r2 / r3
<formerdeathcorps> you double the value
<formerdeathcorps> of r2
<formerdeathcorps> so it is 4
<formerdeathcorps> you leave 3 alone
<formerdeathcorps> so you have 3
<formerdeathcorps> On all R-commands
<formerdeathcorps> *i.e. those that use 3 registers
<formerdeathcorps> the last command is always 00
<formerdeathcorps> *byte
<Aero> k
<formerdeathcorps> not really though...
<formerdeathcorps> using the formulas given
<formerdeathcorps> try....
<formerdeathcorps> writing
<formerdeathcorps> add r15, r6, r26
<formerdeathcorps> Still here?
<Aero> yes
<Aero> okay, um...
<Aero> 20 1E 06 00?
<formerdeathcorps> no
<formerdeathcorps> hing
<formerdeathcorps> what is r15?
<Aero> what IS r15?
<Aero> is it a constant
<Aero> *?
<formerdeathcorps> no
<formerdeathcorps> it's a register
<formerdeathcorps> and it fits in byte 2
<Aero> okay
<Aero> you never said what was in it
<Aero> or any of them
<formerdeathcorps> oh right...
<formerdeathcorps> anything with r before it
<formerdeathcorps> designates a register
<Aero> i know
<Aero> oh derp
<Aero> no wait
<Aero> question
<Aero> why'd you double r2 before?
<formerdeathcorps> because it's the register in the second position
<formerdeathcorps> you always doulbe that one and place it in the first hex digit of byte 3
<Aero> is 15 * 2 1E or 2A?
<formerdeathcorps> carrying over what you must
<formerdeathcorps> except that's the first register
<formerdeathcorps> which means you multiply by 8
<Aero> wait
<Aero> i didn't see that part
<Aero> o_O
<Aero> i must have nodded "yes" to the wrong thing
<Aero> oy vay
<Aero> okay, i see it now
<Aero> first register is multiplied by 8
<Aero> 2nd by 4
<Aero> third by 2
<Aero> okay
<formerdeathcorps> no
<formerdeathcorps> 2nd by 2
<formerdeathcorps> 3rd not at all
<Aero> okay
<formerdeathcorps> and anything that requires you to carry over digits, you do so
<formerdeathcorps> into the next digit
<Aero> 20 78 0C 1A
<formerdeathcorps> almost
<formerdeathcorps> the second and third registers share the same byte
<Aero> 20 78 C1 A0?
<formerdeathcorps> no
<formerdeathcorps> you carry over into the second byte
<formerdeathcorps> i.e.
<formerdeathcorps> C0 + 1A
<formerdeathcorps> *second digit
<Aero> i don't get it
<formerdeathcorps> think of the second register as the "tens place"
<formerdeathcorps> and the third register as the "ones"
<Aero> why is it done that way?
<formerdeathcorps> becuase they all occupy distinct binary digits
<formerdeathcorps> register 2 occupies the next 5 after the opcode
<Aero> but why don't they just occup 2 bytes each?
<Aero> *occupy
<formerdeathcorps> but we only have 32 registers
<formerdeathcorps> so we only need 5 bits
<formerdeathcorps> for each register
<formerdeathcorps> saving space in the opcode so we can address more command types
<Aero> but you're left with extra space anyways
<formerdeathcorps> right
<formerdeathcorps> but that lets you make more MIPS commands
<formerdeathcorps> in later MIPS versions
<Aero> oh
<Aero> =/
<Aero> okay
<Aero> wierd way to do it
<Aero> so it's 20 78 C0 1A
<formerdeathcorps> no
<formerdeathcorps> remember I said the second and third registers
<formerdeathcorps> share the third byte
<formerdeathcorps> so you have C0 + 1A = DA
<Aero> hmm
<Aero> oh
<Aero> 20 78 DA 00
<formerdeathcorps> if these seems confusing, imagine stacking groups of 5 bits next to each other
<Aero> that's... awkward to work with
<formerdeathcorps> the opcode is 6 bits
<formerdeathcorps> 10 0000
<Aero> you'd have to look at the binary
<Aero> or at least, I'd have to
<formerdeathcorps> Yeah
<formerdeathcorps> that's why this system is cumbersome
<formerdeathcorps> but notice
<formerdeathcorps> the next two bytes
<Aero> so it's not even a full word, it's just 10 bits
<formerdeathcorps> right
<Aero> =/
<Aero> well, not 10
<formerdeathcorps> 0000 0 | 000 00 | 00 000 UNUSED
<Aero> 24
<Aero> ugh
<formerdeathcorps> I'm not done with complexity
<formerdeathcorps> when you read the HEX
<formerdeathcorps> it's all backwards
<formerdeathcorps> so you actually read 00 DA 78 20
<formerdeathcorps> in the hex editor
<Aero> little endian
<formerdeathcorps> right
<Aero> like the guide says
<formerdeathcorps> but only each command is little endian
<formerdeathcorps> the commands read in forward order
<Aero> right
<formerdeathcorps> ok...just so you know and aren't going to pull a Damned moment on me
<formerdeathcorps> is there any command you don't get?
<formerdeathcorps> that I wrote??
<Aero> such as?
<formerdeathcorps> as in...do you understand all the symbolic three letter commands? I wrote
<formerdeathcorps> what they do?
<Aero> let me see
<formerdeathcorps> as well as the overall types of commands
<formerdeathcorps> I / R / J
<Aero> i - immediate
<Aero> r - register
<Aero> j - jump/
<Aero> *?
<formerdeathcorps> right
<formerdeathcorps> do you understand the difference, opcode wise?
<formerdeathcorps> and function wise?
<Aero> immediate handles constants
<Aero> register handles registers
<Aero> jump moves to a specified point in code
<formerdeathcorps> right
<Aero> yeah, as long as I know the shorthands, i'm good
<Aero> it becomes... something close to traditional programming
*** Chotokukyan has joined #ffhs
<Aero> and I worked with this in my class when i had it
<formerdeathcorps> ok, good
<Aero> i actually have a working maze game
<formerdeathcorps> Choto, we're doing review over opcodes
<Aero> too bad I wouldn't be able to tell you how the hell I pulled that off
<formerdeathcorps> (Link:
http://ffhacktics.com/smf/index.php?topic=6728.0)http://ffhacktics.com/smf/index.php?topic=6728.0<Aero> hold on, i'll grab it and upload it so you can lol at it
<Chotokukyan> ah k
<Aero> I wonder if it's even compatible with your comp
<formerdeathcorps> OK...Aero, if you're good with this
<formerdeathcorps> we're going to talk about...load delay
<Aero> (Link:
http://64digits.com/users/AeroGP/asm_maze.rar)http://64digits.com/users/AeroGP/asm_maze.rar<Aero> k
<formerdeathcorps> Choto, you probably should stay here
<Aero> you won't be able to compile it, but an executable is available
<Aero> and the code is readable
<formerdeathcorps> all right.
<formerdeathcorps> let's finish up
<Aero> k
<formerdeathcorps> Load Delay
<formerdeathcorps> this is important
<formerdeathcorps> and one of my first assignements to all of you
<formerdeathcorps> would be to fix Pokeytax and Xif's work
<formerdeathcorps> namely, here's the problem
<formerdeathcorps> every branch and jump command
<formerdeathcorps> will execute the command after it
<formerdeathcorps> before it jumps
<formerdeathcorps> this is not true in EVERY assembly language
<formerdeathcorps> it's actually particular only to early versions of MIPS
<formerdeathcorps> what this means, though
<formerdeathcorps> is that we can do stuff like
<formerdeathcorps> addu STUFF
<formerdeathcorps> jump
<Aero> that sounds easy enough - you just move the last command down into the branch as if the branch starts after it
<formerdeathcorps> right
<formerdeathcorps> there's only one thing
<formerdeathcorps> there's also what is known as a pipeline hazard
<formerdeathcorps> this occurs first because each MIPS command has 4 stages
<formerdeathcorps> and while the first command runs, the second command starts
<formerdeathcorps> this can lead to paradoxes of time
<formerdeathcorps> this is called a pipeline hazard
<formerdeathcorps> MIPS can catch some of the more obvious ones
<Aero> so commands are semi-threaded?
<formerdeathcorps> but not all of them
<formerdeathcorps> *yes, Aero
<Aero> interesting
<formerdeathcorps> they're threaded 4 deep
<formerdeathcorps> *no more than
<Aero> i can see how that'd result in paradoxes
<formerdeathcorps> to avoid this
<formerdeathcorps> the rules are as thus
<formerdeathcorps> if you load a variable
<formerdeathcorps> *load a value into a register
<formerdeathcorps> you can't use it immediately after
<Aero> because it isn't executed right away
<formerdeathcorps> correct
<Aero> got it
<formerdeathcorps> another thing
<formerdeathcorps> if you use mult or div
<formerdeathcorps> and then mfhi mflo
<formerdeathcorps> you can't use mult or div again for the next two commands after the mfhi / mflo
<formerdeathcorps> or you'll mess up the values of hi and lo
<Aero> because it takes 2 steps to release hi and lo?
<formerdeathcorps> correct
<formerdeathcorps> mult and div take longer
<formerdeathcorps> than other commands
<Aero> right
<formerdeathcorps> also...one more thing...
<formerdeathcorps> you can't store a register's value into a location
<formerdeathcorps> and then load that location right after
<formerdeathcorps> ...it's the inverse of loading
<formerdeathcorps> but it's the same kind of problem
<formerdeathcorps> as you can imagine
<Aero> ic
<formerdeathcorps> this can get tricky if you do stuff like
<formerdeathcorps> addiu r3, r0, 0x00C0
<formerdeathcorps> jal PLACE
<formerdeathcorps> lbu r2, PLACE (r1)
<formerdeathcorps> *PLACE2
<Aero> so in general, ram manipulation takes a step to finalize, so don't do anything funny with addresses right after you've modified them
<formerdeathcorps> Right
<formerdeathcorps> just remember that if you jump
<formerdeathcorps> this is also possible
<Aero> okay
<formerdeathcorps> because you execute that lbu right before the first step
<formerdeathcorps> so you probably shouldn't use r2
<Aero> k