### -------------------------------------------------------------------- ### uppercase.s ### Author: Bob Dondero ### Byte Instructions, the .equ directive ### -------------------------------------------------------------------- .equ LOWER_TO_UPPER, -32 .section ".rodata" cScanfFormat: .asciz "%c" cPrintfFormat: .asciz "%c\n" ### -------------------------------------------------------------------- .section ".data" ### -------------------------------------------------------------------- .section ".bss" cChar: .skip 1 ### -------------------------------------------------------------------- .section ".text" ## ------------------------------------------------------------- ## int main(void) ## Read a letter from stdin, and write its uppercase ## equivalent to stdout. Return 0. ## ------------------------------------------------------------- .globl main .type main,@function main: pushl %ebp movl %esp, %ebp ## scanf("%c", &cChar) pushl $cChar pushl $cScanfFormat call scanf addl $8, %esp ## cChar += LOWER_TO_UPPER movb cChar, %al addb $LOWER_TO_UPPER, %al movb %al, cChar ## printf("%c\n", cChar) movl $0, %eax movb cChar, %al pushl %eax pushl $cPrintfFormat call printf addl $8, %esp ## return 0 movl $0, %eax movl %ebp, %esp popl %ebp ret