home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 83 / asm / source / unsquish.z80 < prev    next >
Encoding:
Text File  |  2001-07-01  |  2.4 KB  |  138 lines

  1. ;===================================
  2. ;Unsquish by Jimmy Conner aka CiGaMiT  (timagic@yahoo.com)
  3. ; I would comment most of this source but seeing that not even I
  4. ; can understand what the heck I was up to 10 minutes after
  5. ; I write something, I don't believe I will.
  6. ; I will help you out as much as possible, just dont try to take my
  7. ; work and make it yours, otherwise enjoy.
  8. ;
  9. ; <ATTENTION!!!>
  10. ; No calculators were harmed in the making of this program, It was programmed solely on Calc'Em.
  11. ; </ATTENTION!!!>
  12. ;===================================
  13.  
  14.  
  15. .NOLIST
  16. #define equ .equ
  17. #define EQU .equ
  18. #define END .end
  19. #include "ti83asm.inc"
  20. #include "tokens.inc"
  21. .LIST
  22. .org 9327h
  23. strngobj    .equ 04h
  24. progobj    .equ 05h
  25. protprogobj    .equ 06h
  26. _errundefined    .equ    467Bh
  27. _errsyntax    .equ    466Ch
  28. _findsym    .equ    442Eh
  29. _INSERTMEM    equ    4432h
  30. _freemem    equ    441Ah
  31. _errnotenoughmem   equ    467eh
  32.  
  33.      call    _zerooop1      
  34.     ld    a, tAns        
  35.     ld    (op1+1), a     
  36.     call    _findsym       
  37.     jp    c, _errundefined 
  38.     and    1fh              
  39.     cp    strngobj         
  40.     jp    nz, _errsyntax   
  41.     ld    hl, op1          
  42.     ld    (hl), progobj    
  43.     inc    hl                  
  44.     ld    a, (de)           
  45.     ld    c, a              
  46.     xor    b                   
  47.     inc    de                   
  48.     inc    de                   
  49.     ex    de, hl            
  50.     ldir                     
  51.     call    _chkfindsym         
  52.     jp    c, _errundefined  
  53.     ld    a, 5
  54.     ld    (hl), a
  55.     push    de
  56.     ld    a, (de)
  57.     ld    l, a
  58.     inc    de
  59.     ld    a, (de)
  60.     ld    h, a
  61.     push    hl        ; HL = Size
  62.     call    checkformem
  63.     ld    b, h
  64.     ld    c, l
  65.     inc    de
  66. unsquish2:
  67.     push    bc                ; HL is at old data
  68.     inc    de                ; HL is pointing to the new spot data
  69.     ld    hl, 1
  70.     call    _insertmem
  71.     dec    de
  72.  
  73.     ld    a, (de)
  74.     add    a, 16
  75.     ld    c, -1
  76. unsquishdata:
  77.     inc    c
  78.     add    a, -16
  79.     cp    16
  80.     jp    nc, unsquishdata
  81.     ld    b, a
  82.     ld    a, c
  83.     call    addtoit
  84.     ld    (de), a
  85.     ld    a, b
  86.     call    addtoit
  87.     inc    de
  88.     ld    (de), a
  89.     inc    de
  90.     pop    bc
  91.     dec    bc
  92.     ld    a, b
  93.     or    c
  94.     jp    nz, unsquish2
  95.     push    de
  96.     ld    hl, 9
  97.     call    _insertmem
  98.     pop    de
  99.     ld    hl, ending
  100.     ld    bc, 9
  101.     ldir
  102.     pop    hl
  103.     pop    de
  104.     add    hl, hl
  105.     ld    bc, 9
  106.     add    hl, bc
  107.     ld    a, l
  108.     ld    (de), a
  109.     inc    de
  110.     ld    a, h
  111.     ld    (de), a
  112.     ret
  113. addtoit:
  114.     add    a, 30h
  115.     cp    3Ah
  116.     ret    c
  117.     add    a, 7
  118.     ret
  119.  
  120. checkformem:
  121.     push    hl
  122.     push    de
  123.     push    bc
  124.     ld    bc, 9
  125.     add    hl, bc
  126.     ex    de, hl
  127.     call    _freemem
  128.     call    _cphlde
  129.     jp    c, _errnotenoughmem
  130.     pop    bc
  131.     pop    de
  132.     pop    hl
  133.     ret
  134.  
  135. ending:
  136.     .db    tEnter,tEnd,tEnter,"0000",tEnter,tEnd
  137. .end
  138. end