6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Sep 22, 2024 9:37 am

All times are UTC




Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Mon Aug 24, 2020 3:31 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1948
Location: Sacramento, CA, USA
Quote:
By global state... Do you mean global variables that I create? Or do you mean areas of memory that I utilize?
Yes ;-) In theory, global state refers to all RAM, ROM and I/O devices that can be read from and/or written to by the microprocessor. In practice, it refers to the subset of addresses referenced in the scope of your program's execution. With no pesky memory management hardware to get in your way, you are pretty much free to do whatever you want.

_________________
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 24, 2020 4:22 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Among the great leaps forward in computer programming are type safety, data encapsulation, and data hiding. And we don't get any of that when working at assembly level. I think some of us who enjoy working at a low level like the feeling that we're dealing with things as they are, with the minimum of abstraction. But I think everyone would agree that the assembly language programmer will be less productive: everything is more difficult. There are potential advantages in performance, density, efficiency, which rarely make it worthwhile in the commercial world.


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 24, 2020 4:50 pm 
Offline

Joined: Wed Aug 12, 2020 2:30 am
Posts: 43
BigEd wrote:
Among the great leaps forward in computer programming are type safety, data encapsulation, and data hiding. And we don't get any of that when working at assembly level. I think some of us who enjoy working at a low level like the feeling that we're dealing with things as they are, with the minimum of abstraction. But I think everyone would agree that the assembly language programmer will be less productive: everything is more difficult. There are potential advantages in performance, density, efficiency, which rarely make it worthwhile in the commercial world.

I agree. One of the things I'm unlearning is the tendency to group related things together, like a class in a high language.
That being said... I am having a blast learning C64 assembly. It's bringing back very fond memories.


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 24, 2020 4:58 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Yes, it's fun to do! And there's an immediate reward in fixing a bug, or getting something working.


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 24, 2020 6:21 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8510
Location: Southern California
BigEd wrote:
I wonder if learning to program with FORTRAN, or on a programmable calculator, would be a much more appropriate precursor to assembly language, compared to experience with a high level language like C, C++, Java, and so on.

A programmable calculator, a TI-58c with keystroke programming, was my entrance to programming, in 1981. Within a few weeks, I was taking a class in 6502 assembly language and another one in FORTRAN, but I had already spent scores of hours learning the calculator and writing my own programs for it, and it led rather naturally into 6502 assembly language. I wrote about it in the side bar to my article on assembly language still being relevant today, at http://wilsonminesco.com/AssyDefense/#calc . In the same grain, see "Using a Programmable Calculator to Introduce Fundamental Concepts of Assembly Language" by H. D. Schwetman in the computer-science department of Purdue University, CSD TR 171, December 1975, 28 pages.

You can do a lot of abstraction in assembly language by using macros, but you would still need to understand what's going on at a down-to-the-metal level; it's just that once you've written and debugged your macros, you don't have to look at the ugly internal details every time you use them.

_________________
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: Mon Aug 24, 2020 11:07 pm 
Offline

Joined: Tue Jul 24, 2012 2:27 am
Posts: 674
DanielS: Functional abstraction, modularity, and such is absolutely possible in assembly language, even with just a light layer of macros to manage things. But, given that the context is the Commodore 64 and not some 14-100MHz newer variant, 1MHz is not a lot (~15k-18k cycles available per frame, visible using raster bars for profiling), and 64KB is not a lot when you start writing code in such a fashion. You hit walls very quickly after you get such a framework bootstrapped.

Hence, things trended to the shortest and fastest way in competitive development (commercial, demoscene, etc), which is to directly access known memory locations in a static layout, using only up to 1 level of indirection through static-location vectors, as the baseline development style. Venturing further than that comes at noticeable cost, but that tradeoff certainly can be appropriate for the higher-complexity end of things. Just don't start there, build up to it. ;)

IMO, the best way to get into the mindset of the time is to read source code listings & dive into disassemblies. All the C64 ROMs sources/disassemblies are commented online in various forms, and you can see some of the static layout techniques in play.

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


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 24, 2020 11:19 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 890

BigEd wrote:
I would in fact suggest that macros are potentially confusing you: that the beginner should write a fair amount of plain code before venturing into the use of macros. Their productivity and the efficiency of their code will then improve - macros are great, but possibly not the first thing to learn.

I agree. I don't know where you are on your journey of learning so you may already know the following.
You could try "exercising" your assembly language routines from an interpreted high level language.
I personally like testing assembly language routines called CODE words from Forth's interpreter.
Since you are using the Commodore 64, you can do something similar with BASIC.
The memory from $C000 through $CFFF is not touched by BASIC. If you assemble a routine to start at $C000, you can call it from BASIC ( either in a program or interactively ) with
SYS 49152
When BASIC transfers control to your assembly routine it will first store the values in the memory locations 780, 781, and 782 in the accumulator, the x register and the y register. When your routine reaches the RTS and returns control to BASIC, the contents of the accumulator, the x register and the y register will be stored in memory locations 780, 781, and 782.
Hope this helps.


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 25, 2020 10:51 am 
Offline
User avatar

Joined: Sat Dec 01, 2018 1:53 pm
Posts: 727
Location: Tokyo, Japan
DanielS wrote:
By global state... Do you mean global variables that I create? Or do you mean areas of memory that I utilize?

These are the same thing, really. If you declare HEAPBASE to be locations $20-$21, you can consider that a "global variable" that everything in your system has access to and many things may use; there'd typically be no point in making copies of that and passing it around. If you declare TMP0 to be locations $30-$31, you might consider that to be something for temporary internal use by any routine that declares it does so, and you must be careful that one routine that uses it doesn't call another routine that uses it without saving its own copy of the data there first, if it still needs it after the call. This isn't something you'd think of as a "global variable," but of course, being just memory locations, it's still something that any code has access to.

Assembly is a bit like BASIC in a way: there's no such thing as a truly "local" variable except what you push on the stack (and you need to make sure you pull those data off before you execute a RET).

_________________
Curt J. Sampson - github.com/0cjs


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

All times are UTC


Who is online

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