Welcome, Guest. Please login or register.


Author Topic: Assembly programozás (Read 258851 times)

Offline Tuby128

  • EP addict
  • *
  • Posts: 1449
  • Country: hu
Re: Assembly programozás
« Reply #1140 on: 2024.January.05. 17:03:24 »
I remember that there was something with 16bit subtraction (CP HL,BC is missing). Unfortunately this code destroys the Value of the HL, but in the case you choosen, its not a problem.
Thanks!

One thing to mention OR A is becasue CCF (Change Carry Flag?) does not clear, it inverts the Carry, so there is no other obtion but "OR A".
By using SBC the carry also plays a role, so must be reseted.
« Last Edit: 2024.January.05. 17:08:49 by Tuby128 »

Offline Povi

  • EP addict
  • *
  • Posts: 2298
  • Country: hu
    • http://povi.fw.hu
Re: Assembly programozás
« Reply #1141 on: 2024.January.08. 10:02:51 »
Még egy kérdés. Kicsit hiányosnak érzem a Z80 utasításkészletet. Ha el akarok számolni 1-től 2115-ig, és közben valamit csinálni, akkor hogyan tudom leellenőrizni, hogy elértem az 2115-öt?
CMP (vagy SUB) utasítást használnék alapból, de ahogy látom ezek csak 8 bitre érvényesek.
Vagy csinálsz egy CompareHLBC rutint:
Or you can create a subroutine:

Code: [Select]
CompareHLBC:
ld   a, h
sub  b
ret  nz
ld   a, l
sub  c
ret

Hátránya, hogy lassú, tönkreteszi az A regisztert, de ugyanúgy működik (ugyanúgy álíltgatja a flag-eket), mint a sima CP utasítás.
Disadvantages: slow, destroys A, but works as an 8-bit CP operation (C and Z flag affects).
SUB helyett lehet CP is kódban, tök mindegy.
*** Speicherplatz zu klein

Offline Povi

  • EP addict
  • *
  • Posts: 2298
  • Country: hu
    • http://povi.fw.hu
Re: Assembly programozás
« Reply #1142 on: 2024.January.08. 10:04:35 »
CCF (Change Carry Flag?) does not clear, it inverts the Carry
CCF = Complement Carry Flag
*** Speicherplatz zu klein

Offline geco

  • EP addict
  • *
  • Posts: 7118
  • Country: hu
    • Támogató Támogató
Re: Assembly programozás
« Reply #1143 on: 2024.January.08. 10:11:30 »
Vagy szimplán, ha mindig ugyanaz a zámláló értéke:
Ha gyorsítani akarsz rajta, akkor a JR NZ-ket le lehet cserélni JP NZ-re, de a leggyorsabb a visszafelé számlálás.

Code: [Select]
        ld bc,0000h
loop    push bc
        futtatandó kód
        pop bc
        inc bc
        ld a,c
        cp 43h
        jr nz,loop
        ld a,b
        cp 08h         ;2115 = 0843h
        jr nz,loop

Offline BruceTanner

  • EP lover
  • *
  • Posts: 607
  • Country: gb
Re: Assembly programozás
« Reply #1144 on: 2024.January.08. 11:00:14 »
This use of "complement" is a bit strange: if you look up "complement" in a dictionary it means "to make complete or whole". This is where "twos complement" arithmetic comes from: the twos complement of a byte is the number that makes the total FFh when added. But applied to one bit (the Carry) it is the number that makes it up to 1 when added.

The same phrase is used for many processors, not just the z80.

Offline Tuby128

  • EP addict
  • *
  • Posts: 1449
  • Country: hu
Re: Assembly programozás
« Reply #1145 on: 2024.January.08. 12:00:09 »
The CCF not only inverts the Carry Flag, it also inverts (or just resets?) the Half-Carry flag, and also resets the N Flag (which is not commonly used).

ICF - Invert Carry Flag would a be better name.

Offline Ferro73

  • EP lover
  • *
  • Posts: 980
  • Country: hu
Re: Assembly programozás
« Reply #1146 on: 2024.January.08. 19:30:22 »
Geco ez akkor azt jelenti, hogy 0 tól x-ig felejtsem el a számolgatást, és szokjam meg hogy x-től 0-ig kell visszafelé számolni?
Nem a BC az csak a progidat futtatja annyiszor amennyiszer akarod
A BC értékét elmentődik ezért a progin belül használhatod bármire.

Valami példa jó volna miért kell 0-2115 miért nem jó  2115-0.