Advertisement
wallyweek

ESXDOS from assembly

Jul 1st, 2017
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Reason for PUSH IX:POP HL is for some reason when using .command extensions it's HL, and at normal ram space it's IX
  2.  
  3. So I used PUSH IX:POP HL so I can just have the same file handling code no matter if I was writing a .extension command or a game.
  4.  
  5.  
  6. One important thing to know is ESXDOS sets carry flag if call was not successful. Also, A register is set to error code. Finally, if dot command finishes (RET) with carry flag set, ESXDOS will show an message depending onA register value.
  7.  
  8. All that put together means you can for instace call "fopen" and just after add "RET c", and in case open fails ESXDOS will show "file not found", "invalid file name" or whatever.
  9.  
  10.  
  11. I disassembled the bitmap test dot command for this very reason :)
  12.  
  13. http://dailly.blogspot.co.uk/2017/06/zx-spectrum-next-bitmap-example.html
  14.  
  15. This code of mine has a good example of how to read a file, and it has comments:
  16.  
  17. https://github.com/Utodev/ZXUC/blob/master/zxuc.asm
  18.  
  19.  
  20. open and create IX = pointer to filename
  21. read write IX = buffer, BC = size
  22.  
  23.  
  24. setdrv        xor a:rst $08:db $89:xor a:ld (handle),a:ret
  25. fopen        ld    b,$01:db 33
  26. fcreate        ld    b,$0c:push ix:pop hl:ld a,42:rst $08:db $9a:ld (handle),a:ret
  27. fread            push ix:pop hl:db 62
  28. handle        db 0:or a:ret z:rst $08:db $9d:ret
  29. fwrite        push ix:pop hl:ld a,(handle):or a:ret z:rst $08:db $9e:ret
  30. fclose        ld    a,(handle):or a:ret z:rst $08:db $9b:ret
  31. fseek        ld a,(handle):or a:ret z:rst $08:db $9f:ret
  32. ;                                    // Seek BCDE bytes. A=handle
  33. ;                                    // L=mode:    0-from start of file
  34. ;                                    //            1-forward from current position
  35. ;                                     //            2-back from current position
  36. ;                                    // On return BCDE=current file pointer.
  37. ;                                    // Does not currently return bytes
  38. ;                                    // successfully sought.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement