You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some 16-bit Real Mode DOS programs use the upper portion of ESP as standby stack pointer for an alternative stack, specifically for graphics operations. However, SBEMU does not account for this and inadvertently corrupts the upper part of ESP.
ror esp,16 ; invoke graphic stack
; some graphic stuff, for example blit a sprite row
lodsw ; word from ds:[si] into ax, increment si by 2
ror eax,cl ; rotate eax right by x-pos mod 8 to adjust output
or es:[di],ah ; 1st byte to vmem
push di ; save di to clearstack
inc di
or es:[di],al ; 2nd byte to vmem
push di ; save di to clearstack
inc di
shr eax,16 ; overflow from the rotation to ah (side effect: clears upper 16 bits of eax)
or es:[di],ah ; 3rd byte to vmem
push di ; save di to clearstack
ror esp,16 ; restore standard sp and save clrscr stack pointer in upper 16 bit of esp
After a few seconds, programs that utilize this method freeze.
The text was updated successfully, but these errors were encountered:
EmoticonSmile
changed the title
Corruption of ESP in 16 bit Real Mode DOS Programs
Corruption of ESP in 16 bit Real Mode DOS programs
Oct 24, 2024
Wow, well debugged. Think you could help with creating a PR for this? Or at least some pointers for those reading here who are knowledgeable to have a go at fixing this? Thanks! 🙏🏾
Some 16-bit Real Mode DOS programs use the upper portion of ESP as standby stack pointer for an alternative stack, specifically for graphics operations. However, SBEMU does not account for this and inadvertently corrupts the upper part of ESP.
ror esp,16 ; invoke graphic stack
; some graphic stuff, for example blit a sprite row
lodsw ; word from ds:[si] into ax, increment si by 2
ror eax,cl ; rotate eax right by x-pos mod 8 to adjust output
or es:[di],ah ; 1st byte to vmem
push di ; save di to clearstack
inc di
or es:[di],al ; 2nd byte to vmem
push di ; save di to clearstack
inc di
shr eax,16 ; overflow from the rotation to ah (side effect: clears upper 16 bits of eax)
or es:[di],ah ; 3rd byte to vmem
push di ; save di to clearstack
ror esp,16 ; restore standard sp and save clrscr stack pointer in upper 16 bit of esp
After a few seconds, programs that utilize this method freeze.
The text was updated successfully, but these errors were encountered: