Skip to content

Instantly share code, notes, and snippets.

@laqieer
Last active April 4, 2024 16:06
Show Gist options
  • Save laqieer/24dcba67310e9695f157e88ad716b248 to your computer and use it in GitHub Desktop.
Save laqieer/24dcba67310e9695f157e88ad716b248 to your computer and use it in GitHub Desktop.
Example to write string in UTF-8 encoded source file but tell compiler to store string in SJIS
#!/bin/sh
arm-none-eabi-gcc -S test.c
# https://gcc.gnu.org/onlinedocs/cpp/Invocation.html#index-fexec-charset
arm-none-eabi-gcc -S test.c -o test_sjis.s -fexec-charset=sjis
const char s[] = "ああ";
.cpu arm7tdmi
.eabi_attribute 20, 1
.eabi_attribute 21, 1
.eabi_attribute 23, 3
.eabi_attribute 24, 1
.eabi_attribute 25, 1
.eabi_attribute 26, 1
.eabi_attribute 30, 6
.eabi_attribute 34, 0
.eabi_attribute 18, 4
.file "test.c"
.text
.global s
.section .rodata
.align 2
.type s, %object
.size s, 7
s:
.ascii "\343\201\202\343\201\202\000"
.ident "GCC: (15:9-2019-q4-0ubuntu1) 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]"
.cpu arm7tdmi
.eabi_attribute 20, 1
.eabi_attribute 21, 1
.eabi_attribute 23, 3
.eabi_attribute 24, 1
.eabi_attribute 25, 1
.eabi_attribute 26, 1
.eabi_attribute 30, 6
.eabi_attribute 34, 0
.eabi_attribute 18, 4
.file "test.c"
.text
.global s
.section .rodata
.align 2
.type s, %object
.size s, 5
s:
.ascii "\202\240\202\240\000"
.ident "GCC: (15:9-2019-q4-0ubuntu1) 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment