Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add x86 "int" instruction, use it in gsc/_t-x86.scm to call OS, produ…

…ce listing on standard error, and modify gsc/runtests.scm to leave standard error alone so that assembly code listing can be examined.
  • Loading branch information...
commit 090ff9f63121cf001c6f679e5ea06db0796e6cd1 1 parent f3e4b52
@feeley authored
View
8 gsc/_t-x86.scm
@@ -114,7 +114,7 @@
(let* ((code (asm-assemble-to-u8vector cgc))
(fixups (codegen-context-fixup-list cgc)))
(if show-listing?
- (asm-display-listing cgc (current-output-port) #t))
+ (asm-display-listing cgc (current-error-port) #t))
(u8vector->procedure code fixups))))
@@ -425,7 +425,7 @@
(x86-translate-procs cgc)
(entry-point cgc (list-ref procs 0))
- (let ((f (create-procedure cgc #f)))
+ (let ((f (create-procedure cgc #t)))
(f)))
#f)
@@ -726,7 +726,7 @@
(x86-push cgc (x86-imm-int 1)) ;; "stdout" is file descriptor 1
(x86-push cgc (x86-imm-int 0)) ;; reserve space for system call
(x86-mov cgc (x86-eax) (x86-imm-int 4)) ;; "write" system call is 4
- (asm-8 cgc #xcd) (asm-8 cgc #x80) ;; perform system call (int 0x80)
+ (x86-int cgc #x80) ;; perform system call (int 0x80)
(x86-add cgc (x86-esp) (x86-imm-int 20)) ;; pop what was pushed
(x86-ret cgc))
((x86-64)
@@ -759,7 +759,7 @@
(x86-mov cgc (x86-edx) (x86-imm-int 1)) ;; number of bytes to write = 1
(x86-mov cgc (x86-ebx) (x86-imm-int 1)) ;; "stdout" is file descriptor 1
(x86-mov cgc (x86-eax) (x86-imm-int 4)) ;; "write" system call is 4
- (asm-8 cgc #xcd) (asm-8 cgc #x80) ;; perform system call (int 0x80)
+ (x86-int cgc #x80) ;; perform system call (int 0x80)
(x86-add cgc (x86-esp) (x86-imm-int 4)) ;; pop what was pushed
(x86-pop cgc (x86-edx))
(x86-pop cgc (x86-ecx))
View
2  gsc/_x86#.scm
@@ -188,6 +188,8 @@ x86-sti
x86-cld
x86-std
+x86-int
+
x86-syscall
x86-sysret
x86-wrmsr
View
13 gsc/_x86.scm
@@ -954,6 +954,19 @@
;;;----------------------------------------------------------------------------
+;;; X86 instruction: INT.
+
+(define (x86-int cgc n)
+ (asm-8 cgc #xcd) ;; opcode
+ (asm-8 cgc n)
+ (if (codegen-context-listing-format cgc)
+ (x86-listing cgc
+ "int"
+ 0
+ (x86-imm-int n 0))))
+
+;;;----------------------------------------------------------------------------
+
;;; X86 instructions: SYSCALL, SYSRET, WRMSR, RDTSC, RDMSR, RDPMC,
;;; and CPUID.
View
3  gsc/runtests.scm
@@ -15,7 +15,8 @@
(let* ((port
(open-process (list path: path
arguments: args
- stderr-redirection: #t)))
+ ;; stderr-redirection: #t
+ )))
(output
(read-line port #f))
(status
View
2  include/stamp.h
@@ -3,4 +3,4 @@
*/
#define ___STAMP_YMD 20120706
-#define ___STAMP_HMS 41822
+#define ___STAMP_HMS 130445
Please sign in to comment.
Something went wrong with that request. Please try again.