It is currently Mon Oct 23, 2017 5:32 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Sat Jan 21, 2017 1:53 pm 
Offline
Formerly WheelInventor

Joined: Thu Apr 14, 2016 2:55 am
Posts: 910
Location: Gothenburg, Sweden
Ah, thanks! Good to know. I feel a little bad for making that mistake.

_________________
http://www.frankengraphics.com - personal NES blog


Top
 Profile  
 
PostPosted: Sat Jan 21, 2017 2:02 pm 
Offline

Joined: Tue May 28, 2013 5:49 am
Posts: 809
Location: Sweden
WheelInventor wrote:
pokun wrote:
Nuancically equalent with the English "practice"

For this use, is there such a word? 'Praktik' might have been at one point, but i feel it is archaic when used as such compared to both 'praxis' and the english 'practice' (meaning mode of doing things). Arbetsmetod (Working method)?

I don't think there is an 100% equalent word. "Praktik" means practice as in the opposite of theory, but not practice as in "ice hockey practice". Oh there are so many words that mean different kinds of practice.


Top
 Profile  
 
PostPosted: Sat Jan 21, 2017 4:40 pm 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2963
Location: Tampere, Finland
Pokun wrote:
Heh, in Swedish "praxis" would be the proper word for the context used in this thread. But it's not totally nuancically equalent with the English "practice".

Yeah I meant in the context of this thread, as in "what's the practice on tutorial commenting".

(Sorry for the derail.)

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Sat Jan 21, 2017 4:56 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10068
Location: Rio de Janeiro - Brazil
I believe we now have way more comments about practice than about comments...


Top
 Profile  
 
PostPosted: Sat Jan 21, 2017 5:03 pm 
Offline
Formerly WheelInventor

Joined: Thu Apr 14, 2016 2:55 am
Posts: 910
Location: Gothenburg, Sweden
So to um, bring things back on topic.

In old programming manuals for the 6502, i often see a recommendation to comment each block with what registers and/or flags it affects, and what is expected to come in and go out. Would this be valid for tutorials, too?

_________________
http://www.frankengraphics.com - personal NES blog


Top
 Profile  
 
PostPosted: Sat Jan 21, 2017 5:15 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
WheelInventor wrote:
In old programming manuals for the 6502, i often see a recommendation to comment each block with what registers and/or flags it affects, and what is expected to come in and go out. Would this be valid for tutorials, too?

It's good programming practise in general (that means it applies to tutorials just as much as actual production code).

Similar methodology -- though not for registers, but rather for input arguments and return values/pointers -- is used in C and other PLs as well.


Top
 Profile  
 
PostPosted: Sun Jan 22, 2017 2:30 am 
Offline

Joined: Tue May 28, 2013 5:49 am
Posts: 809
Location: Sweden
Hm maybe I should start doing it more like that.

A good tutorial should teach good commenting I think. Especially if it's aimed for newbie programmers.


Top
 Profile  
 
PostPosted: Sun Jan 22, 2017 4:03 pm 
Offline
User avatar

Joined: Sat Jul 12, 2014 3:04 pm
Posts: 936
Oh, comments establishing pre- and post-conditions of a function/subroutine? Yeah, often-taught in CS. (Of course, you don't need a JSR to make a subroutine…)

Part of the reason you set these conditions is so that you can test your code piecemeal.


Top
 Profile  
 
PostPosted: Sun Jan 22, 2017 4:27 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5736
Location: Canada
For assembly code it tends to be more important to document the input/output/side-effects of a function than it usually is in C, just because it's easier to write C with less side effects.

In C, very often all the inputs to a function are already encapsulated as its parameter arguments, with a single well defined return value as output, and it's easy to keep temporary values within the scope of the function itself (i.e. on the stack), preventing most side-effects. Unless your function depends on or modifies global variables, the needed information is often made quite clear from just the definition of the function. You may need to document what the function does, and what its arguments mean, but the rest can be self-contained.

In assembly, especially on the 6502 with such limited registers available, you will probably often want to use global variables as inputs, outputs, and for temporary calculation. There's a lot of need there to document this stuff.

For example, I tend to include quick summaries like the following so I can manage my use of temporary global variables when calling the functions:
Code:
.import sprite_add           ; A=sprite, X=x, Y=y (clobbers A,X,Y,i,j,k)
.import sprite_tile_add      ; A=tile, X=x, Y=y, i=attribute (clobbers A,X)
.import palette_load         ; A=slot, X=palette (clobbers Y)


When using C with inline assembly, some compilers also had input, output, and clobber lists, which let you tell the compiler to pre-load specific registers with your input values, and which registers to recover the output values from, and the clobber list tells it which registers have been changed by your assembly code so the compiler doesn't have to presume that every register has been invalidated (there may be some useful values still in registers from before the inline assembly, and the compiler can use this to optimize).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google [Bot] and 9 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group