Created
January 4, 2023 15:19
-
-
Save yunkya2/be71f779482976de931f5eb105487abd to your computer and use it in GitHub Desktop.
X68000 B_SUPERで安全にユーザモードに復帰する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdint.h> | |
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include <iocslib.h> | |
| #include <doslib.h> | |
| int main(int argc, char *argv[]){ | |
| /* 何かキーが押されるまで繰り返す */ | |
| while (INPOUT(0xFF) == 0) { | |
| /* スーパーバイザモードに移行する */ | |
| int ssp = B_SUPER(0); | |
| /* ハードウェアに直接アクセスし内部時計の状態を表示します */ | |
| printf("RTC(0xE8A000) = %08X¥n", *(uint32_t *)0xE8A000); | |
| /* ユーザモードに復帰する ( B_SUPER(ssp) の代わり ) */ | |
| __asm__ volatile ("subq.l #8,sp\n" | |
| "move.l sp,usp\n" | |
| "addq.l #4,sp\n" | |
| "move.l %0,(sp)\n" | |
| "jsr (%1)\n" | |
| "addq.l #4,sp" :: "d"(ssp), "a"(B_SUPER)); | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment