I assume you want the answer to be in the beginner's class, so here we go:
Back in the day, you could either buy an assembler made by someone else, or you could code with paper and pen first. Most people coded with paper and pen to start with.
There's no Z80 statement for LD HL,BC so that has to be LD H,B LD L,C. Then we find the value for that instruction in Appendix A of the user manual: ZX81 Basic Programming. So our paper begins with:
Code: Select all
Assembler : Code
..........:......
LD H,B : 96
LD L,C : 105
LD HL,(BC) has no instruction on the Z80 either, so we make it in more steps. The HL register is used very much so we create the content for HL in the DE register, and swap them in the end. And HL is the only register that can be used indirectly e.g. (HL), so we use that instead of BC. Back to paper:
Code: Select all
Assembler : Code
..........:......
LD E,(HL) : 94
INC HL : 35
LD D,(HL) : 86
EX DE,HL : 235
If this was the actual code it wouldn't make much sense as we have just overwritten the content of HL we just created on paper above.
In the last statement LD A,24, I assume you mean 24 decimal. This instruction is two bytes, as the first byte is instruction and second byte is data. So on paper:
Code: Select all
Assembler : Code
..........:......
LD A,24 : 62
: 24
We could now enter the program into the computer like this:
Code: Select all
10 REM XXXXXXXX
20 POKE 16514,96
30 POKE 16515,105
40 POKE 16516,94
50 POKE 16517,35
60 POKE 16518,86
70 POKE 16519,235
80 POKE 16520,62
90 POKE 16521,24
100 LET Y=USR 16514
The 8 X'es in line 10 is where we store our program. And the address of the first X is 16514. In line 100 we call the machine language at this address. This program will crash though, as it misses the instruction RET to return to Basic.
Next step is to use a HEX-loader program like described in Usborne's: Machine Code for Beginners page 24+48. Can be downloaded here at the bottom of the page:
https://usborne.com/browse-books/featur ... ing-books/
Or in Toni Baker's: Mastering Machine Code on Your ZX81 page 12. That chapter is reproduced in HTML here:
http://www.users.waitrose.com/~thunor/m ... ter02.html