Author Topic: Hexadecimal Assembly Programming  (Read 22008 times)

0 Members and 1 Guest are viewing this topic.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Hexadecimal Assembly Programming
« on: January 22, 2011, 09:02:57 am »
I decided to create a topic for general discussion about general Hexadecimal Assembly programming. It is also a small tutorial and introduction.

What is hexadecimal?

Hexadecimal is a numeration system just like the Arabic one (1,2,3,4,5,6,7,8,9.5,11,12,...) or the Roman one (I,II,III,IV,V,X,L,MCM,...).
So, a number like seven can have multiple representations, according to the system used, let's check the number 28:

Code: [Select]
28          // Arabic
XXVIII    // Roman
1C        // Hexadecimal
11100  // Binary

So, why don't we all use the same? It's hard for all of us to use the same and some are useful in some situations but terrible in others. For example, to make a sprite we use binary or hexadecimal, but to solve a giant equation using any of those would be a pain in the ass!

Now, when we make a Calculator Assembly program (ld hl,1 ....), it is written as a binary file (10010101011110101010...). Binary is hard to read, so we just use Hexadecimal.

So, why don't we just program in Assembly and leave the Hexadecimal alone?

If we know how to code in Hexadecimal instead of using an assembler that makes our assembly code hexadecimal, we can program assembly on the calculator. Of course, with Mimas (and some others) we can also do it, and Mimas is quite good. However, I'm not sure if we can all use Mimas or if it has everything there is.

So, I assume you already know Assembly if you're reading this, and here's an Assembly program:

Code: [Select]
.nolist
#include "ti83plus.inc"
.list
    .org $9D95-2
    .db $BB, $6D

Start:
  B_CALL (_ClrLCDFull)
  ld hl,1
  B_CALL (_DispHL)
  B_CALL (_GetKey)
 
  ret

This program will Clear the Screen, the set the hl registers to 1, then display "1" and wait for a key press until ending.

The hexadecimal code it creates (the data) is something like:

Code: [Select]
EF4045  // ClrLCDFull
210100  // Set hl registers to 1
EF0745  // Display the hl registers, so display "1"
EF7249  // Wait for key press
C9

Now, how do I know this is the hexadecimal code for it? One, I checked the ti83plus.inc, I use Assemblex and I learnt it with Xeda. Now, the ti83plus.inc has all the hexadecimal codes for BCalls. Assemblex converts hexadecimal to assembly and disassembles files which lets me learn it from other programs.

Also, for opcodes such as 210100, I check this all the time!

How to program in my calculator?

Press PRGM
Create a new PRGM
Call it whatever you want
Then make it like this:

Code: [Select]
AsmPrgm
EF4045
EF7045 // Turns the run diagnostic off  B_CALL (_RunIndicOff)
FDCB00AE  // Disables the 'Done' message when the program closes (res 5,(iy+0))
210100
EF0745
EF7249
C9




Never forget the ending C9 (ret), without it the calculator crashes!

Now you can run that program by typing Asm(prgmNAME.

You can also compile it so you can run it in shells and it is a true Assembly program: AsmComp(prgmNAME,prgmNAME2)

Note, in AsmComp( the names have to be different. Also, press 2ND + 0 to access the catalog and use the Asm( and AsmPrgm and AsmComp( tokens, don't just type them.

I hope more discussion comes, for now, skim through the pages I gave you and try and make something new.

Note: The language on this tutorial may be wrong. For example, I said that AsmComp( made it a real Assembly program, but it was already, it just compiles it.

Also, concerning Assemblex, the last uploaded version is still not perfect, so you can have a demo here, but the 'Export to 8xp' isn't finished, so it does not count as an upload. Assemblex is what I use to program in Hexadecimal in my computer.

Discuss!

EDIT: You can also use brandonw's website for more bcalls and information, I think. The Z80 tables with opcodes can also be found in ticalc.org.


EDIT 2:
I have a lot to tell you yet, but for now, here's another program:

Code: [Select]
EF4045
3E01
C60A
2600
6F
EF0745
EF7249
EF4045
C9

Who guesses what this does?
« Last Edit: January 22, 2011, 01:31:12 pm by Scout »

Offline Binder News

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 785
  • Rating: +46/-3
  • Zombie of Tomorrow
    • View Profile
Re: Hexadecimal Assembly Programming
« Reply #1 on: January 22, 2011, 09:47:26 am »
Very useful. Definite bookmark!
Spoiler For userbars:







Hacker-in-training!   Z80 Assembly Programmer     Axe Programmer
C++ H4X0R             Java Coder                           I <3 Python!

Perdidisti ludum     Cerebrum non habes

"We are humans first, no matter what."
"Fame is a vapor, popularity an accident, and riches take wings. Only one thing endures, and that is character."
Spoiler For Test Results:





Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Hexadecimal Assembly Programming
« Reply #2 on: January 22, 2011, 01:40:08 pm »
Very useful. Definite bookmark!

Thanks much!

I edited with another program ;D
« Last Edit: January 22, 2011, 01:41:03 pm by Scout »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Hexadecimal Assembly Programming
« Reply #3 on: January 22, 2011, 01:50:28 pm »
Want another chart I like to use?!? This is one I made after I learned assembly...
And I'm glad you're helping to spread the plague-- er, fun!

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Hexadecimal Assembly Programming
« Reply #4 on: January 22, 2011, 02:23:42 pm »
Nice chart Xeda! I really like the way it looks! You should check mine and get the unofficial instructions and the IX and IY tables. Also the IX bits and IY bits tables and put them in yours. I did not fully make all of those, though. Runer made two of those, I just don't remember which.

Offline holmes221b

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 282
  • Rating: +13/-1
  • RESISTANCE IS FUTILE.
    • View Profile
    • My Livejournal
Re: Hexadecimal Assembly Programming
« Reply #5 on: January 22, 2011, 02:24:54 pm »
What file type is xls? I don't recall ever seeing that one before...
* holmes221b wants to download it to start teaching herself how to program in HEX, but isn't sure if it's in a format she can read

Spoiler For "Projects":
Spoiler For "Because Everyone Else Is":
*Sigh*
can we keep this on topic? The topic is about what the big thing might be, NOT SEX

Offline FinaleTI

  • Believe in the pony that believes in you!
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1830
  • Rating: +121/-2
  • Believe in the pony that believes in you!
    • View Profile
    • dmuckerman.tumblr.com
Re: Hexadecimal Assembly Programming
« Reply #6 on: January 22, 2011, 02:26:01 pm »
What file type is xls? I don't recall ever seeing that one before...
* holmes221b wants to download it to start teaching herself how to program in HEX, but isn't sure if it's in a format she can read
It's an Excel spreadsheet, but I think it'll open in OpenOffice as well.


Spoiler For Projects:

My projects haven't been worked on in a while, so they're all on hiatus for the time being. I do hope to eventually return to them in some form or another...

Spoiler For Pokemon TI:
Axe port of Pokemon Red/Blue to the 83+/84+ family. On hold.

Spoiler For Nostalgia:
My big personal project, an original RPG about dimensional travel and a few heroes tasked with saving the world.
Coding-wise, on hold, but I am re-working the story.

Spoiler For Finale's Super Insane Tunnel Pack of Doom:
I will be combining Blur and Collision Course into a single gamepack. On hold.

Spoiler For Nostalgia Origins: Sky's Story:
Prequel to Nostalgia. On hold, especially while the story is re-worked.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Hexadecimal Assembly Programming
« Reply #7 on: January 22, 2011, 02:26:22 pm »
What file type is xls? I don't recall ever seeing that one before...
* holmes221b wants to download it to start teaching herself how to program in HEX, but isn't sure if it's in a format she can read

It's Excel file, opened with Microsoft Excel, which can be either bought or used online for free in a limited way (Google Chrome+Hotmail Account).

www.davidgom.co.cc/z80table.html The tables are also there, online.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Hexadecimal Assembly Programming
« Reply #8 on: January 22, 2011, 02:29:15 pm »
Yeah, I've checked yours... me likes :D
Oh, um, yeah, I made it with Open Office...

Offline holmes221b

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 282
  • Rating: +13/-1
  • RESISTANCE IS FUTILE.
    • View Profile
    • My Livejournal
Re: Hexadecimal Assembly Programming
« Reply #9 on: January 22, 2011, 03:15:21 pm »
Well, I do have Excell...It's been a long while since I've done anything in Excell, so no wonder I've forgotten the file extension...xD

Spoiler For "Projects":
Spoiler For "Because Everyone Else Is":
*Sigh*
can we keep this on topic? The topic is about what the big thing might be, NOT SEX

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Hexadecimal Assembly Programming
« Reply #10 on: January 22, 2011, 04:23:01 pm »
Well, I do have Excell...It's been a long while since I've done anything in Excell, so no wonder I've forgotten the file extension...xD

Oh I see, Excel is quite useful for this kind of tables, though.

So, anybody already knows (not you, Xeda) what the final program of my code does?

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Hexadecimal Assembly Programming
« Reply #11 on: January 22, 2011, 05:57:51 pm »
Pssh, that is SO unoptimised... :P
(but it is for an example, so I guess it's okay :D)

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Hexadecimal Assembly Programming
« Reply #12 on: January 22, 2011, 05:59:45 pm »
Code: [Select]
EF4045
3E01
C60A
2600
6F
EF0745
EF7249
EF4045
C9

It could be optimized to:

Code: [Select]
EF4045
210B00
EF0745
EF7249
EF4045
C9

However, it would lose the point of the challange.
« Last Edit: January 22, 2011, 06:08:26 pm by Scout »

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Hexadecimal Assembly Programming
« Reply #13 on: January 22, 2011, 06:04:40 pm »
Scout, no one is going to be able to remove their finger from the keypad quickly enough for that not to execute through :P

EDIT: Now write it without system calls  >:D
« Last Edit: January 22, 2011, 06:05:20 pm by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Hexadecimal Assembly Programming
« Reply #14 on: January 22, 2011, 06:09:54 pm »
Been there. Done that. It is fun.