Posts: 0
Threads: 0
Joined: Dec 2016
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
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
|
Posts: 0
Threads: 0
Joined: Feb 2018
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
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
|
Posts: 0
Threads: 0
Joined: Oct 2021
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
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
|
Posts: 0
Threads: 0
Joined: Jul 2017
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
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
|
Posts: 0
Threads: 0
Joined: Apr 2018
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
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
|
|