What's a better language for someone that remembers numbers better than letters, Assembly or Machine code
Assembly
 92%  [ 23 ]
Machine code
 8%  [ 2 ]
Total Votes : 25

I'm much better at remembering numbers than letters. I feel like learning Machine Code would be easier for me than Assembly. Is this a good idea for me? Is there any tutorials on z80 Machine language.
Short answer: No
Long answer: Nooooooooooooooooooooooooooooooooooooooo.

What you're talking about is the data that is generated by your assembler from your original human-readable ASM code, the data that is executed directly by the z80 processor. Some heathens insist on giving this translated code the totally incorrect and vague name "HEX", if you've seen references to that elsewhere on the forum. Human-readable assembly code is used for a good reason: it's much, much easier to read and understand that the CPU-readable code, it's much easier to modify after you first write it, and other programmers will be able to understand your code. Once you assemble your code into machine code, it is nigh unmodifiable without a lot of headaches, and I very, very strongly recommend against it. A better approach would be to ask us whatever questions would help you where you're stuck in learning z80 assembly.
And besides you aren't learning random sequences of letters; you are learning letters associated into things that are meant to be remembered as they are associated with the thing they do.
For example; this is a simple Hello World Program:

Code:

219F9D // LD HL, 9D9F
EF0A45 // BCALL _PutC
EF2E45 // BCALL NewLine
C9 // RET
48656C6C6F2C20576F726C642100 // DB "Hello, World!", 0

And you think you will just memorize all this junk?
In other words, what zeldaking is trying to say is that it's at least as hard (and in fact much harder) to memorize the numbers than their word equivalents. You also need to do tons of math in your head or on paper to compute addresses, relative jump offsets and absolute jump targets, the length of each line of code in bytes, and so on. An assembler performs all of that work for you, making it much less painless to write ASM programs and much less likely that you'll make human errors while "assembling" the code by hand.
Kerm's points are quite valid, CPU-readable code is named as such for the obvious reason that it is meant for a CPU. Where-as you might be able to remember the opcode values in numerical form easy enough (lots of people do know this), developing a large program by programming this way would be a nightmare.

And then there is linking ...
KermMartian wrote:
In other words, what zeldaking is trying to say is that it's at least as hard (and in fact much harder) to memorize the numbers than their word equivalents. You also need to do tons of math in your head or on paper to compute addresses, relative jump offsets and absolute jump targets, the length of each line of code in bytes, and so on. An assembler performs all of that work for you, making it much less painless to write ASM programs and much less likely that you'll make human errors while "assembling" the code by hand.


I have a habit of making the spaces, indents, and tabs in Assembly perfect. I don't think Machine code, which is binary, has these annoying spaces, indents, and tabs. Also, i'm a pretty slow typer. I don't have any problem with math. I love math and pretty good with it. Is Assembly still less painless for me?
The answer is no. Machine language is a headache to try and use when you are even doing basic things, and all that you are really doing is memorizing the hex values, which is pointless because you would have to learn assembly anyway in order to use those values. Learn assembly! It really is not that bad! Smile
I'm having trouble with the following example Assembly code in "learn ti 83 plus assembly in 28 days" in Day 28:


Code:

.nolist
#include "ti83plus.inc"
#include "dcs7.inc"
.list
.org progstart
   .db $BB,$6D
Start:
 #define BUFSIZE   48
buffer      .EQU   TextShadow
buf_ptr      .EQU   buffer + BUFSIZE + 1
   CALL   Clear
Restart:
   LD      HL, Restart
   PUSH   HL
   CALL   GetStr
   CALL   GetChar
   JP      C, ErrCommand
   SUB      'A'
   JP      C, ErrCommand
   CP      'Z'-'A'+1
   JP      NC, ErrCommand
   ADD      A, A
   LD      HL, CmdVectors
   LD      D, 0
   LD      E, A
   ADD      HL, DE
   b_call(_LdHLInd)
   JP      (HL)
   
GetStr:
   RES      AppTextSave, (IY + AppFlags)
   LD      HL, buffer      ; Init pointer
   XOR      A
   LD      B, A         ; Init character counter
   LD      (CurCol), A
GetChar:
   PUSH   HL
   LD      HL, (buf_ptr)   ; buf_ptr is our pointer variable
   LD      A, (HL)
   OR      A
   SCF                  ; Set carry to indicate error status
   JR      Z, GetChar_Done
   
   INC      HL
   LD      (buf_ptr), HL
   OR      A            ; Reset carry to indicate success status
   
GetChar_Done:
   POP      HL
   RET
   
Clear:
   b_call(_ClrScrnFull)
   b_call(_HomeUp)
   RET
   
Quit:
   POP      AF
   JR      Clear
   
ErrCommand:
   b_call(_NewLine)
   LD      HL, errcmd_text
   b_call(_PutS)
   b_call(_NewLine)
   RET
errcmd_text:
   .DB      "ERR: Command", 0
   
CmdVectors:
.DW      ErrCommand   ; A -
.DW      ErrCommand   ; B -
.DW      Clear      ; C - Clear screen
.DW      ErrCommand   ; D -
.DW      ErrCommand   ; E -
.DW      ErrCommand   ; F -
.DW      ErrCommand   ; G -
.DW      ErrCommand   ; H -
.DW      ErrCommand   ; I -
.DW      ErrCommand   ; J -
.DW      ErrCommand   ; K -
.DW      ErrCommand   ; L -
.DW      ErrCommand   ; M -
.DW      ErrCommand   ; N -
.DW      ErrCommand   ; O -
.DW      ErrCommand   ; P -
.DW      Quit      ; Q - Quit program
.DW      ErrCommand   ; R -
.DW      ErrCommand   ; S -
.DW      ErrCommand   ; T -
.DW      ErrCommand   ; U -
.DW      ErrCommand   ; V -
.DW      ErrCommand   ; W -
.DW      ErrCommand   ; X -
.DW      ErrCommand   ; Y -
.DW      ErrCommand   ; Z -
.end
END
Stating what the problems are, such as compiler errors, etc. will help us out when we are trying to help you out.
The code compiles successfully, but runs differently then what the tutorial says.
Alright; what is the expected output and what output are you getting?
I made this point in another topic, but I'll make it again here:
If you absolutely bizarrely insist on learning machine code, learn it in binary, not hex. Opcodes actually have structure to them - they aren't just randomly selected numbers, and the structure isn't necessarily 4-bit aligned, meaning it will be obscured by hex.

The primary downside is that you lose labels, which means your code really really can't be reorganized cleanly.
zeldaking wrote:
Alright; what is the expected output and what output are you getting?

Look in "Learn z80 assembly in 28 days" for the expected output.
Ephraim B wrote:
zeldaking wrote:
Alright; what is the expected output and what output are you getting?

Look in "Learn z80 assembly in 28 days" for the expected output.

If there is any way for us to help you, it would probably be nice to help us out in return. I would help you, but I don't want to find the files, download them, read it, find the code and go from there..
Soo if you want people to help you.. its best if you include all the information here
How hard is it to say its supposed to say "Hello world" or its supposed to draw a maze. or its supposed to bake me cookies.

Also it says "goodbye world" Draws a cookie, and makes me a maze.


>.>
Is there any tutorials for z80 machine code so I can give it a try.
Ephraim B wrote:
Is there any tutorials for z80 machine code so I can give it a try.


No, it's literally exactly the same instructions as assembly, you just don't get labels or anything friendly. Read the assembly tutorials with a copy of the z80 instruction set listing open so you can see what the machine code for each line is.
What are the GetStr and GetChar procedures in z80 Assembly and where do I put them?
You'll have to count the address to them by hand if you're writing machine code instead of assembly.
If you mean to input text or characters, you'll need to write your own routine for that or use one someone else has written. There are plenty available on ticalc.org, Phoenix for example has an input routine and is in the Public Domain so you can take the code directly and play with it and do whatever you want with it.

In this topic there's a sample routine to input numbers:
http://www.cemetech.net/forum/viewtopic.php?t=9549&start=0

You might be interested in checking out some of Xeda's stuff:
http://www.ticalc.org/archives/files/fileinfo/434/43467.html
http://www.ticalc.org/archives/files/fileinfo/434/43489.html
http://www.ticalc.org/archives/files/fileinfo/424/42401.html

...but really you should just learn the mnemonics. It's so much easier. And as elfprince mentioned, it'd make much more sense to learn the opcodes in binary, not hex. The opcodes don't always divide evenly into nibbles, actually i don't know if they ever really do. For example, take the ld instruction:
%01[reg8D][reg8S]
Each register is marked with three bits, so you have: %01DD DSSS, which clearly doesn't fit into the nibble boundary. The binary representation makes much more sense than the hex representation. And even if you learn the hex opcodes, you'll still be thinking "Ok, so this adds register 001 to register 111, so that's %01 111 001". I think "add a,c" is much simpler and what you'll be thinking anyway.
  
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 1 of 2
» 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