Advertisement
AnthonyCagliano

Untitled

Jan 5th, 2022
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. ; use to erase the stack to prevent buffer leak side channel attack
  2. stack_clear:
  3.  
  4. ; save a, hl, e
  5. ld (.smc_a), a
  6. ld (.smc_hl), hl
  7. ld a, e
  8. ld (.smc_e), a
  9.  
  10. ; set from stackBot + 4 to sp - 1 to 0
  11. lea de, (ix - 2)
  12. ld hl, -(stackBot + 3)
  13. add hl, de
  14. push hl
  15. pop bc
  16. lea hl, (ix - 1)
  17. ld (hl), 0
  18. lddr
  19.  
  20. ; restore a, hl, e
  21. ld e, 0
  22. .smc_e:=$-1
  23. ld a, 0
  24. .smc_a:=$-1
  25. ld hl, 0
  26. .smc_hl:=$-3
  27. ld sp, ix
  28. pop ix
  29. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement