1 /* Test program for byte registers. 2 3 Copyright 2010-2023 Free Software Foundation, Inc. 4 5 This file is part of GDB. 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 3 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 19 20 #include <stdio.h> 21 22 int data[] = { 23 0x14131211, 24 0x24232221, 25 0x34333231, 26 0x44434241, 27 }; 28 29 int 30 main (int argc, char **argv) 31 { 32 register int eax asm ("eax"); 33 register int ebx asm ("ebx"); 34 register int ecx asm ("ecx"); 35 register int edx asm ("edx"); 36 37 asm ("mov 0(%0), %%eax\n\t" 38 "mov 4(%0), %%ebx\n\t" 39 "mov 8(%0), %%ecx\n\t" 40 "mov 12(%0), %%edx\n\t" 41 : /* no output operands */ 42 : "r" (data) 43 : "eax", "ebx", "ecx", "edx"); 44 45 asm ("nop" /* first breakpoint here */ 46 /* i386-{byte,word}.exp write eax-edx here. 47 Tell gcc/clang they're live. */ 48 : "=r" (eax), "=r" (ebx), "=r" (ecx), "=r" (edx) 49 : /* no inputs */); 50 51 asm ("mov %%eax, 0(%0)\n\t" 52 "mov %%ebx, 4(%0)\n\t" 53 "mov %%ecx, 8(%0)\n\t" 54 "mov %%edx, 12(%0)\n\t" 55 : /* no output operands */ 56 : "r" (data), 57 /* Mark these as inputs so that gcc/clang won't try to use them as 58 a temp to build %0. */ 59 "r" (eax), "r" (ebx), "r" (ecx), "r" (edx)); 60 puts ("Bye!"); /* second breakpoint here */ 61 62 return 0; 63 } 64