#====================================================================== # uppercase.s # Byte Instructions #====================================================================== #====================================================================== .section ".rodata" #====================================================================== pcScanfFormat: .asciz "%c" pcPrintfFormat: .asciz "%c\n" #====================================================================== .section ".data" #====================================================================== #====================================================================== .section ".bss" #====================================================================== pcChar: .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 $pcChar pushl $pcScanfFormat call scanf addl $8, %esp # cChar = (char)toupper((int)cChar); movl $0, %eax movb pcChar, %al pushl %eax call toupper addl $4, %esp movb %al, pcChar # printf("%c\n", cChar); movl $0, %eax movb pcChar, %al pushl %eax pushl $pcPrintfFormat call printf addl $8, %esp # return 0; movl $0, %eax movl %ebp, %esp popl %ebp ret