Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 655 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
first full x86 program - Feedback Please

#1
I recently finished my first shot at a full x86 program. I decided to do the first project euler challenge. This program takes one number as an argument, and for every number between it and 0, will figure out if that number is divisible by 3 or 5. If it is, it adds it to a running sum, then outputs the sum. The problem description is described

[To see links please register here]

.

I cut some corners, including hardcoding the address of the first argument to the program. I believe this makes the program reliant on arg0 being a certain length. There's also some random unused code that I havent removed.

I was hoping to get some feedback on what i could do differently or how i could improve. I'm not super familiar with x86-specific opcodes and fancy stuff, so if i missed an opportunity to use something like that, let me know. I intentionally didn't use libraries since this was supposed to be a practice exercise.

The source is

[To see links please register here]

and the makefile is

[To see links please register here]


thanks for reading
Reply

#2
Quote:(12-04-2017, 04:20 AM)neko.py Wrote:

[To see links please register here]

I recently finished my first shot at a full x86 program. I decided to do the first project euler challenge. This program takes one number as an argument, and for every number between it and 0, will figure out if that number is divisible by 3 or 5. If it is, it adds it to a running sum, then outputs the sum. The problem description is described

[To see links please register here]

.

I cut some corners, including hardcoding the address of the first argument to the program. I believe this makes the program reliant on arg0 being a certain length. There's also some random unused code that I havent removed.

I was hoping to get some feedback on what i could do differently or how i could improve. I'm not super familiar with x86-specific opcodes and fancy stuff, so if i missed an opportunity to use something like that, let me know. I intentionally didn't use libraries since this was supposed to be a practice exercise.

The source is

[To see links please register here]

and the makefile is

[To see links please register here]


thanks for reading

Quote:(12-04-2017, 05:57 AM)Ender Wrote:

[To see links please register here]

Wow, someone new in the assembly section!
That's pretty rare, you should talk to me and @phyrrus9 more on Discord.

Each time I read someone else's code, unless it's really well documented/commented, my mind just blanks out, so I won't be giving any feedback on this. Strange, since I can often write the same code without problem.

EDIT: I just noticed that the problem says for you to output "the sum of all the multiples of 3 or 5 below 1000", which doesn't require any arguments.
EDIT 2: I'm pretty sure that program can be made shorter, seems long

assembly (especially x86....yuck...) is hard to understand at first glance, and this is quite long (longer than I'd expect it to be).

OP: on my github (

[To see links please register here]

) there are many of the subs that you wrote, but built in a more extensible way, you should check them out.

Also in the same project (

[To see links please register here]

) is a subroutine using SysVAbi so that you don't have to write the entire program in asm. Alternatively, you can invert that process and call the real stdio suite of functions from libc
Reply

#3
Quote:(12-04-2017, 05:57 AM)Ender Wrote:

[To see links please register here]

Wow, someone new in the assembly section!
That's pretty rare, you should talk to me and @phyrrus9 more on Discord.

Each time I read someone else's code, unless it's really well documented/commented, my mind just blanks out, so I won't be giving any feedback on this. Strange, since I can often write the same code without problem.

EDIT: I just noticed that the problem says for you to output "the sum of all the multiples of 3 or 5 below 1000", which doesn't require any arguments.
EDIT 2: I'm pretty sure that program can be made shorter, seems long

Thanks for reading. Maybe I'll sync up with pyrrus on discord about it. I know that the question didnt require me to be able to take arguments, but leaving the program locked at only solving a *single* problem just made me feel itchy -- i had to make it more versatile than that. To be honest, i think i spent the most time on the atoi implementation anyway, so im glad i did it
Reply

#4
Quote:(12-04-2017, 06:05 AM)neko.py Wrote:

[To see links please register here]

Quote: (12-04-2017, 05:57 AM)Ender Wrote:

[To see links please register here]

Wow, someone new in the assembly section!
That's pretty rare, you should talk to me and @phyrrus9 more on Discord.

Each time I read someone else's code, unless it's really well documented/commented, my mind just blanks out, so I won't be giving any feedback on this. Strange, since I can often write the same code without problem.

EDIT: I just noticed that the problem says for you to output "the sum of all the multiples of 3 or 5 below 1000", which doesn't require any arguments.
EDIT 2: I'm pretty sure that program can be made shorter, seems long

Thanks for reading. Maybe I'll sync up with pyrrus on discord about it. I know that the question didnt require me to be able to take arguments, but leaving the program locked at only solving a *single* problem just made me feel itchy -- i had to make it more versatile than that. To be honest, i think i spent the most time on the atoi implementation anyway, so im glad i did it

that's interesting, atoi is really simple.

subtract 0x30 from digit
convert bases 10->2
increment exponent
repeat from right to left
Reply

#5
Wow, someone new in the assembly section!
That's pretty rare, you should talk to me and @phyrrus9 more on Discord.

Each time I read someone else's code, unless it's really well documented/commented, my mind just blanks out, so I won't be giving any feedback on this. Strange, since I can often write the same code without problem.

EDIT: I just noticed that the problem says for you to output "the sum of all the multiples of 3 or 5 below 1000", which doesn't require any arguments.
EDIT 2: I'm pretty sure that program can be made shorter, seems long
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through