r/transprogrammer • • Jul 20 '24

Implementing exceptions

Just wanna know if anyone knows a more time-efficient way of implementing exceptions in a language than this or sees any issues with this design :3

(I know this flow chart sucks, sry)

handlethrow would exist separately for each try-catch clause

(obv this will only work for x86 but smth similar should work for all major architectures)

15 Upvotes

25 comments sorted by

View all comments

Show parent comment

2

u/definitelynotagirl99 Jul 22 '24

btw, do be careful with the carry flag thing, you gotta reset that before executing anything that doesn't account for it being set as i do believe that at least systemV-amd64 requires it to be clear upon return

edit: i have given up on checking since the sysv-amd64 spec looks like it was formatted by a toddler

2

u/Mai_Lapyst Jul 22 '24

I've found that this documentation https://gitlab.com/x86-psABIs/x86-64-ABI (which the osdev wiki (https://wiki.osdev.org/System_V_ABI) lists as source), on page 21, it claims that only DF needs to be clear and no other flags are touched or of interest.

2

u/definitelynotagirl99 Jul 22 '24

oh well, i must have been mistaken then.
Thx for pointing it out because that may actually mean that i have to reset the carry flag in a number of places.