Post Reply 
Assembly code [boring blog post]
Author Message
Tetris999
..............................

Posts: 2,390.4622
Threads: 298
Joined: 15th Apr 2007
Reputation: -6.7936
E-Pigs: 82.5657
Offline
Post: #1
Assembly code [boring blog post]
Yeah, I've been trying to get into this. Unfortunately I haven't been able to find the correct approach to assembly programming. I've been looking into arm (since that's what the vita is programmed on) but the book I've got my hands on seems to be geared towards people who already KNOW what assembly is about. Ugh. As such, all this searching has been making me slack behind in my duties to school, but oh well.

Speaking of school, been getting through midterm month where wee're all swamped with the things. Personally, I just had my computer science one and blew it (was tired as spoon since the midterm was scheduled at 7:00pm and I have to get up at 5:00am, it was an easy midterm too, but to be honest, getting a good mark on it does not say anything about coding ability. Or any ability for that matter.

Also, fudge linear algebra, subspaces and spoon. double you tee eff is that? And when you move into "prove that this is an invertible matrix or other spoon", this stuff becomes messy as fudge. I'm falling behind because I don't bother going to lecture any more (the guy reads out the textbook, go figure).

I also talked to my statistics prof and found out, well, I'm doing an APPLIED statistics course, which means, it's fun! Can't say that about all statistics though and I bet many aspects of the science/whatever is pretty boring, bummer.

On the bright side of things, found out my stats prof was a total gadget bro, what was even more interesting is that he had a psvita. Being an assembly programmer himself, I talked about how to approach assembly programming and he told me to pick up any random book and said that you didn't REALLY need to know C/Java whatever to actually understand what was going on (but knowing would help you).

What was really funny is that he even offered to let me fiddle around with the vita in office hours. My opinions of it is that it's a LOT lighter than it looks, but also that when you play around with it for about 30 minutes, you start to get tired of it very quickly. It's a nice piece of kit, but I totally lost interest in 30 minutes, this thing needs games badly. I did this all the while some random girl was watching the prof and I talk about games and what not while she was trying to get help for one of the assignments. Her face was priceless.

Also my computer science prof is a douche, tried to get along with the guy and he does NOT like his students, funny how a stats prof appeals more than someone in my faculty. Actually, that's a big statement about how big of a joke my faculty is.

Bottom line is, I'm not doing well at all in school, but that really doesn't matter to me personally when I have a goal. School and what not is never something that says something about your achievements, if you want a job or someone to admire what you've done, don't look for school as an outlet for this. Do what interests you, get that spoon done and people will take notice. Well, at least for computer science, I'd say for something like statistics, you may want to do well in school for that because...well, that's all you'll ever be able to have to show for THAT field. :P

Fuck the haters, have some fun.

Also, where's da beguineer tootorials for assemblah programmin'? (Imma 13-yearold trying to be coo!)

 Shame on me, I haven't been able to get back into web development because of my school workload, sorry I'm not using the site yet jooms 


P.S. Forgot to whine about this, but my partner in my android program project is a useless and lazy douche that's in computer science "for the monayz" (he's an arts student, probably one of the kids who apply to UBC just to get in and then find out that there's reasons for application requirements and goes into computer science because "its the only thing worthwhile in arts", not hating on arts students, but arts students like THESE are scum).

Basically I'm doing the project on my own and I don't know how to approach this situation, I'm not a douchey guy (BETA AS FUCK) so I don't know what else I should do. Ratting him out would make me feel bad, but this guy cheats and copies work like no tomorrow.

Fuck.

MY SIG IS FUCKING DEAD
(This post was last modified: 08/03/2012 06:05 PM by Tetris999.)
08/03/2012 05:57 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,022.2988
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.1294
Offline
Post: #2
RE: Assembly code [boring blog post]
If you know programming, then it would make assembly easier.  It's a very basic language - you probably don't need much of a tutorial on it.
Basically, it's just "opcode operand" syntax most of the time, eg

Code:
1
2
3
4
5
6
add a, b
subtract a, b
compare c, d
jump_if_greater_than to_some_place

some_place:

You pretty much just need an overview on the processor architecture and the various opcodes.
Whilst this gives you a founding in the language, actually programming anything is a different matter.  Then again, you rarely need to program anything significant in assembly these days.

If you come from a higher level language, think of it as a really dumbed down simple, but highly verbose, language.
If you prefer a bottom-up approach, just think of an opcode as selecting a logic circuit from the ALU, and operands as feeding in data (or references to data).

Note: I don't actually do assembly programming, so this is just what I'm guessing.

08/03/2012 07:10 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ProperBritish
Daddy Proper
Team DreamArts

Posts: 5,666.3250
Threads: 192
Joined: 19th Nov 2008
Reputation: -2.36574
E-Pigs: 147.7035
Offline
Post: #3
RE: Assembly code [boring blog post]
also PS Vita is programmed in C++ or C#, not assembly.
hell even PSP was programmed in C, not assembly.

you read assembly right to left, and all of it revolves around registers or stacks (can't remember which) such as the EAX, EBX, ECX registers.

I did a section of my advanced programming on reading assembly, it's not hard to read. But to write, god help you.

The compiler of PSSuite, which i have, the PS Certified DevKit for PS Certified devices and the Vita, will compile the program into whatever assembly functions it needs to do.

Never should you need to program anything in Assembly these days, unless you are writing an OS of your own or something that in-depth.

[Image: rsz_contrast.png]

Spoiler for More sigs:
[Image: 6xu74t8]
[Image: sig.php]

[Image: 656embk]
[Image: sig.png]
(This post was last modified: 08/03/2012 07:32 PM by ProperBritish.)
08/03/2012 07:27 PM
Find all posts by this user Quote this message in a reply
Assassinator
...

Posts: 6,646.6190
Threads: 176
Joined: 24th Apr 2007
Reputation: 8.53695
E-Pigs: 140.8363
Offline
Post: #4
RE: Assembly code [boring blog post]
(08/03/2012 05:57 PM)Tetris999 Wrote:  P.S. Forgot to whine about this, but my partner in my android program project is a useless and lazy douche that's in computer science "for the monayz" (he's an arts student, probably one of the kids who apply to UBC just to get in and then find out that there's reasons for application requirements and goes into computer science because "its the only thing worthwhile in arts", not hating on arts students, but arts students like THESE are scum).

Lol doing computer science for the money.  Go tell him to do med or law instead, since he's an arts student, law probably fits him better anyway.  Actually he's probably not good enough to get into med or law, heh.



Assembly language is generally very simple to learn (for RISC systems anyway), it's just very annoying to use.  If you want to program anything significant it'll end up massive so I suggest not doing that and using a higher level language instead.

Also, you probably shouldn't try to program any games until you're very proficient at programming.

(08/03/2012 07:27 PM)ProperBritish Wrote:  you read assembly right to left, and all of it revolves around registers or stacks (can't remember which) such as the EAX, EBX, ECX registers.

I did a section of my advanced programming on reading assembly, it's not hard to read. But to write, god help you.

Most likely both.  Stacks take a while to get your head around but once you're used to it it's not that hard.

Assembly programming is usually covered in "Intro to Computer Systems" or something like that here, usually early second year.
(This post was last modified: 08/03/2012 08:33 PM by Assassinator.)
08/03/2012 08:22 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,022.2988
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.1294
Offline
Post: #5
RE: Assembly code [boring blog post]
My guess is that he's interested in assembly for the purposes of hacking the device?
I can only really think of five reasons, off the top of my head, why you may need to use assembly:
- reverse engineering
- you need a lot of speed or more optimisation than a compiler can give you
- some features not available in higher level languages (eg how an OS needs to save all registers)
- some fancy code injection type stuff
- specific applications, such as compilers, emulators etc
08/03/2012 08:30 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Tetris999
..............................

Posts: 2,390.4622
Threads: 298
Joined: 15th Apr 2007
Reputation: -6.7936
E-Pigs: 82.5657
Offline
Post: #6
RE: Assembly code [boring blog post]
(08/03/2012 07:27 PM)ProperBritish Wrote:  also PS Vita is programmed in C++ or C#, not assembly.
hell even PSP was programmed in C, not assembly.

you read assembly right to left, and all of it revolves around registers or stacks (can't remember which) such as the EAX, EBX, ECX registers.

I did a section of my advanced programming on reading assembly, it's not hard to read. But to write, god help you.

The compiler of PSSuite, which i have, the PS Certified DevKit for PS Certified devices and the Vita, will compile the program into whatever assembly functions it needs to do.

Never should you need to program anything in Assembly these days, unless you are writing an OS of your own or something that in-depth.

While that's definitely the case proper, I thought there are merits to assembly programming. As you said, yes, the C/C++/Java languages are basically templates to assembly code (as you give it to a compiler to interpret the statements to you) this makes coding easier to read but a much sloppier implementation.

By which I mean, anything done by a template may or may not be the most optimized assembly code for the device. In these days our devices are starting to get so fast that you don't even NEED to optimize your code to that level (like you said), it's still VERY handy in optimizing programs for smaller devices like the psp/ps vita/what have you with smaller amounts of ram/cpu power/etc.

Of course, I haven't done all of this yet so what do I know, this is all from what I've been reading about and hearing. Which is why I want to learn it and see if it's all true. That's the reason why I want to...

(08/03/2012 08:30 PM)ZiNgA BuRgA Wrote:  My guess is that he's interested in assembly for the purposes of hacking the device?
I can only really think of five reasons, off the top of my head, why you may need to use assembly:
- reverse engineering
- you need a lot of speed or more optimisation than a compiler can give you
- some features not available in higher level languages (eg how an OS needs to save all registers)
- some fancy code injection type stuff
- specific applications, such as compilers, emulators etc

...read me like a book, that's almost all the reasons as to why I want to learn assembly coding Zinga. But also for the "performance" that seems to be the golden land of assembly code, I still am trying to look into ARM architecture but nonetheless my exploits have been of mixed success because, as I said, I don't know assembly enough to know what the books I get are talking about.

Yeah fun stuff.

If I ever do get into the hacking shenanigans, I better change my name, YOU DIDN'T HEAR IT FROM ME HERE!


Oh, nonetheless, your replies have been really helpful guys, thanks.

EDIT:

(08/03/2012 08:22 PM)Assassinator Wrote:  Assembly language is generally very simple to learn (for RISC systems anyway), it's just very annoying to use.  If you want to program anything significant it'll end up massive so I suggest not doing that and using a higher level language instead.

Also, you probably shouldn't try to program any games until you're very proficient at programming.


Oh god, using assembly for everything? I think that's a bit much and I'd agree with you on using a higher level language for some parts of the program. Having said that, I also heard that C is the closest you can get to assembly (as in, a language that implements it in it's design), and that you can actually mix the two together in a single program, pretty neat if you ask me. Which allows you to optimize your algorithms but at the same time not bothering to assembly program your print statements and such.

Actually I don't know this to be true, my prof told me this, though I don't think I misheard him.

MY SIG IS FUCKING DEAD
(This post was last modified: 09/03/2012 05:20 AM by Tetris999.)
09/03/2012 05:10 AM
Find all posts by this user Quote this message in a reply
Assassinator
...

Posts: 6,646.6190
Threads: 176
Joined: 24th Apr 2007
Reputation: 8.53695
E-Pigs: 140.8363
Offline
Post: #7
RE: Assembly code [boring blog post]
(09/03/2012 05:10 AM)Tetris999 Wrote:  While that's definitely the case proper, I thought there are merits to assembly programming. As you said, yes, the C/C++/Java languages are basically templates to assembly code (as you give it to a compiler to interpret the statements to you) this makes coding easier to read but a much sloppier implementation.

No really, coding in assembly is terribly inefficient and if you try to code anything significant, shit quickly gets out of hand.

You should only ever bother with assembly optimization if speed is of utmost importance for whatever program you're writing, for example, a video encoder.  Even then you want to write pretty much everything in C, and only a very small amount of speed critical components in assembly language.

C Code
int x=1, y=0;
while (x<5) {
    y+=x*(x-2);
    x++;
}


Ok, lets say you want the equivalent of this bit of c code in assembly

Assuming your machine has 3 registers R0 R1 R2.  (Now normally you have more than 3 registers, but normally your program is also way more complicated and needs a lot more variables, so it evens out).

Note: this is like simplified pseudo-code assembly.  I obviously can't be fucked learning the real ARM assembly language just for the purpose of this demo.

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Store 1 R0   //Store value of x into register 0
Store 0 R2
Push R2      //Push the value of y onto the stack, because we don't have enough registers.
start_loop:
Store 5 R2
Jump_equal R0 R2 #exit_loop
Store 2 R2
Sub R0 R2 R1
Mult R0 R1 R1
Pop R2
Add R2 R1 R2
Push R2
Store 1 R2
Add R0 R2 R0
Jump #start_loop
exit_loop:
Pop R2      //This is the y you want at the end
End


Now imagine if you wanted to write a real program in assembly language, it's going to be a massive pile of mess, that's impossible to read and probably very annoying to debug.


(09/03/2012 05:10 AM)Tetris999 Wrote:  Having said that, I also heard that C is the closest you can get to assembly (as in, a language that implements it in it's design), and that you can actually mix the two together in a single program, pretty neat if you ask me. Which allows you to optimize your algorithms but at the same time not bothering to assembly program your print statements and such.

Actually I don't know this to be true, my prof told me this, though I don't think I misheard him.

Yeah, you can embed assembly code into C.
(This post was last modified: 10/03/2012 03:01 AM by Assassinator.)
09/03/2012 06:14 AM
Find all posts by this user Quote this message in a reply
hibbyware
ʕθ̿␣̅θ̿ʔ ℋiЬЬyℬot™

Posts: 1,048.2613
Threads: 19
Joined: 18th Jul 2007
Reputation: -3.09168
E-Pigs: 7.0196
Offline
Post: #8
RE: Assembly code [boring blog post]
 Results from ℋiЬЬyℬot™ - "better than Google"
Tetris999 Wrote:Actually I don't know this to be true, my prof told me this, though I don't think I misheard him.

Yes it's true you can mix the two and it's known as inline assembly.

[Image: small_hw_logo_001.png] ʕθ̿␣̅θ̿ʔ ℋiЬЬyℬot™
09/03/2012 06:22 AM
Find all posts by this user Quote this message in a reply
13thprotector
Paradigmatic Entity

Posts: 165.2444
Threads: 2
Joined: 22nd Feb 2012
Reputation: 1.00938
E-Pigs: 4.7310
Offline
Post: #9
RE: Assembly code [boring blog post]
Anyway a simpleton can understand this all?

"If you see a person jumping down the street, you can tell his preferences by shooting at the guy. If he starts whining, he plays Counter-Strike. If he charges you wielding an axe, you just interrupted a Morrowind player buffing his Acrobatics."
09/03/2012 07:21 AM
Find all posts by this user Quote this message in a reply
ProperBritish
Daddy Proper
Team DreamArts

Posts: 5,666.3250
Threads: 192
Joined: 19th Nov 2008
Reputation: -2.36574
E-Pigs: 147.7035
Offline
Post: #10
RE: Assembly code [boring blog post]
i would read how to do x86 assembly before trying ARM assembly.

http://www.cs.virginia.edu/~evans/cs216/guides/x86.html

very comprehensive guide here.

assassinator is completely right though, attempting to program in assembly is going to end up with a confusing mess.
inline assembly as far as i know is sparingly used, only when you're getting down to the really finnicky performance increases.

Code:
mov eax, [ebx] 	; Move the 4 bytes in memory at the address contained in EBX into EAX
mov [var], ebx 	; Move the contents of EBX into the 4 bytes at memory address var. (Note, var is a 32-bit constant).
mov eax, [esi-4] 	; Move 4 bytes at memory address ESI + (-4) into EAX
mov [esi+eax], cl 	; Move the contents of CL into the byte at address ESI+EAX
mov edx, [esi+4*ebx]     	; Move the 4 bytes of data at address ESI+4*EBX into EDX


these are just move commands in assembly, and as you can glean for x86, you take the command, and the operand on the right is moved into the one on the left. that is what i mean by right-to-left reading.

give the guide a go, see what you learn from it :3


[Image: rsz_contrast.png]

Spoiler for More sigs:
[Image: 6xu74t8]
[Image: sig.php]

[Image: 656embk]
[Image: sig.png]
09/03/2012 08:37 AM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 2 Guest(s)

 Quick Theme: