On 6/2/18 1:48 AM, Willard Goosey wrote:
Assembly in 808x isn't about smart, it's about having the patience to
look up every other instruction in a book. ;-)
The classic example:
mvi b,0 ; move the 8bit value 0 into b
lxi b,0 ; move the 16bit value 0 into bc
Assembly programming. Because some people enjoy pain. :-)
Willard
I have an 8-bit microcontroller that I wrote for an FPGA back in 1997
for which I aslo wrote an assembler. I have recently been using it use
as a small controller in some of my ASICs at work. But most of the guys
at work don't enjoy the "pain" of "ldi, lda, sta, sxi, sxr" assembly the
way I do. :)
So recently I decided to enable other engineers by extended the
assembler to support things like:
r1 = 5; // LDI r1,5 opcode (Load Immediate
value)
while(r1 != 0) // While requires expansion to 3-4 opcodes
{ // LDI 0 (Load A with 0)
// CMP r1 (compare with R1)
// BZ while_end_label
a = r1; // LDA r1 opcode
*r2++ = a; // SXR r2 opcode (Store Indexed
Register)
// INC r2 opcode
print(a); // CALL addr opcode
a = gVarSum; // LXI addr opcode (Load Indexed Immediate)
a += r1; // ADD r1 opcode (Add r1 to Acc)
gVarSum = a; // SXI addr opcode (Store Indexed Immediate)
r1--; // DEC r1 opcode (Decrement A or R0-R3)
}
It isn't C exactly because it doen't manage a stack, local
functionvariables or support statements like "a = b * c + 3", but rather
it is a C like syntax that converts almost directly into the
corresponding ASM opcodes. Who ever made the decision that assembly had
to be cryptic anyway?
Ken