cursos:ensamblador:rutinas_save_load

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anterior Revisión previa
Próxima revisión
Revisión previa
cursos:ensamblador:rutinas_save_load [19-01-2024 07:58] sromerocursos:ensamblador:rutinas_save_load [19-01-2024 11:58] (actual) sromero
Línea 139: Línea 139:
 </code> </code>
    
- Este comando BASIC salvaría (SAVE), un total de 2 bytes (2) de datos (CODE), empezando en 0 (0) a cinta. En resumen, salvaría el contenido de la dirección de memoria 0x0000 0x0001 en cinta. Esto produciría los siguientes datos en cinta:+ Este comando BASIC salvaría (SAVE), un total de 2 bytes (2) de datos (CODE), empezando en 0 (0) a cinta. En resumen, salvaría el contenido de la dirección de memoria $0000 $0001 en cinta. Esto produciría los siguientes datos en cinta:
  
 <code> <code>
Línea 173: Línea 173:
 | ff | f3 af | a3 | | ff | f3 af | a3 |
  
- En este caso el byte flag es 0xFF (bloque de tipo "datos"), al cual siguen los 2 bytes tomados de la ROM y grabados a cinta (0x0000 0x0001) y el checksum (0xA3).+ En este caso el byte flag es $FF (bloque de tipo "datos"), al cual siguen los 2 bytes tomados de la ROM y grabados a cinta ($0000 $0001) y el checksum ($A3).
  
 \\  \\ 
Línea 189: Línea 189:
 | IX | Dirección inicio de memoria donde almacenar los datos que se van a cargar. | | IX | Dirección inicio de memoria donde almacenar los datos que se van a cargar. |
 | DE | Longitud del bloque de datos a cargar. | | DE | Longitud del bloque de datos a cargar. |
-| A | Flag Byte, normalmente 0x00 para cargar cabeceras o 0xFF (255) para cargar datos. |+| A | Flag Byte, normalmente $00 para cargar cabeceras o $FF (255) para cargar datos. |
 | CF (CarryFlag) | 1=LOAD, 0=VERIFY | | CF (CarryFlag) | 1=LOAD, 0=VERIFY |
  
Línea 203: Línea 203:
  
 <code z80> <code z80>
-    scf                ; Set Carry Flag -> CF=1 -> LOAD +    scf                   ; Set Carry Flag -> CF=1 -> LOAD 
-    ld a, 255          ; A = 0xFF (cargar datos) +    ld a, $ff             ; A = $FF (cargar datos) 
-    ld ix, 16384       ; Destino del load = 16384 +    ld ix, 16384          ; Destino del load = 16384 
-    ld de, 6912        ; Tamaño a cargar = 6912 +    ld de, 6912           ; Tamaño a cargar = 6912 bytes 
-    call 1366          ; Llamamos a la rutina de carga+    call 1366             ; Llamamos a la rutina de carga
 </code> </code>
  
Línea 213: Línea 213:
  
 <code z80> <code z80>
-    scf               ; Set Carry Flag (LOAD) +    scf                  ; Set Carry Flag (LOAD) 
-    ld a, 255      ; A = 0xFF (cargar datos) +    ld a, $ff            ; A = $FF (cargar datos) 
-    ld ix, 32768      ; Destino de la carga +    ld ix, 32768         ; Destino de la carga 
-    ld de, 12000      ; Nuestro "programa" ocupa 12000 bytes. +    ld de, 12000         ; Nuestro "programa" ocupa 12000 bytes. 
-    call 0556        ; Recordemos que 0556h = 1366d +    call $0556           ; Recordemos que 0556h = 1366d 
-    jp 32768          ; Saltamos al programa código máquina cargado+    jp 32768             ; Saltamos al programa código máquina cargado
 </code> </code>
  
Línea 230: Línea 230:
 | IX | Dirección inicio de memoria de los datos que se van a grabar. | | IX | Dirección inicio de memoria de los datos que se van a grabar. |
 | DE | Longitud del bloque de datos a grabar (se grabarán los datos desde IX a IX+DE). | | DE | Longitud del bloque de datos a grabar (se grabarán los datos desde IX a IX+DE). |
-| A | Flag Byte, 0x00 para grabar cabeceras o 0xFF (255) para grabar datos. |+| A | Flag Byte, $00 para grabar cabeceras o $FF (255) para grabar datos. |
 | CF (CarryFlag) | 0 (SAVE) | | CF (CarryFlag) | 0 (SAVE) |
  
Línea 249: Línea 249:
  
     scf                             ; Set Carry Flag -> CF=1 -> LOAD     scf                             ; Set Carry Flag -> CF=1 -> LOAD
-    ld a, 255                       ; A = 0xFF (cargar datos)+    ld a, $ff                       ; A = $FF (cargar datos)
     ld ix, direccion_destino        ; Destino del load     ld ix, direccion_destino        ; Destino del load
     ld de, tamaño_a_cargar          ; Tamaño a cargar     ld de, tamaño_a_cargar          ; Tamaño a cargar
Línea 372: Línea 372:
  
     scf                             ; Set Carry Flag -> CF=1 -> LOAD     scf                             ; Set Carry Flag -> CF=1 -> LOAD
-    ld a, 255                       ; A = 0xFF (cargar datos)+    ld a, $ff                       ; A = $FF (cargar datos)
     ld ix, 16384                    ; Destino del load = 16384     ld ix, 16384                    ; Destino del load = 16384
-    ld de, 6912                     ; Tamaño a cargar = 6912+    ld de, 6912                     ; Tamaño a cargar = 6912 bytes
     call 1366                       ; Llamamos a la rutina de carga     call 1366                       ; Llamamos a la rutina de carga
  
Línea 419: Línea 419:
  El código comentado está extraído del documento "//The Complete Spectrum ROM Disassembly//", de Ian Logan y Frank O'Hara.  El código comentado está extraído del documento "//The Complete Spectrum ROM Disassembly//", de Ian Logan y Frank O'Hara.
  
-<code z80>+ <code z80>
 ; THE 'LD-BYTES' SUBROUTINE ; THE 'LD-BYTES' SUBROUTINE
 ; This subroutine is called to LOAD the header information (from 07BE) ; This subroutine is called to LOAD the header information (from 07BE)
Línea 425: Línea 425:
 0556 LD-BYTES: 0556 LD-BYTES:
                   inc                     ; This resets the zero flag. (D                   inc                     ; This resets the zero flag. (D
-                                            ; cannot hold +FF.) +                                            ; cannot hold $FF.) 
-                  ex    af,a'f            ; The A register holds +00 for a +                  ex    af, af            ; The Aregister holds $00 for 
-                                            ; header and +FF for a block of+                                            ; header and $FF for a block of
                                             ; data.                                             ; data.
                                             ; The carry flag is reset for                                             ; The carry flag is reset for
Línea 436: Línea 436:
                   di                        ; The maskable interrupt is now                   di                        ; The maskable interrupt is now
                                             ; disabled.                                             ; disabled.
-                  ld    a,+0F               ; The border is made WHITE. +                  ld    a,$0f               ; The border is made WHITE. 
-                  OUT   (+FE),A +                  out   ($fe),a 
-                  ld    hl,+053F            ; Preload the machine stack+                  ld    hl,$053f            ; Preload the machine stack
                   push  hl                  ; with the address - SA/LD-ret.                   push  hl                  ; with the address - SA/LD-ret.
-                  IN    A,(+FE)             ; Make an initial read of port '254'+                  in    a,($fe)             ; Make an initial read of port '254'
                   rra                       ; Rotate the byte obtained but                   rra                       ; Rotate the byte obtained but
-                  AND   +20                 ; keep only the EAR bit, +                  and   $20                 ; keep only the EAR bit, 
-                  OR    +02                 ; Signal 'RED' border.+                  or    $02                 ; Signal 'RED' border.
                   ld    c,a                 ; Store the value in the C register. -                   ld    c,a                 ; Store the value in the C register. -
-                                            ; (+22 for 'off' and +02 for 'on'+                                            ; ($22 for 'off' and $02 for 'on'
                                             ; - the present EAR state.)                                             ; - the present EAR state.)
                   cp    a                   ; Set the zero flag.                   cp    a                   ; Set the zero flag.
Línea 455: Línea 455:
                                             ; being pressed.                                             ; being pressed.
 056C LD-START     call  05E7,LD-EDGE-1      ; Return with the carry flag reset 056C LD-START     call  05E7,LD-EDGE-1      ; Return with the carry flag reset
-                  jr    nc,056B,LD-BREAK    ; if there is no 'edge' within+                  jr    nc,056b,LD-BREAK    ; if there is no 'edge' within
                                             ; approx. 14,000 T states. But if                                             ; approx. 14,000 T states. But if
                                             ; an 'edge' is found the border                                             ; an 'edge' is found the border
Línea 463: Línea 463:
 ; that the signal is still pulsing. ; that the signal is still pulsing.
  
-                  ld    hl,+0415            ; The length of this waiting+                  ld    hl,$0415            ; The length of this waiting
 0574 LD-WAIT      djnz  0574,LD-WAIT        ; period will be almost one 0574 LD-WAIT      djnz  0574,LD-WAIT        ; period will be almost one
                   dec   hl                  ; second in duration.                   dec   hl                  ; second in duration.
Línea 470: Línea 470:
                   jr    nz,0574,LD-WAIT                   jr    nz,0574,LD-WAIT
                   call  05E3,LD-EDGE-2      ; Continue only if two edges are                   call  05E3,LD-EDGE-2      ; Continue only if two edges are
-                  jr    nc,056B,LD-BREAK    ; found within the allowed time+                  jr    nc,056b,LD-BREAK    ; found within the allowed time
                                             ; period.                                             ; period.
  
 ; Now accept only a 'leader signal'. ; Now accept only a 'leader signal'.
  
-0580 LD-LEADER    ld    b,+9C               ; The timing constant,+0580 LD-LEADER    ld    b,$9c               ; The timing constant,
                   call  05E3,LD-EDGE-2      ; Continue only if two edges are                   call  05E3,LD-EDGE-2      ; Continue only if two edges are
                   jr    nc,056B,LD-BREAK    ; found within the allowed time                   jr    nc,056B,LD-BREAK    ; found within the allowed time
                                             ; period.                                             ; period.
-                  ld    a,+C6               ; However the edges must have+                  ld    a,$c6               ; However the edges must have
                   cp    b                   ; been found within about                   cp    b                   ; been found within about
-                  jr    nc,056C,LD-START    ; 3,000 T states of each other+                  jr    nc,056c,LD-START    ; 3,000 T states of each other
                   inc                     ; Count the pair of edges in the H                   inc                     ; Count the pair of edges in the H
                   jr    nz,0580,LD-LEADER   ; register until '256' pairs have                   jr    nz,0580,LD-LEADER   ; register until '256' pairs have
Línea 488: Línea 488:
 ; After the leader come the 'off' and 'on' part's of the sync pulse. ; After the leader come the 'off' and 'on' part's of the sync pulse.
  
-058F LD-SYNC      ld    b,+C9               ; The timing constant.+058F LD-SYNC      ld    b,$c9               ; The timing constant.
                   call  05E7,LD-EDGE-1      ; Every edge is considered until                   call  05E7,LD-EDGE-1      ; Every edge is considered until
-                  jr    nc,056B,LD-BREAK    ; two edges are found close+                  jr    nc,056b,LD-BREAK    ; two edges are found close
                   ld    a,b                 ; together - these will be the                   ld    a,b                 ; together - these will be the
-                  CP    +D4                 ; start and finishing edges of +                  CP    $d4                 ; start and finishing edges of 
-                  jr    nc,058F,LD-SYNC     ; the 'off' sync pulse. +                  jr    nc,058f,LD-SYNC     ; the 'off' sync pulse. 
-                  call  05E7,LD-EDGE-1      ; The finishing edge of the+                  call  05e7,LD-EDGE-1      ; The finishing edge of the
                   ret   nc                  ; 'on' pulse must exist.                   ret   nc                  ; 'on' pulse must exist.
                                             ; (Return carry flag reset.)                                             ; (Return carry flag reset.)
Línea 502: Línea 502:
  
                   ld    a,c                 ; The border colours from now                   ld    a,c                 ; The border colours from now
-                  XOR   +03                 ; on will be BLUE & YELLOW.+                  XOR   $03                 ; on will be BLUE & YELLOW.
  
                   ld    c,a                   ld    c,a
-                  ld    h,+00               ; Initialise the 'parity matching'+                  ld    h,$00               ; Initialise the 'parity matching'
                                             ; byte to zero.                                             ; byte to zero.
-                  ld    b,+B0               ; Set the timing constant for the+                  ld    b,$b0               ; Set the timing constant for the
                                             ; flag byte.                                             ; flag byte.
                   jr    05C8,LD-MARKER      ; Jump forward into the byte                   jr    05C8,LD-MARKER      ; Jump forward into the byte
Línea 516: Línea 516:
 ; the last byte is the 'parity' byte. ; the last byte is the 'parity' byte.
  
-05A9 LD-LOOP      ex    af,a'f'             ; Fetch the flags.+05A9 LD-LOOP      ex    af,af             ; Fetch the flags (ex af, af')
                   jr    nz,05B3,LD-FLAG     ; Jump forward only when                   jr    nz,05B3,LD-FLAG     ; Jump forward only when
                                             ; handling the first byte.                                             ; handling the first byte.
Línea 548: Línea 548:
  
 05C2 LD-NEXT      inc   ix                  ; Increase the 'destination'. 05C2 LD-NEXT      inc   ix                  ; Increase the 'destination'.
-05C4 LD-dec       deC   DE                  ; Decrease the 'counter'+05C4 LD-dec       dec   de                  ; Decrease the 'counter'
-                  ex    af,a'f'             ; Save the flags. +                  ex    af,af             ; Save the flags in af' 
-                  ld    b,+B2               ; Set the timing constant. +                  ld    b,$b2               ; Set the timing constant. 
-05C8 LD-MARKER    ld    l,+01               ; Clear the 'object' register apart+05C8 LD-MARKER    ld    l,$01               ; Clear the 'object' register apart
                                             ; from a 'marker' bit.                                             ; from a 'marker' bit.
  
Línea 560: Línea 560:
                   ret   nc                  ; Return if the time period is                   ret   nc                  ; Return if the time period is
                                             ; exceeded. (Carry flag reset.)                                             ; exceeded. (Carry flag reset.)
-                  ld    a,+CB               ; Compare the length against+                  ld    a,$cb               ; Compare the length against
                                             ; approx. 2,400 T states; resetting                                             ; approx. 2,400 T states; resetting
                   cp    b                   ; the carry flag for a '0' and                   cp    b                   ; the carry flag for a '0' and
Línea 566: Línea 566:
                   rl    l                   ; Include the new bit in the L                   rl    l                   ; Include the new bit in the L
                                             ; register.                                             ; register.
-                  ld    b,+B0               ; Set the timing constant for the+                  ld    b,$b0               ; Set the timing constant for the
                                             ; next bit.                                             ; next bit.
                   jp    nc,05CA,LD-8-BITS   ; Jump back whilst there are still                   jp    nc,05CA,LD-8-BITS   ; Jump back whilst there are still
Línea 583: Línea 583:
                   ld    a,h                 ; Fetch the 'parity matching'                   ld    a,h                 ; Fetch the 'parity matching'
                                             ; byte.                                             ; byte.
-                  CP    +01                 ; Return with the carry flat set+                  CP    $01                 ; Return with the carry flat set
                   ret                       ; if the value is zero.                   ret                       ; if the value is zero.
                                             ; (Carry flag reset if in error.)                                             ; (Carry flag reset if in error.)
Línea 602: Línea 602:
                   ret   nc                  ; returning in between if there                   ret   nc                  ; returning in between if there
                                             ; is an error.                                             ; is an error.
-05E7 LD-EDGE-1    ld    a,+16               ; Wait 358 T states before+05E7 LD-EDGE-1    ld    a,$16               ; Wait 358 T states before
 05E9 LD-DELAY     dec                     ; entering the sampling loop. 05E9 LD-DELAY     dec                     ; entering the sampling loop.
                   jr    nz,05E9,LD-DELAY                   jr    nz,05E9,LD-DELAY
Línea 613: Línea 613:
                   ret                     ; Return carry reset & zero set if                   ret                     ; Return carry reset & zero set if
                                             ; 'time-up'.                                             ; 'time-up'.
-                  ld    a,+7F               ; Read from port +7FFE. +                  ld    a,$7F               ; Read from port $7FFE. 
-                  IN    A,(+FE)             ; i.e. BREAK & EAR.+                  IN    A,($fe)             ; i.e. BREAK & EAR.
                   rra                       ; Shift the byte.                   rra                       ; Shift the byte.
                   ret   nc                  ; Return carry reset & zero reset                   ret   nc                  ; Return carry reset & zero reset
                                             ; if BREAK was pressed.                                             ; if BREAK was pressed.
                   xor                     ; Now test the byte against the                   xor                     ; Now test the byte against the
-                  AND   +20                 ; 'last edge-type'; jump back+                  AND   $20                 ; 'last edge-type'; jump back
                   jr    z,05ED,LD-SAMPLE    ; unless it has changed.                   jr    z,05ED,LD-SAMPLE    ; unless it has changed.
  
Línea 628: Línea 628:
                   cpl                       ; and border colour.                   cpl                       ; and border colour.
                   ld    c,a                   ld    c,a
-                  AND   +07                 ; Keep only the border colour. +                  AND   $07                 ; Keep only the border colour. 
-                  OR    +08                 ; Signal 'MIC off'+                  OR    $08                 ; Signal 'MIC off'
-                  OUT   (+FE),A             ; Change the border colour (RED/+                  OUT   ($fe),A             ; Change the border colour (RED/
                                             ; CYAN or BLUE/YELLOW).                                             ; CYAN or BLUE/YELLOW).
                   scf                       ; Signal the successful search                   scf                       ; Signal the successful search
Línea 641: Línea 641:
 ; allowance is made for ten additional passes through the sampling loop. ; allowance is made for ten additional passes through the sampling loop.
 ; The search is thereby for the next edge to be found within, roughly, ; The search is thereby for the next edge to be found within, roughly,
-; 1,100 T states (465 10 * 58 overhead). This will prove successful+; 1,100 T states (465 10 * 58 overhead). This will prove successful
 ; for the sync 'off' pulse that comes after the long 'leader pulses'. ; for the sync 'off' pulse that comes after the long 'leader pulses'.
 </code> </code>
 +  
 + 
 \\  \\ 
 ===== Ficheros ===== ===== Ficheros =====
  • cursos/ensamblador/rutinas_save_load.1705651090.txt.gz
  • Última modificación: 19-01-2024 07:58
  • por sromero