### -------------------------------------------------------------------- ### uppercase.s ### Author: Bob Dondero ### -------------------------------------------------------------------- .equ LOWER_TO_UPPER, -32 ### -------------------------------------------------------------------- .section ".rodata" ### -------------------------------------------------------------------- .section ".data" ### -------------------------------------------------------------------- .section ".bss" cChar: .skip 1 ### -------------------------------------------------------------------- .section ".text" ## ------------------------------------------------------------- ## Read a letter from stdin, and write its uppercase ## equivalent to stdout. Return 0. ## int main(void) ## ------------------------------------------------------------- .globl main .type main,@function main: pushl %ebp movl %esp, %ebp ## cChar = (char)getchar() call getchar movb %al, cChar ## cChar += LOWER_TO_UPPER addb $LOWER_TO_UPPER, cChar ## putchar((int)cChar) movb cChar, %al andl $0xff, %eax # Clear high-order 3 bytes of EAX. pushl %eax call putchar addl $4, %esp ## putchar('\n') pushl $'\n' call putchar addl $4, %esp ## return 0 movl $0, %eax movl %ebp, %esp popl %ebp ret