Domanda

I'm working on a program for Intel 8080 right now and I don't really get how the space we can reserve for variables work. Namely, let's say we do test DB 80. Can I later somehow decrement or increment the variable test for example or do I have to declare it anew?

È stato utile?

Soluzione

INR M instruction increments the byte content of the memory address pointed by HL register. So you can basically:

LXI H, test
INR M

Altri suggerimenti

Assuming "test" is a byte, you could do something like this:

test: ds 1 :this sets aside one byte for storage of data and names it "test"

  lda test  ; move the value from the memory location called "test" into "a"
  inr a     ; increment A
  sta test  ; store the value from A into the memory location called "test"

; this code uses the A register and seven bytes of code space. The incremented value of "test" remains in A at the end of the sequence.

Alternatively, as mentioned above:

test: ds 1 lxi H,test ; Load HL with the address of the memory location called "test" inr m ; increment the memory location whose address is in HL. ; this code uses four bytes of code space and registers H and L ; if you want to load A with the contents of "test", execute: mov a,m ; which adds another byte of code.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top