diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-09-11 19:04:49 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-09-11 19:53:23 -0700 |
commit | ecfbbfb5b58aaba9f9265cb13b9fb4a914bdcf37 (patch) | |
tree | 486cd5f4ee75323b5c733912c7a58501d65b0325 /examples/ex7.subx | |
parent | 4d53de8afa0d44e29d3caeb01ccdd02bc2e4cd70 (diff) | |
download | mu-ecfbbfb5b58aaba9f9265cb13b9fb4a914bdcf37.tar.gz |
5647 - experimental support for swapping OS
Diffstat (limited to 'examples/ex7.subx')
-rw-r--r-- | examples/ex7.subx | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/examples/ex7.subx b/examples/ex7.subx index ffef013d..cf684f86 100644 --- a/examples/ex7.subx +++ b/examples/ex7.subx @@ -11,88 +11,79 @@ # $ echo $? # 97 -== code 0x09000000 +== code # instruction effective address register displacement immediate # . op subop mod rm32 base index scale r32 # . 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes Entry: - # syscall(creat, Filename) + # creat(Filename) bb/copy-to-ebx Filename/imm32 b9/copy-to-ecx 0x180/imm32/fixed-perms - b8/copy-to-eax 8/imm32/creat - cd/syscall 0x80/imm8 + e8/call syscall_creat/disp32 - # stream = syscall(open, Filename, O_WRONLY, 0) # we can't use 'fd' because it looks like a hex byte + # stream = open(Filename, O_WRONLY, 0) # we can't use 'fd' because it looks like a hex byte bb/copy-to-ebx Filename/imm32 b9/copy-to-ecx 1/imm32/wronly ba/copy-to-edx 0x180/imm32/fixed-perms - b8/copy-to-eax 5/imm32/open - cd/syscall 0x80/imm8 + e8/call syscall_open/disp32 # save stream bb/copy-to-ebx Stream/imm32 89/copy 0/mod/indirect 3/rm32/ebx . . . 0/r32/eax . . # copy eax to *ebx - # syscall(write, Stream, "a", 1) + # write(Stream, "a", 1) # . load stream bb/copy-to-ebx Stream/imm32 8b/copy 0/mod/indirect 3/rm32/ebx . . . 3/r32/ebx . . # copy *ebx to ebx # . b9/copy-to-ecx A/imm32 ba/copy-to-edx 1/imm32/size - b8/copy-to-eax 4/imm32/write - cd/syscall 0x80/imm8 + e8/call syscall_write/disp32 - # syscall(close, Stream) + # close(Stream) # . load stream bb/copy-to-ebx Stream/imm32 8b/copy 0/mod/indirect 3/rm32/ebx . . . 3/r32/ebx . . # copy *ebx to ebx # . - b8/copy-to-eax 6/imm32/close - cd/syscall 0x80/imm8 + e8/call syscall_close/disp32 - # stream = syscall(open, Filename, O_RDONLY, 0) + # stream = open(Filename, O_RDONLY, 0) bb/copy-to-ebx Filename/imm32 b9/copy-to-ecx 0/imm32/rdonly ba/copy-to-edx 0x180/imm32/fixed-perms - b8/copy-to-eax 5/imm32/open - cd/syscall 0x80/imm8 + e8/call syscall_open/disp32 # . save Stream bb/copy-to-ebx Stream/imm32 89/copy 0/mod/indirect 3/rm32/ebx . . . 0/r32/eax . . # copy eax to *ebx - # syscall(read, Stream, B, 1) + # read(Stream, B, 1) # . load stream bb/copy-to-ebx Stream/imm32 8b/copy 0/mod/indirect 3/rm32/ebx . . . 3/r32/ebx . . # copy *ebx to ebx # . b9/copy-to-ecx B/imm32 ba/copy-to-edx 1/imm32/size - b8/copy-to-eax 3/imm32/read - cd/syscall 0x80/imm8 + e8/call syscall_read/disp32 - # syscall(close, Stream) + # close(Stream) # . load stream bb/copy-to-ebx Stream/imm32 8b/copy 0/mod/indirect 3/rm32/ebx . . . 3/r32/ebx . . # copy *ebx to ebx # - b8/copy-to-eax 6/imm32/close - cd/syscall 0x80/imm8 + e8/call syscall_close/disp32 - # syscall(unlink, filename) + # unlink(filename) bb/copy-to-ebx Filename/imm32 - b8/copy-to-eax 0xa/imm32/unlink - cd/syscall 0x80/imm8 + e8/call syscall_unlink/disp32 - # syscall(exit, b) + # exit(b) # . load b bb/copy-to-ebx B/imm32 8b/copy 0/mod/indirect 3/rm32/ebx . . . 3/r32/ebx . . # copy *ebx to ebx # - b8/copy-to-eax 1/imm32/exit - cd/syscall 0x80/imm8 + e8/call syscall_exit/disp32 -== data 0x0a000000 +== data Stream: 0/imm32 |