Sidetracking from 'Tabs vs. Spaces': Do you indent assembly code?
-
In the 'Surveys' section, there has been some assembler talk the last couple of days. It seems like we have fair share of developers not afraid of getting their fingers oily :-) I am curious: After more than 40 years of 'structured programming', do you assembler coders indent loop bodies, if-bodies / else-bodies etc. when you program such constructs in assembler? Or do you follow the tradition from 50 years ago, with every instruction/statement left justified?
-
In the 'Surveys' section, there has been some assembler talk the last couple of days. It seems like we have fair share of developers not afraid of getting their fingers oily :-) I am curious: After more than 40 years of 'structured programming', do you assembler coders indent loop bodies, if-bodies / else-bodies etc. when you program such constructs in assembler? Or do you follow the tradition from 50 years ago, with every instruction/statement left justified?
I tab indent since my sight requires the most assistance possible. I can no longer scan code like I was once able to.
-
In the 'Surveys' section, there has been some assembler talk the last couple of days. It seems like we have fair share of developers not afraid of getting their fingers oily :-) I am curious: After more than 40 years of 'structured programming', do you assembler coders indent loop bodies, if-bodies / else-bodies etc. when you program such constructs in assembler? Or do you follow the tradition from 50 years ago, with every instruction/statement left justified?
Never! God had made assembly language with 4 columns: label, opcode, args and comments and said each one should stay under it's own kind. And God saw every thing that he had made, and it was very good. :laugh:
Mircea
-
In the 'Surveys' section, there has been some assembler talk the last couple of days. It seems like we have fair share of developers not afraid of getting their fingers oily :-) I am curious: After more than 40 years of 'structured programming', do you assembler coders indent loop bodies, if-bodies / else-bodies etc. when you program such constructs in assembler? Or do you follow the tradition from 50 years ago, with every instruction/statement left justified?
What flavor of "Assembly"? I only ever had one semester of assembly (VAX-11 Macro) -- Structured Assembly Language Programming -- in college, 1988 (?) . I don't seem to have printouts of anything I wrote for it. But I have the book, and the examples are indented, so I would likely have followed suit. I would not indent if I wanted to obfuscate something.
-
In the 'Surveys' section, there has been some assembler talk the last couple of days. It seems like we have fair share of developers not afraid of getting their fingers oily :-) I am curious: After more than 40 years of 'structured programming', do you assembler coders indent loop bodies, if-bodies / else-bodies etc. when you program such constructs in assembler? Or do you follow the tradition from 50 years ago, with every instruction/statement left justified?
Depends on the assembler. Some old assemblers didn't give you the choice of indentation. For example, the TMS9900 assembler required your opcode to start in column 8. So, yeah, as with all things, "it depends."
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiak -
In the 'Surveys' section, there has been some assembler talk the last couple of days. It seems like we have fair share of developers not afraid of getting their fingers oily :-) I am curious: After more than 40 years of 'structured programming', do you assembler coders indent loop bodies, if-bodies / else-bodies etc. when you program such constructs in assembler? Or do you follow the tradition from 50 years ago, with every instruction/statement left justified?
I'm not using assembler much these days.
trønderen wrote:
Or do you follow the tradition from 50 years ago, with every instruction/statement left justified?
But in the "old" days most assembler projects I worked on was exactly the opposite with each and every line indented and only the jump labels left justified.
-
In the 'Surveys' section, there has been some assembler talk the last couple of days. It seems like we have fair share of developers not afraid of getting their fingers oily :-) I am curious: After more than 40 years of 'structured programming', do you assembler coders indent loop bodies, if-bodies / else-bodies etc. when you program such constructs in assembler? Or do you follow the tradition from 50 years ago, with every instruction/statement left justified?
No. It mostly impossible to indent in the way we do in C-like languages, because the way assembly flow works... Like in this code... No indentation makes sense here... However I use blank lines to break the code...
raster_irq: {
lda flag
and #popup_on
bne bottom // popup is activelda $d012 cmp #raster\_irq\_bottom\_line bcc top
bottom:
lda #charset2 // set secondary charset (for bottom half of the screen)
sta $d018lda #raster\_irq\_top\_line sta $d012 jmp end
top:
lda #charset1 // set primary charset (for top half of the screen)
sta $d018lda #raster\_irq\_bottom\_line sta $d012
end:
asl $d019 // clear pending
jmp $ea31 // finish interrupt
}"Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid." ― Albert Einstein
-
In the 'Surveys' section, there has been some assembler talk the last couple of days. It seems like we have fair share of developers not afraid of getting their fingers oily :-) I am curious: After more than 40 years of 'structured programming', do you assembler coders indent loop bodies, if-bodies / else-bodies etc. when you program such constructs in assembler? Or do you follow the tradition from 50 years ago, with every instruction/statement left justified?
No. Probably because the early assemblers I learned on didn't support it: column zero starts were a label, column 7 started an opcode, column 15 was a parameter. And also because it wouldn't have worked in most cases: spaghetti code is a "feature" of much assembly code (since you are trying to cram as much function into as little ROM space or processing time as possible) and you can't indent that in a meaningful way.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
In the 'Surveys' section, there has been some assembler talk the last couple of days. It seems like we have fair share of developers not afraid of getting their fingers oily :-) I am curious: After more than 40 years of 'structured programming', do you assembler coders indent loop bodies, if-bodies / else-bodies etc. when you program such constructs in assembler? Or do you follow the tradition from 50 years ago, with every instruction/statement left justified?
Anyone who indents assembly code will be burned at the stake for such heresy.
Nothing succeeds like a budgie without teeth. To err is human, to arr is pirate.
-
In the 'Surveys' section, there has been some assembler talk the last couple of days. It seems like we have fair share of developers not afraid of getting their fingers oily :-) I am curious: After more than 40 years of 'structured programming', do you assembler coders indent loop bodies, if-bodies / else-bodies etc. when you program such constructs in assembler? Or do you follow the tradition from 50 years ago, with every instruction/statement left justified?
-
In the 'Surveys' section, there has been some assembler talk the last couple of days. It seems like we have fair share of developers not afraid of getting their fingers oily :-) I am curious: After more than 40 years of 'structured programming', do you assembler coders indent loop bodies, if-bodies / else-bodies etc. when you program such constructs in assembler? Or do you follow the tradition from 50 years ago, with every instruction/statement left justified?
YES. I indent everything, even my notes. But I did backport an habit from assembly: I align operators and operands on consecutive lines. Example
longFunctionName(arg1, argument2);
shortFunction (argument1, arg2 );Not only it makes it easier for me to parse the code but it's a boon when used with column editing. All the coworkers who have worked on my code appreciate it too.
GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
-
Anyone who indents assembly code will be burned at the stake for such heresy.
Nothing succeeds like a budgie without teeth. To err is human, to arr is pirate.
Considering gas prices (1.7€ / scm), collecting stakes to be burned is a solution.
GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
-
No. Probably because the early assemblers I learned on didn't support it: column zero starts were a label, column 7 started an opcode, column 15 was a parameter. And also because it wouldn't have worked in most cases: spaghetti code is a "feature" of much assembly code (since you are trying to cram as much function into as little ROM space or processing time as possible) and you can't indent that in a meaningful way.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
OriginalGriff wrote:
column zero starts were a label, column 7 started an opcode, column 15 was a parameter.
Sounds like PLAN (ICL 1900 Assembler) which I spent several years writing. Col 1 = label, col 7 = op code, 13 = accumulator(s), 17 = operand, 36 = comment, 73 to 80 = sequence number The sequence numbers were vital. It was the only way of reconstructing a source program if you (or, more commonly, the computer operator) accidentally dropped the deck of cards and you (always the programmer) had to re-order them back into their original sequence.
-
OriginalGriff wrote:
column zero starts were a label, column 7 started an opcode, column 15 was a parameter.
Sounds like PLAN (ICL 1900 Assembler) which I spent several years writing. Col 1 = label, col 7 = op code, 13 = accumulator(s), 17 = operand, 36 = comment, 73 to 80 = sequence number The sequence numbers were vital. It was the only way of reconstructing a source program if you (or, more commonly, the computer operator) accidentally dropped the deck of cards and you (always the programmer) had to re-order them back into their original sequence.
Oh gawd yes - dropped desk were a PITA. And you had to remember to leave gaps in teh sequence numbering so you could add code later ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
In the 'Surveys' section, there has been some assembler talk the last couple of days. It seems like we have fair share of developers not afraid of getting their fingers oily :-) I am curious: After more than 40 years of 'structured programming', do you assembler coders indent loop bodies, if-bodies / else-bodies etc. when you program such constructs in assembler? Or do you follow the tradition from 50 years ago, with every instruction/statement left justified?
-
No. It mostly impossible to indent in the way we do in C-like languages, because the way assembly flow works... Like in this code... No indentation makes sense here... However I use blank lines to break the code...
raster_irq: {
lda flag
and #popup_on
bne bottom // popup is activelda $d012 cmp #raster\_irq\_bottom\_line bcc top
bottom:
lda #charset2 // set secondary charset (for bottom half of the screen)
sta $d018lda #raster\_irq\_top\_line sta $d012 jmp end
top:
lda #charset1 // set primary charset (for top half of the screen)
sta $d018lda #raster\_irq\_bottom\_line sta $d012
end:
asl $d019 // clear pending
jmp $ea31 // finish interrupt
}"Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid." ― Albert Einstein
Looks indented to me.
-
In the 'Surveys' section, there has been some assembler talk the last couple of days. It seems like we have fair share of developers not afraid of getting their fingers oily :-) I am curious: After more than 40 years of 'structured programming', do you assembler coders indent loop bodies, if-bodies / else-bodies etc. when you program such constructs in assembler? Or do you follow the tradition from 50 years ago, with every instruction/statement left justified?
The last time I wrote assembly code was on an XT box (8088 processor) using edlin. I barely remember what I ate for dinner yesterday, much less code from 40 years ago. I do remember loving to code that close to the hardware. And thanks for reminding me that I'm old as dirt. :laugh:
If you think 'goto' is evil, try writing an Assembly program without JMP.
-
No, of course not. Assembler was supposed to be hard to read, nothing should make it easier! I also didn't indent FORTRAN - but then it didn't lend itself to that.
- I would love to change the world, but they won’t give me the source code.
-
No. Probably because the early assemblers I learned on didn't support it: column zero starts were a label, column 7 started an opcode, column 15 was a parameter. And also because it wouldn't have worked in most cases: spaghetti code is a "feature" of much assembly code (since you are trying to cram as much function into as little ROM space or processing time as possible) and you can't indent that in a meaningful way.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
In the 'Surveys' section, there has been some assembler talk the last couple of days. It seems like we have fair share of developers not afraid of getting their fingers oily :-) I am curious: After more than 40 years of 'structured programming', do you assembler coders indent loop bodies, if-bodies / else-bodies etc. when you program such constructs in assembler? Or do you follow the tradition from 50 years ago, with every instruction/statement left justified?
Never, always been a tab then the op code. Labels start in the first column.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle