Category: 未分类

  • The simplest working compiler!

    比较弱智,呵呵。 源程序如下: class Program { static int i; static int j; static boolean b; static void Main() { i = 3 * 5; j = i + 10; func(); print(j); } static void func() { print(i); } } 翻译成汇编码: .section    .rodata format: .string    “%dn” .text .globl main .type    main, @function main: pushl    %ebp movl    %esp,…

  • GAS编译的第一个汇编小程序

    在Linux里写了第一个汇编小程序,呵呵,输入两个数字,计算出结果并显示。 保存为example.s, # gcc -o example example.s .section .rodata prompt: .string “Please input an integer:” format: .string “%d” oform: .string “%d + %d = %dn” .text .globl main .type main, @function main: pushl %ebp movl %esp, %ebp subl $32, %esp andl $-16, %esp movl $0, %eax subl %eax, %esp ;Instructions above have nothing meaningful. movl…

  • AT&T assembly syntax

    记得以前是弄过Windows里的汇编的,还调用了printf。现在不知道为什么不会弄了,只好转入Linux。现转载一篇AT&T语法格式的介绍(原文 h ttp://www.delorie.com/djgpp/doc/brennan/brennan_att_inline_djgpp.html ): Register naming: Register names are prefixed with “%”. To reference eax: AT&T: %eax Intel: eax Source/Destination Ordering: In AT&T syntax (which is the UNIX standard, BTW) the source is always on the left, and the destination is always on the right. So let’s load ebx with the value in eax: AT&T:…

  • 锻炼身体,好好学习

    上大学后体质越来越差了,上学期竟得了气胸,唉。 最近决定每天早上打会篮球,昨天早上去了,中午没睡觉,结果今天早上没起来,中等补打了会,呵呵。坚持下去,身体会好起来的。 记得高中的时候,在家里摸那个房梁,可以超半截手指的,这次回家只摸到了一次,后来再也摸不到了。。。