Needs moar one-line solution.

Code:
"".join(["0x"+instring[i:i+2] for i in range(0,len(instring),2)])

Also, I think your method fails due to only grabbing one character from the string instead of 2.
calc84maniac wrote:
Needs moar one-line solution.

Code:
"".join(["0x"+instring[i:i+2] for i in range(0,len(instring),2)])

Also, I think your method fails due to only grabbing one character from the string instead of 2.
Oh yeah, I forgot about that stupid offset. Thanks for catching that. Smile
All instructions are in hexadecimal. Or more accurately, all instructions are just values stored in memory that are best represented in base-16. Razz

I think you're a bit confused. It seems like you understand that basic concept that all instructions are essentially data that's run through an instruction decoder that specifies actions to be taken. You've got opcodes, and then you've got parameters to those opcodes. The whole thing together is taken as one instruction and each Z80 instruction can vary in width.

But if we're thinking just on the level of assembly code (not the machine code it represents), the $FFFF part of that instruction is called an immediate 16-bit parameter (or just imm16). I'm not familiar with Z80 machine code, but let's pretend in the documentation it says "ld hl,imm6" is [10101010][imm16]. The first field is the opcode and the second field is where you stick the 16-bit paramater (in this case, little-endian). I think you're just confusing the terms "immediate value" and "hexadecimal." "Hex" is more or less just a way to write a number, not the number itself.

---

ScoutDavid wrote:
So...

ld hl,$FFFF
ld hl,65535

Can both be done and are both possible?

Are there instructions that need to be Hexadecimal? And can't be written in decimal?


Whoops, I was 4 pages behind the discussion. This post was a response to that, lol.
Progbeard wrote:
Whoops, I was 4 pages behind the discussion. This post was a response to that, 0x5.
If you were four pages behind, I shudder to think what sort of necropost that would have been had there not been more recent discussion. Rolling Eyes

On the other hand, there seem to be users around whom still fail to understand your point(s), so it's not a useless necropost.. more of a reminder to some people.
Indeed; I feel like Scout has still not 100% grasped the difference between ASCII-encoded hex and the actual bytes, so feel free to carry on.
KermMartian wrote:
Indeed; I feel like Scout has still not 100% grasped the difference between ASCII-encoded hex and the actual bytes, so feel free to carry on.

Hey, we all started somewhere. Asking lots of questions is one of the best ways to learn. I think I can explain it in layman's terms.

The best analogy I can come up with to explain ASCII and data in general is this. When you write the date, you probably write it in the format MM/DD/YY, depending on where you live. You'll probably agree that almost anyone who sees that will recognize it as a date. 03/02/11 could be thought of as three bytes, which stand for "March", "2nd", and "2011" respectively. Your buddy in Europe might follow a different standard and understand it as "February 3rd, 2011". Ultimately, data means different things based on who is reading the data. The idea that the decimal value 3 in the months place (by your standards) stands for "March" is a lot like ASCII in that a value is mapped to somehing that gives it meaning, otherwise it's seen as just another value. The ASCII standard maps a byte to a printable (ABC's, 123's, punctuation, etc), format (tab, linebreak, etc) , or control (beep, end-of-file, etc) character (just Google 'ascii table'). If there was no standardized format, you'd be SOL.

Fight the urge to see data as anything more than numbers. I mean, you should, but you need to keep in mind at all times that characters on a screen are just the product of a program interpreting ASCII codes, nothing more. Lemme ninja a delicious quote from AsmIn28, "Data is what you make of it" (or something like that).

Once you got the whole data-is-data-is-data-is-data chant down, go one step further: code is data. There's nothing innate in data that's going to keep your CPU from executing it. You can throw random bytes into userMem and start executing if you wanted, but I would not recommend it. For all intents and purposes, RAM holds values only, and what you do with those values is what gives it meaning.

Sorry if I broke that down too much. But if you didn't get it before you do now. Very Happy Have fun, and share this disassembler with us when you're done.
That's an excellent explanation, Progbeard! Very nicely done; we need more people with long, well-thought-out, well-expressed posts like you in the community. Smile I'm glad to see another intelligent ASM coder join the ranks of Cemetech ASM coders. Hopefully that will help Scout; I think he's been struggling with that distinction, and the language barrier (he natively speaks Portuguese) doesn't help.
Thanks man.

Don't expect to understand everything at once. All these concepts were new to every Asm coder at some point. I'd be surprised if any of us didn't start out Output('ing O's to the homescreen in a BASIC game. XD
Funnily enough, I distinctly remember writing BASIC animations that worked by repeatedly drawing massive numbers of 'I's to the homescreen and ClrHome'ing, and being very impressive with myself for the results. That was seventh grade, and I'm now in 18th grade, so that was a whole twelve years ago!
KermMartian wrote:
Funnily enough, I distinctly remember writing BASIC animations that worked by repeatedly drawing massive numbers of 'I's to the homescreen and ClrHome'ing, and being very impressive with myself for the results. That was seventh grade, and I'm now in 18th grade, so that was a whole twelve years ago!


And you jumped from there to making Doors CS...?
Yup, I started Doors CS as Doors XP about two years after that, in my Freshman year of high school. Smile
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 4 of 4
» All times are UTC - 5 Hours
 
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 vote in polls in this forum

 

Advertisement