{"id":35167,"date":"2022-03-03T15:29:51","date_gmt":"2022-03-03T20:29:51","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=35167"},"modified":"2022-03-03T15:29:51","modified_gmt":"2022-03-03T20:29:51","slug":"emulating-1998-vintage-mac-compilers","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2022\/03\/03\/emulating-1998-vintage-mac-compilers\/","title":{"rendered":"Emulating 1998-Vintage Mac Compilers"},"content":{"rendered":"<p><a href=\"https:\/\/wuffs.org\/blog\/emulating-mac-compilers\">Ninji<\/a> (<a href=\"https:\/\/twitter.com\/_Ninji\/status\/1498420342418821121\">tweet<\/a>):<\/p>\n<blockquote cite=\"https:\/\/wuffs.org\/blog\/emulating-mac-compilers\">\n<p>All of the tools I needed could be accessed via MPW. Could I get these to run externally somehow?<\/p>\n<p>[&#8230;]<\/p>\n<p>The obvious choice to start with here is <a href=\"https:\/\/www.unicorn-engine.org\/\">Unicorn Engine<\/a>, which is essentially the CPU emulator from QEMU made into an embeddable library. I&rsquo;ve used it for a bunch of projects before. They&rsquo;ve brought Rust bindings into the tree now which is also quite cool!<\/p>\n<p>[&#8230;]<\/p>\n<p>Whenever the emulator calls a library function, it loads the function&rsquo;s index into rtoc (r2) and invokes <code>sc<\/code>. Then, my hook looks at r2 to determine which function we should try and simulate.<\/p>\n<p>[&#8230;]<\/p>\n<p>The CodeWarrior C\/C++ compiler (MWCPPC) imports over a hundred library functions, but I didn&rsquo;t want to just implement every single one right off the bat - I wanted to see results faster than that, so I ran it and implemented things as they came up.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Ninji (tweet): All of the tools I needed could be accessed via MPW. Could I get these to run externally somehow? [&#8230;] The obvious choice to start with here is Unicorn Engine, which is essentially the CPU emulator from QEMU made into an embeddable library. I&rsquo;ve used it for a bunch of projects before. They&rsquo;ve [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2022-03-03T20:29:54Z","apple_news_api_id":"acc2150f-7e6b-44f9-8c92-c807e1ce9875","apple_news_api_modified_at":"2022-03-03T20:29:54Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/ArMIVD35rRPmMksgH4c6YdQ","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[1404,255,733,295,924,1059,74,71,408],"class_list":["post-35167","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-codewarrior","tag-compiler","tag-emulator","tag-history","tag-mac-os-9","tag-macintosh-programmers-workshop-mpw","tag-opensource","tag-programming","tag-rust-lang"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/35167","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=35167"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/35167\/revisions"}],"predecessor-version":[{"id":35168,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/35167\/revisions\/35168"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=35167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=35167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=35167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}