chevron_left chevron_right
Login Register invert_colors photo_library
Thread Rating:
  • 0 Vote(s) - 0 Average


filter_list first full x86 program - Feedback Please
Author
Message
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 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 here
and the makefile is here

thanks for reading

Reply

RE: first full x86 program - Feedback Please #2
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
(This post was last modified: 12-04-2017, 06:02 AM by Ender.)
+++++++++[>++++++++++>>++++++++++<<<-]>+>>+++<<<++++[>>++++++++++>>++++++++++>++++++++++<<<<<-]>>+++++>>+++>++++++[<<<<<,[>>>>.<<<<-]>>>>>.<<<<.>.>.>>]

[Image: duwskq.gif]

Reply

RE: first full x86 program - Feedback Please #3
(12-04-2017, 04:20 AM)neko.py Wrote: 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 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 here
and the makefile is here

thanks for reading

(12-04-2017, 05:57 AM)Ender Wrote: 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 (https://github.com/phyrrus9/bigmath/blob...gtostr.asm) 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 (https://github.com/phyrrus9/bigmath/blob...ic.asm#L31) 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
I will keep that list up to date at all times. Check often for new materials!

Reply

RE: first full x86 program - Feedback Please #4
(12-04-2017, 05:57 AM)Ender Wrote: 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

[+] 1 user Likes neko.py's post
Reply

RE: first full x86 program - Feedback Please #5
(12-04-2017, 06:05 AM)neko.py Wrote:
(12-04-2017, 05:57 AM)Ender Wrote: 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
I will keep that list up to date at all times. Check often for new materials!

Reply






Users browsing this thread: 1 Guest(s)