flat assembler
Message board for the users of flat assembler.

Index > Heap > am i stupid?

Author
Thread Post new topic Reply to topic
b1528932



Joined: 21 May 2010
Posts: 287
b1528932
Im having big problems to keep concentration on my code. For example, recently ive been writing few algoritms to bo some operations on bits, for example last one was signed division of large data. Ive spent 4 days on it.
Whats wrong with me? When think about how to approach it, before writing anything, it sounds really simple. Shift bits by X, subtract, if subtraction give 0 do it again, if cf break loop, and default write zeros and do normal subtraction.
Then rotate, and so on untill i process all data or get ending condition. It only seems simple before i start to write code.

When i start writing, the first thing i do (not?) is realize that i need a ton of local variables, and each of them named like [bp - XX]. In the past i was using registers, saving them on stack, using si, di, cx as counters, but when i found out that i need to have access to them in any given time i switched only to stack frames.
To simplify my coding, i use registers only this way:
ax - accumulator
bx - addres
bp - stack frame
dx - multiplication and pio
cx - bit shifts
di/si/sp - never use

This way bx registers is abused in my code, but its more readable.

This doesnt help much. When i start writing code, make first first loop i forget what i was supposed to do next. I try to remember, and when i do - i code it, and while doing so, i in turn forget about what was the first loop doing. At this point the most efficient thing to do is do delete everything and start over again, because when i try to understand what i wrote and check if its correct - i completly lose track of everything and find myself writing nonsense.


I dont know why im having such problems, its just impossible to code anything. At the beggining it looks simple, but in the middle i just dont know what im doing anymore. I know what im supposed to do, but i lose the big picture.


Am i that stupid, or i take wrong approach to code?
I use local variables as counters, when i need temporary variable, i use separate memory for each of them, even if its clearly i could reuse one.
I absolutly dont use any optimizations, like movs/xor ax, ax, just straightforward method.
I even tried not to cache memory in ax to do few operations on it, but access it every single time, just to keep it simple.

Still, whats wrong? Anyone having simmilar problems, that in the middle of writing code you have no idea what your doing?
Post 09 Feb 2011, 04:01
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17474
Location: In your JS exploiting you and your system
revolution
Draw a flow chart, or sketch out the algorithm, on paper. Jumping straight in and coding things from scratch can sometimes be difficult without these external aids to help direct your coding.
Post 09 Feb 2011, 04:21
View user's profile Send private message Visit poster's website Reply with quote
idle



Joined: 06 Jan 2011
Posts: 359
Location: Ukraine
idle
i've spent 2 years 2 study floats perfectly
i'm afraid watching my old sources(deleted)
i'm sometimes using paper for notes
i can not add-sub-mul-div quickly in mind
i forget names of my friends
you seem to be doubting about what you really need
reuse named vars :b
optimization is always difficult, writing and instro you must think beforehand
relax at last

in the past i had a math teacher and she was a bitch, my common mark was 5-6 while maximal was 12, one time i've received 11, as the itch said, but she put 7 arguing i was not so clever to do that; later i got another teacher and she was fair: 2-11 the marks were Smile so believe yourself, ask the forum

be fine
Post 09 Feb 2011, 06:23
View user's profile Send private message Reply with quote
ass0



Joined: 31 Dec 2008
Posts: 521
Location: ( . Y . )
ass0
You are getting old dude, take some vitamin-B12.

_________________
Image
Nombre: Aquiles Castro.
Location2: about:robots
Post 09 Feb 2011, 11:25
View user's profile Send private message Reply with quote
guignol



Joined: 06 Dec 2008
Posts: 725
guignol
b1528932
Maybe you have too much lyrica in your thinking.

rĂªve wrote:
Draw a flow chart,
or a 3D model...
Post 09 Feb 2011, 11:50
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel
When I design, I always go in -v (i.e. verbose) mode Smile

In the source code file, I write pseudo code, draw ASCII-art charts and describe (as in novel back-story) every single bit of code I'll need to implement.
Post 09 Feb 2011, 12:52
View user's profile Send private message Reply with quote
matefkr



Joined: 02 Sep 2007
Posts: 1291
Location: Ukraine, Beregovo
matefkr
write your code into the asm file as comments after one another. then later just start to replace comments with code.
Post 10 Feb 2011, 09:43
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.