Showing posts with label assembly. Show all posts
Showing posts with label assembly. Show all posts

Sunday, June 3, 2018

Coding

I love to code. Its as simple as that. If I had a job where I couldn't code, I probably wouldn't stay in that job very long.

I don't especially care what the language is because I can figure it out (with my pal Google). I've coded in a lot of different languages. I'm sure there are more than this but these are the ones I can think of off the top of my head: Basic, Assembly, Pascal / Delphi, Today, Progress, Cobol, dBase, Hibol, C, C++, C#, VB, VBScript, VB.Net, Java, JavaScript, Perl, PowerShell, PHP, Various other "shell" batch languages

I loved doing Assembly when I was deep into it (many, many moons ago). The system was there for all to see and I was tweaking the heck out of it. I doubt that I would know where to begin on a 'modern' system.

I'm not sure that I have a favorite language. If I'm going to do something web based then I would probably choose PHP (with lots of JavaScript). If I'm going to do something Windows based then its probably going to be C#. If I just need a script then most likely it will be PowerShell or Bash (depending on the OS :)).

My advice to you, learn all you can and follow your passion. The more you know, the more valuable you are and the more hire-able you will be.

Tuesday, March 10, 2009

Assembly is Fun!

It has been a LONG time since I seriously wrote any 6502 Assembly code, but I used to do it all the time.  I would write it out on paper first then type it in once I had it where I thought I wanted it.  Paper made it alot easier to see everything all at once (due to the tiny screens in the old days).  I think I still have a page or two of hand written code.  If I find it I'll scan and post it just for fun.

So, I was playing with this site: http://www.6502asm.com/

And decided to take an old Apple ][ Assembly program I wrote EONS ago and adapt it to work on that site.  Got it to work pretty well and even submitted it for their examples page.  I do have a Game Of Life I wrote once that I want to try and adapt, but not today :)

If you write anything cool, let me know.

Saturday, February 28, 2009

Here is some old code for you...

The Apple ][ computer didn't have super fancy graphics.  They had a portion of memory mapped to the graphic screen.  Since I don't really feel like trying to explain it here because others have done it far better than I could read this: http://en.wikipedia.org/wiki/Apple_II_graphics   Specifically the Hires Graphics section.

Now, I had a need to be able to scroll the Hires Screen left or right.  Thanks to a series of articles by David Lubar in Creative Computing called The Graph Paper (October 1982 -> March 1983) and an article called Lookup Tables (March 1982) I had a very good understanding of how each byte in memory made up the picture that was displayed so I wrote the following code using the SC Macro Assembler.  This version of the code did the scroll left.

The 'Lookup Table' allowed me to access each line of the hires screen directly and in order (since the screen was 'interlaced').

BTW, comments are for losers. :)

1000        .OR $6000
1010        .TF SCROLLLEFT
1020        .LIST OFF
1030        JMP HERE
1040 TABLHI .HS 2024282C3034383C
1050        .HS 2024282C3034383C
1060        .HS 2125292D3135393D 
1070        .HS 2125292D3135393D
1080        .HS 22262A2E32363A3E
1090        .HS 22262A2E32363A3E
1100        .HS 23272B2F33373B3F
1110        .HS 23272B2F33373B3F
1120        .HS 2024282C3034383C 
1130        .HS 2024282C3034383C
1140        .HS 2125292D3135393D 
1150        .HS 2125292D3135393D
1160        .HS 22262A2E32363A3E
1170        .HS 22262A2E32363A3E 
1180        .HS 23272B2F33373B3F
1190        .HS 23272B2F33373B3F
1200        .HS 2024282C3034383C 
1210        .HS 2024282C3034383C
1220        .HS 2125292D3135393D
1230        .HS 2125292D3135393D
1240        .HS 22262A2E32363A3E 
1250        .HS 22262A2E32363A3E
1260        .HS 23272B2F33373B3F
1270        .HS 23272B2F33373B3F
1280 TABLLO .HS 0000000000000000
1290        .HS 8080808080808080
1300        .HS 0000000000000000
1310        .HS 8080808080808080
1320        .HS 0000000000000000 
1330        .HS 8080808080808080 
1340        .HS 0000000000000000
1350        .HS 8080808080808080
1360        .HS 2828282828282828
1370        .HS A8A8A8A8A8A8A8A8
1380        .HS 2828282828282828
1390        .HS A8A8A8A8A8A8A8A8 
1400        .HS 2828282828282828 
1410        .HS A8A8A8A8A8A8A8A8 
1420        .HS 2828282828282828 
1430        .HS A8A8A8A8A8A8A8A8 
1440        .HS 5050505050505050
1450        .HS D0D0D0D0D0D0D0D0
1460        .HS 5050505050505050 
1470        .HS D0D0D0D0D0D0D0D0 
1480        .HS 5050505050505050 
1490        .HS D0D0D0D0D0D0D0D0
1500        .HS 5050505050505050 
1510        .HS D0D0D0D0D0D0D0D0 
1520 HERE   STA $C050 
1530        STA $C057
1540        STA $C054
1550        STA $C052
1560        LDX #$00
1570 A7     LDA TABLLO,X  
1580        STA $F0
1590        LDA TABLHI,X
1600        STA $F1
1610        CLC
1620        LDY #$27
1630 A6     LDA ($F0),Y
1640        ROL
1650        BCC A1
1660        ROR
1670        BCC A2
1680        SEC
1690        ROR
1710        JMP A3
1720 A2     ROL
1730        CLC
1740        ROR
1750        SEC
1760        ROR
1770        JMPA3
1780 A1     ROR
1790        BCC A4
1800        ROL
1810        SEC
1820        ROR
1830 A4     ROR
1840 A3     STA ($F0),Y
1850        ROR
1860        DEY
1870        BMI A5
1880        ROL
1890        JMP A6
1900 A5     INX
1910        CPX #$C0
1920        BNE A7
1930        RTS

And the code to scroll right looks like this:

1000        .OR $6000
1010        .TF SCROLLRGHT
1020        .LIST OFF
1030        JMP HERE
1040 TABLHI .HS 2024282C3034383C
1050        .HS 2024282C3034383C
1060        .HS 2125292D3135393D 
1070        .HS 2125292D3135393D
1080        .HS 22262A2E32363A3E
1090        .HS 22262A2E32363A3E
1100        .HS 23272B2F33373B3F
1110        .HS 23272B2F33373B3F
1120        .HS 2024282C3034383C 
1130        .HS 2024282C3034383C
1140        .HS 2125292D3135393D 
1150        .HS 2125292D3135393D
1160        .HS 22262A2E32363A3E
1170        .HS 22262A2E32363A3E 
1180        .HS 23272B2F33373B3F
1190        .HS 23272B2F33373B3F
1200        .HS 2024282C3034383C 
1210        .HS 2024282C3034383C
1220        .HS 2125292D3135393D
1230        .HS 2125292D3135393D
1240        .HS 22262A2E32363A3E 
1250        .HS 22262A2E32363A3E
1260        .HS 23272B2F33373B3F
1270        .HS 23272B2F33373B3F
1280 TABLLO .HS 0000000000000000
1290        .HS 8080808080808080
1300        .HS 0000000000000000
1310        .HS 8080808080808080
1320        .HS 0000000000000000 
1330        .HS 8080808080808080 
1340        .HS 0000000000000000
1350        .HS 8080808080808080
1360        .HS 2828282828282828
1370        .HS A8A8A8A8A8A8A8A8
1380        .HS 2828282828282828
1390        .HS A8A8A8A8A8A8A8A8 
1400        .HS 2828282828282828 
1410        .HS A8A8A8A8A8A8A8A8 
1420        .HS 2828282828282828 
1430        .HS A8A8A8A8A8A8A8A8 
1440        .HS 5050505050505050
1450        .HS D0D0D0D0D0D0D0D0
1460        .HS 5050505050505050 
1470        .HS D0D0D0D0D0D0D0D0 
1480        .HS 5050505050505050 
1490        .HS D0D0D0D0D0D0D0D0
1500        .HS 5050505050505050 
1510        .HS D0D0D0D0D0D0D0D0 
1520 HERE   STA $C050 
1530        STA $C057
1540        STA $C054
1550        STA $C052
1560        LDX #$00
1570 A7     LDA TABLLO,X  
1580        STA $F0
1590        LDA TABLHI,X
1600        STA $F1
1610        CLC
1620        LDY #$00
1630 A6     LDA ($F0),Y
1640        ROL
1650        BCC A1
1660        ROL
1670        BCC A2
1680        SEC
1690        ROR
1700        SEC
1710        BCS A3
1720 A2     SEC
1730        ROR
1740        CLC
1750        BCC A3
1760 A1     ROL
1770        BCC A4
1780        CLC
1790        ROR
1800        SEC
1810        BCS A3
1820 A4     CLC
1830        ROR
1840        CLC
1850 A3     STA ($F0),Y
1860        ROR
1870        INY
1880        CPY #$28
1890        BEQ A5
1900        ROL
1910        JMP A6
1920 A5     INX
1930        CPX #$C0
1940        BNE A7
1950        RTS

The code is very close but there are some important differences (like line 1620, 00 starts on the left of the line and #27 starts on the right of the line).

Now, you may ask, Why did I bother posting this?  Because I could and I felt like sharing.  I do have some old notebook pages I found with some hand written code on them that I'm going to scan in and post here at some point in the near future.

Ah, the old days...

So, long ago I was deep into Apple ][ computers. I could hand code assembly directly into the monitor (until I got my hands on SC Macro Assembler).. A time when Boot Code tracing was the best way to get into the guts of a game and when windows were things you looked out of.

My buddy and I would figure out some cool piece of code and then share it. Each of us trying to be better than the other.

Once I figure out an easy way to link to some of the stuff we wrote, I'll post links to .bin files that will run in any Apple ][ emulator. Sure, its not up to today's standards but for the time it was pretty cool (20+ years ago!).

I miss the simplicity of the code & operating systems. Today's OSes just have way too much bloat.
Ah well... everything must pass to dust eventually
Copyright Realm Laboratories, LLC