![]() |
|
first full x86 program - Feedback Please - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Assembly (https://sinister.li/Forum-Assembly) +--- Thread: first full x86 program - Feedback Please (/Thread-first-full-x86-program-Feedback-Please) |
first full x86 program - Feedback Please - neko.py - 12-04-2017 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 RE: first full x86 program - Feedback Please - Blink - 12-04-2017 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 RE: first full x86 program - Feedback Please - phyrrus9 - 12-04-2017 (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. (12-04-2017, 05:57 AM)Ender Wrote: Wow, someone new in the assembly section! 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/master/asm/bigtostr.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/master/asm/bigarithmatic.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 RE: first full x86 program - Feedback Please - neko.py - 12-04-2017 (12-04-2017, 05:57 AM)Ender Wrote: Wow, someone new in the assembly section! 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 RE: first full x86 program - Feedback Please - phyrrus9 - 12-04-2017 (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 interesting, atoi is really simple. subtract 0x30 from digit convert bases 10->2 increment exponent repeat from right to left |