Skip to content

ti_Read and ti_Write assumes ti._smulu sets UHL to zero #804

Description

@ZERICO2005
; size_t ti_Write(const void *data, size_t size, size_t count, uint8_t handle);
ti_Write:
; writes a chunk of data into a slot handle
; args:
;  sp + 3 : pointer to data to write
;  sp + 6 : size of chunks in bytes
;  sp + 9 : number of chunks
;  sp + 12 : slot index
; return:
;  hl = number of chunks written if success
    ld    iy, 0
    add    iy, sp
    ld    c, (iy + 12)
    call    util_is_slot_open
    jr    nz, .ret0
    call    util_is_in_ram
    jr    z, .ret0
    ld    bc, (iy + 6) ; size
    ld    hl, (iy + 9) ; count
    call    ti._smulu ; size * count
    add    hl, de
    xor    a, a
    sbc    hl, de
    ret    z
    ld    (.smc_copy_size), hl
    ; ...

This code assumes ti._smulu sets UHL to zero. While I assume 0 * 0 will set UHL to zero, this may not be the case for non-zero multipliers.

If UHL is non-zero, that implies that .smc_copy_size will copy more than 65535 bytes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions