Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Sidetracking from 'Tabs vs. Spaces': Do you indent assembly code?

Sidetracking from 'Tabs vs. Spaces': Do you indent assembly code?

Scheduled Pinned Locked Moved The Lounge
visual-studioquestion
31 Posts 15 Posters 6 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T trønderen

    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?

    F Offline
    F Offline
    Franc Morales
    wrote on last edited by
    #2

    I tab indent since my sight requires the most assistance possible. I can no longer scan code like I was once able to.

    1 Reply Last reply
    0
    • T trønderen

      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?

      Mircea NeacsuM Offline
      Mircea NeacsuM Offline
      Mircea Neacsu
      wrote on last edited by
      #3

      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

      1 Reply Last reply
      0
      • T trønderen

        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?

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #4

        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.

        1 Reply Last reply
        0
        • T trønderen

          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?

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #5

          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

          1 Reply Last reply
          0
          • T trønderen

            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?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #6

            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.

            1 Reply Last reply
            0
            • T trønderen

              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?

              Kornfeld Eliyahu PeterK Offline
              Kornfeld Eliyahu PeterK Offline
              Kornfeld Eliyahu Peter
              wrote on last edited by
              #7

              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 active

              lda $d012
              cmp #raster\_irq\_bottom\_line
              bcc top
              

              bottom:
              lda #charset2 // set secondary charset (for bottom half of the screen)
              sta $d018

              lda #raster\_irq\_top\_line
              sta $d012
              
              jmp end
              

              top:
              lda #charset1 // set primary charset (for top half of the screen)
              sta $d018

              lda #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

              "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

              P T 2 Replies Last reply
              0
              • T trønderen

                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?

                OriginalGriffO Offline
                OriginalGriffO Offline
                OriginalGriff
                wrote on last edited by
                #8

                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!

                "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

                J T 2 Replies Last reply
                0
                • T trønderen

                  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?

                  W Offline
                  W Offline
                  Wizard of Sleeves
                  wrote on last edited by
                  #9

                  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.

                  D 1 Reply Last reply
                  0
                  • T trønderen

                    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?

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #10

                    Labels start in column 1, instructions in column 11, operands in column 21, and comments in column 41 (although the semi-colon should be in column 39).

                    1 Reply Last reply
                    0
                    • T trønderen

                      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?

                      D Offline
                      D Offline
                      den2k88
                      wrote on last edited by
                      #11

                      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

                      1 Reply Last reply
                      0
                      • W Wizard of Sleeves

                        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.

                        D Offline
                        D Offline
                        den2k88
                        wrote on last edited by
                        #12

                        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

                        1 Reply Last reply
                        0
                        • OriginalGriffO OriginalGriff

                          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!

                          J Offline
                          J Offline
                          jsc42
                          wrote on last edited by
                          #13

                          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.

                          OriginalGriffO T 2 Replies Last reply
                          0
                          • J jsc42

                            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.

                            OriginalGriffO Offline
                            OriginalGriffO Offline
                            OriginalGriff
                            wrote on last edited by
                            #14

                            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!

                            "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

                            1 Reply Last reply
                            0
                            • T trønderen

                              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?

                              F Offline
                              F Offline
                              Forogar
                              wrote on last edited by
                              #15

                              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.

                              T 1 Reply Last reply
                              0
                              • Kornfeld Eliyahu PeterK Kornfeld Eliyahu Peter

                                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 active

                                lda $d012
                                cmp #raster\_irq\_bottom\_line
                                bcc top
                                

                                bottom:
                                lda #charset2 // set secondary charset (for bottom half of the screen)
                                sta $d018

                                lda #raster\_irq\_top\_line
                                sta $d012
                                
                                jmp end
                                

                                top:
                                lda #charset1 // set primary charset (for top half of the screen)
                                sta $d018

                                lda #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

                                P Offline
                                P Offline
                                PIEBALDconsult
                                wrote on last edited by
                                #16

                                Looks indented to me.

                                Kornfeld Eliyahu PeterK 1 Reply Last reply
                                0
                                • T trønderen

                                  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?

                                  T Offline
                                  T Offline
                                  TNCaver
                                  wrote on last edited by
                                  #17

                                  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.

                                  1 Reply Last reply
                                  0
                                  • F Forogar

                                    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.

                                    T Offline
                                    T Offline
                                    TNCaver
                                    wrote on last edited by
                                    #18

                                    The FORTRAN I used back in the day had everything in specific columns. So yeah, no indentions.

                                    If you think 'goto' is evil, try writing an Assembly program without JMP.

                                    T 1 Reply Last reply
                                    0
                                    • OriginalGriffO OriginalGriff

                                      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!

                                      T Offline
                                      T Offline
                                      TNCaver
                                      wrote on last edited by
                                      #19

                                      OriginalGriff wrote:

                                      spaghetti code is a "feature" of much assembly code

                                      Yep. See my signature line. :-D

                                      If you think 'goto' is evil, try writing an Assembly program without JMP.

                                      T 1 Reply Last reply
                                      0
                                      • T trønderen

                                        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?

                                        J Offline
                                        J Offline
                                        jeron1
                                        wrote on last edited by
                                        #20

                                        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

                                        1 Reply Last reply
                                        0
                                        • P PIEBALDconsult

                                          Looks indented to me.

                                          Kornfeld Eliyahu PeterK Offline
                                          Kornfeld Eliyahu PeterK Offline
                                          Kornfeld Eliyahu Peter
                                          wrote on last edited by
                                          #21

                                          OP was talking about if- and for-like structures... The only indentation here is labels vs code...

                                          "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

                                          "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

                                          P 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups