playing Tower of Hanoi with registers

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
Post Reply
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

playing Tower of Hanoi with registers

Post by AndrewAPrice »

My registers were always mixed up when ever I returned from my screen printing functions. I checked my printing function over and over again, but nothing appeared to be wrong. My solution was to 'call tower_of_hanoi' after each print, a function that would play an interesting game of Tower of Hanoi and re-arrange my registers in the correct order.

I soon found out all of this wasn't required, because of some sillyness in the 'pop'ing and 'push'ing of the registers in my printing function:

Code: Select all

print:
        push    edi
        push    eax
        push    ebx

; more code here
        pop     eax
        pop     edi
        pop     ebx
        ret
Moral of the story: if your registers are screwed, save yourself a lot of headache by checking your 'pop'ing and 'push'ing!
User avatar
spix
Member
Member
Posts: 128
Joined: Mon Jun 26, 2006 8:41 am
Location: Millicent, South Australia
Contact:

Post by spix »

That's pretty funny.

"Sorry, your computer is busy playing games and doesn't have time for you. It might beable to fit you in on friday. Thursday is D&D night with the modem and printer. OK CANCEL"

Well, I thought it was funny ;)
Post Reply