6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 16, 2024 12:40 am

All times are UTC




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Fri Jun 06, 2014 6:28 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10980
Location: England
From time to time someone refers to the act of transforming an assembly language program into runnable machine code as "compiling."

Almost no-one will be confused by that, and in my view it doesn't help to make a big deal of it. It seems to be a common usage among the C64 userbase.

However, there is wide agreement that the term "assembling" is the better term for this transformation, and the program which does the work is called an "assembler." This leaves the term "compiler" to refer unambiguously to a program which transforms a high level language (a compiled language) into runnable machine code, or into some intermediate form.

So, on this forum, there will be less perturbation if you use the term "assembling". If someone happens to use the term "compiling" there is no need to "correct" their dialect.

Cheers
Ed

(A high level language is distinct from assembly language in that it will look after some low-level details and make some low level aspects of the machine difficult or impossible to access. For example, a high level language will probably support multi-byte integers and will look after memory allocation for named variables. It's probably not useful to debate in this thread which languages are high level or where the boundary lies or whether assembly language macros make any relevant difference to terminology.)


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 06, 2014 6:38 am 
Online
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
I suppose that if you have a lot of macros in your assembly-language code, it almost qualifies as "compiling," although we still use an assembler for it. The strange thing about the terminology is that an "assembler" actually takes assembly language and disassembles it into machine language, and a "disassembler" actually takes the machine language and turns it back into assembly. Maybe the machinists' union complained when somone originally proposed calling it a "machiner" or "machinist." :lol:

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 06, 2014 8:00 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10980
Location: England
Hmm, I wouldn't call macro expansion compiling, personally.

And I surely wouldn't think of assembling as in any sense disassembling! "INX" is in no sense composed of the byte E8.

Cheers
Ed


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 06, 2014 8:24 am 
Offline
User avatar

Joined: Fri Oct 31, 2003 10:00 pm
Posts: 200
From Wikipedia, and I support these definitions:

A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code).[1] The most common reason for wanting to transform source code is to create an executable program.

The name "compiler" is primarily used for programs that translate source code from a high-level programming language to a lower level language (e.g., assembly language or machine code
).

An assembly language is a low-level programming language for a computer, or other programmable device, in which there is a very strong (generally one-to-one) correspondence between the language and the architecture's machine code instructions. Each assembly language is specific to a particular computer architecture, in contrast to most high-level programming languages, which are generally portable across multiple architectures, but require interpreting or compiling.

Assembly language is converted into executable machine code by a utility program referred to as an assembler; the conversion process is referred to as assembly, or assembling the code.


Note that an assembler may produce the intermediate object code, instead of an executable. It has to be linked (assembled?) into executable code in a next step.

Source code usually is human readable, a text file. But in compiler technology it can also be an intermediate binary code, like in front-backend constructions or byte code as used for VMs and JIT (just in time) compilers e.g.

One may arque that assembly language is source code in text format and the assembler 'compiles' this in executable code.

Some assemblers allow constructs that are way above the generally one-to-one correspondence and are indeed higher level constructs.

The line between compiling and assembling is not that easy to draw!

Ihave often made programs written in a high level language with machine language parts, and made that into an executable.

To be politicaly correct I should say: I compiled the high level language source, assembled the machine language parts and linked it into an executable.

Or just say 'make' it :)


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 06, 2014 8:29 am 
Online
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
HansO posted while I was writing, but I'll post this anyway, along those lines.

I don't call it compiling, but it bears some resemblance when you have things like this piece from my article on simple methods to do multitasking without a multitasking OS:
Code:
WATCH_ACIA:
        LDA  RX_STATE
        CASE  ACCUM

            CASE_OF  0                             ; In the case of RX_STATE being 0, an $FF is required to increment it to 1.
                IF_BIT   ACIA_STAT_REG, 3, IS_SET  ; If a byte came in (indicated by bit 3 of the status register),
                    LDA  ACIA_DATA_REG             ; get it (this clears the flag in the status register too),
                    CMP  #$FF                      ; and see if it's $FF.
                    IF_EQ                          ; If it is,
                        INC  RX_STATE              ; move on to watch for a valid (non-$FF) first byte.
                    END_IF                         ; The $FF gets discarded.
                END_IF                             ; If no byte came in, just exit.
            END_OF


            CASE_OF  1                             ; To get here, we've received the $FF marker and we're looking for a valid 1st byte.
                IF_BIT   ACIA_STAT_REG, 3, IS_SET  ; If a byte came in,
                    LDA  ACIA_DATA_REG             ; get it,
                    IF_PLUS                        ; see if it's valid as a high byte, ie, that the high bit is clear, and if so,
                        STA  READING_BUF           ; store it as valid in the buffer area meant to prevent wrong readings between bytes,
                        INC  RX_STATE              ; and move on to watch for the 2nd byte which could be anything.
                    END_IF                         ; If it's not a valid high byte, just discard it, and leave RX_STATE as is.
                END_IF                             ; If no byte came in, just exit.
            END_OF

                                                        ; In the case of RX_STATE being 2, we've gotten the high byte of READING,
            CASE_OF  2                                  ; and we're waiting for the second byte which could be anything.
                IF_BIT  ACIA_STAT_REG, 3, IS_SET        ; See if a byte came in.  If one did,
                    COPY  VIA_SR, TO, READING           ; just transfer it
                    COPY  READING_BUF, TO, READING+1    ; (including the high byte now, which we had saved to prevent glitches
                    STZ   RX_STATE                      ; in the two-byte READING value), and go back to state 0.
                END_IF                                  ; If no byte came in, just exit.
            END_OF


            STZ   RX_STATE                         ; If there's any chance for state to go invalid, just reset it and start over.
        END_CASE
        RTS
 ;---------------------------------------

because there's stuff going on in the assembler that makes for interaction between the macros to make the program structures. Lines are not autonomous like they are in normal assembly language.

Although I've never called assembling compiling, the subject becomes interesting now that you've brought it up.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 06, 2014 8:36 am 
Offline

Joined: Sun Apr 10, 2011 8:29 am
Posts: 597
Location: Norway/Japan
You may think of a high-level language as instructions for a virtual machine. When you compile, you translate that into another machine (e.g. your target CPUs instruction set). An assembler is instead mapping one notation to another (assembly code to object/binary code) - macros doesn't really change that.
The above also explains why translators from one machine language to another are also called 'compilers', not assemblers.. e.g. the just-in-time compilers used for Java bytecode, but also the compiler used for letting ARM-based Palm PDAs handle MC68K Palm programs (almost every Palm application was for MC68K, years and years after Palm switched to ARM).

-Tor


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 06, 2014 8:50 am 
Offline

Joined: Tue Jul 24, 2012 2:27 am
Posts: 679
Assemblers are a subset/specialization of compilers. "Compile" does not exclude "assemble". It is simply the transformation of one language form to another, typically from human-readable to machine-readable. Human-readable to human-readable compilers are usually called "code generators/translators/transformers", but are still just another type of compiler.

Assemblers are usually individual instruction translators, working independently on each instruction (labels & addressing ranges notwithstanding, same with macros as above); whereas other compilers can work on blocks of source code to figure out how to generate corresponding blocks of other-language instructions, say in the case of algebraic expressions or function paramater & return value handling.

_________________
WFDis Interactive 6502 Disassembler
AcheronVM: A Reconfigurable 16-bit Virtual CPU for the 6502 Microprocessor


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 06, 2014 9:26 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10980
Location: England
HansO wrote:
Some assemblers allow constructs that are way above the generally one-to-one correspondence and are indeed higher level constructs.
I'd be interested to see examples! I presume this is more than macro substitution - which clearly does raise the abstraction level a bit.

Slightly off topic, but see "How do British and American attitudes to dictionaries differ?"
http://blog.oup.com/2014/03/british-ame ... attitudes/
(No idea how this comparison fares for people who are neither British nor American. Essentially the point made is that Americans are more likely to consult a dictionary for meaning and to regard it as authoritative, whereas Brits are more likely to consult for "word loving" purposes. I would suppose also that Brits are less avid users of dictionaries, although I'm not sure that's said.)

Cheers
Ed


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 06, 2014 9:40 am 
Online
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
I wonder if the attitudes regarding dictionaries are related to the fact, if I understand it right, that one can quite accurately pinpoint what part of the Brittish Isles someone comes from by how they speak. (A big deal of this was made in the movie "My Fair Lady.") There are different accents in the States, but they are separated by longer distances, and there are probably fewer differences in actual vocabulary. When I was working in Spain, they said you could tell within 10km where someone was from, based on their accent. I could definitely hear the differences, but didn't know where they came from. Before radio and TV, the country was more isolated by mountains, such that each town's language evolved separately from other towns'. That's my understanding of it anyway.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 06, 2014 9:44 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10980
Location: England
It's true, both accent and dialect vary over relatively short distances, and betray both regional information and class information. But I like the point in the article: that American culture is highly aware of a written constitution, and other early documents, and treats the written word as more definitive, and looks to authorities. British culture less so.

Edit: possibly of interest, USA dialect and accent maps: http://www4.uwm.edu/FLL/linguistics/dia ... /q_15.html

Cheers
Ed


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 06, 2014 11:02 am 
Offline
User avatar

Joined: Fri Oct 31, 2003 10:00 pm
Posts: 200
BigEd wrote:
HansO wrote:
Some assemblers allow constructs that are way above the generally one-to-one correspondence and are indeed higher level constructs.
I'd be interested to see examples! I presume this is more than macro substitution - which clearly does raise the abstraction level a bit.


In Programming a Personal Computer, Per Brinch Hansen, besides the Edison programming language, a special language was described , the Alva language, that had the usual one-to-one assembler facility combined with higher level constructs for conditional statement blocks. I dont have access at the moment to the book (in another home!) , so forgive me not to give more details.

Another example is here: http://en.wikipedia.org/wiki/High_Level_Assembly


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 06, 2014 11:33 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10980
Location: England
Thanks!


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 06, 2014 5:49 pm 
Offline

Joined: Sat Aug 21, 2010 7:52 am
Posts: 231
Location: Arlington VA
I usually call both of those things (compiling, assembling) "building"


Top
 Profile  
Reply with quote  
PostPosted: Sat Jun 07, 2014 6:12 am 
Offline

Joined: Sat Jul 28, 2012 11:41 am
Posts: 442
Location: Wiesbaden, Germany
chitselb wrote:
I usually call both of those things (compiling, assembling) "building"

"building includes the process of "linking" multiple relocatable object files. A Linker is not needed, when the assembling or compiling process produces non relocatable images.

_________________
6502 sources on GitHub: https://github.com/Klaus2m5


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 11, 2014 8:37 pm 
Offline

Joined: Sun May 08, 2011 7:39 am
Posts: 104
Ah, semantics. A sure fire sign that we're getting old!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 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: