flat assembler
Message board for the users of flat assembler.

Index > Heap > The three hardest things to deal with in assembly ...

Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17250
Location: In your JS exploiting you and your system
revolution
  • Naming of labels
  • Cache optimisation
  • Handling of the 29th of February
  • Off-by-one errors
Post 01 May 2012, 05:24
View user's profile Send private message Visit poster's website Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 724
tthsqe
Could you give an example of what you are talking about with cache optimizations? (Suppose that you are not just marching through a large data set like in matrix-vector multiplication, ect.)
any pointers would be appreciated...
Post 01 May 2012, 05:43
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1408
Location: Toronto, Canada
AsmGuru62
If you're serious about labels:

1. Name the procedure labels by concatenating the name of a
source file and the name of the procedure itself. Imagine that you have
a file named TObject1.Asm and TObject2.Asm. Both of these objects suppose to have
a function called Draw. Therefore labels for these functions will be:

TObject1_Draw:
...
TObject2_Draw:

Large projects can't be done without this rule.
But with this rule code becomes easy to read, even after few years
passed since the coding started.

2. Local labels, simply call by their name, like:

.done_parsing:
...
.got_file_name:
...
.calc_memory_reserves:
...
Post 01 May 2012, 10:41
View user's profile Send private message Send e-mail Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
hem... label name can be simplified a lot using local labels anywhere it's possible, and if you speak objects, then a method will have a local name to this new type of object.

TObj1.asm
Code:
TObj1:
.Draw:
    

TObj2.asm
Code:
TObj2:
.Draw:
    


to access the draw mathod of Obj1, you make exactlly like with OBj2,

global name.local name.
call OBj1.Draw
call OBj2.Draw

when revoution says the name is hard to find, i understand the difficulty to find the appropriate name for OBj1, and also the name for Draw, where Draw can be also Print, print, draw, Disp, disp, paint, Paint, etc..
the same for OBj, where it can be Object, object, item, Item, thing, Thing, etc...
the difficulties in asm is that there are too much freedom, and you feel like a pioneer in an unknown world everythime you start a new project.
Naming labels with numbers to show some iteration is really bad practive for general purpose things like Obj, etc...
but sometimes, the quick & esay copy paste is stronger, and we get labels like message1, message2, message3, file1, file2, file3, etc...

in fact, the labels should not be defined during code writing, but during conception, where you will have to determine every partof your code, and in this place, labels are hard to choose.

and i see there are not 3 but 4 hardest things in assembly.

Off-by-one errors, what's that?

why do you find the handling of 29th feb so hard?
Post 01 May 2012, 12:23
View user's profile Send private message Visit poster's website Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 692
Location: Adelaide
sinsi
>Cache optimisation
Which cache?

>not 3 but 4
>Off-by-one errors
You answered yourself
wondering how long it would take

Anyway, the hardest thing is zeroing a register...
Post 01 May 2012, 12:46
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
what cases of use makes 29th feb (and leap second?) hard to handle?

have you examples where issues can be met?

off by one, ok, get it, it can be off by 1000 also, as the hard things list is very long. Laughing
Post 01 May 2012, 12:57
View user's profile Send private message Visit poster's website Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 8870
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
idk why creating an application that you really satisfied is so hard?
until we able to program like playing games..
Post 01 May 2012, 13:06
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1408
Location: Toronto, Canada
AsmGuru62
@edfed: very good approach.
Can I use it in my new OOP IDE without paying you?
Smile
Post 01 May 2012, 15:07
View user's profile Send private message Send e-mail Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
hum... i want to earn a symbolic royalty of one milli.€ (0.001€) per object oriented character in your code that are:
Code:
. ;like in "call class.method"
: ;like in ".method:" or "object:"
_ ;like in "object_Type" or "_system"
+ ;like in "mov eax,[object+class.method]"
= ;like in ".field=N
* ;like in mov eax,[object+class.datas+ecx*4]
    


Laughing
Post 01 May 2012, 15:30
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
edfed wrote:
what cases of use makes 29th feb (and leap second?) hard to handle?


*nix time_t? 32-bit or 64-bit? (Linux uses 64-bit nowadays) And things like Gzip, do .gz archives even support leap day? (Dunno!) So that's annoying.

Though honestly I thought the hardest parts of assembly were these:


  • incompatible dialects (MASM, TASM, A86 ... yuck)
  • signed vs. unsigned
  • minint = -maxint-1 (or does that also count as "off by one"?)
  • at runtime detecting cpu, mode, etc.
  • wrestling with different calling conventions
  • floating point and/or SIMD (ugh, what a mess)
  • buggy API docs
  • overflow, difficulty to mul or div by large-ish numbers


EDIT: I meant "minint", bah, you guys probably know what I mean better than I do.
Post 01 May 2012, 18:03
View user's profile Send private message Visit poster's website 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.

Powered by rwasa.