### ------------------------------------------------------------------ ### uppercase.s ### Author: Bob Dondero ### Byte Instructions ### ------------------------------------------------------------------ .section ".rodata" cScanfFormat: .asciz "%c" cPrintfFormat: .asciz "%c\n" ### ------------------------------------------------------------------ .section ".data" ### ------------------------------------------------------------------ .section ".bss" cChar: .skip 1 ### ------------------------------------------------------------------ .section ".text" ## ----------------------------------------------------------- ## int main(int argc, char *argv[]) ## Read a letter from stdin, and write its uppercase ## equivalent to stdout. ## ----------------------------------------------------------- ## Formal parameter offsets: .equ ARGC, 8 .equ ARGV, 12 .globl main .type main,@function main: pushl %ebp movl %esp, %ebp ## scanf("%c", &cChar); pushl $cChar pushl $cScanfFormat call scanf addl $8, %esp ## cChar = (char)toupper((int)cChar); movl $0, %eax movb cChar, %al pushl %eax call toupper addl $4, %esp 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