Last active
August 14, 2017 20:45
-
-
Save cedriczirtacic/cd83c65ba533cd6a0c55041fa3198953 to your computer and use it in GitHub Desktop.
check if 64 or 32 bits using CS segment (64=33, 32=23)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To try it in i386: | |
// as --32 -o cs.o cs.S && ld -melf_i386 -o cs cs.o | |
.section .text | |
.global _start | |
_start: | |
movw %cs, %cx | |
shr $4, %cx | |
cmpb $3, %cl | |
je x86_64 | |
jmp i386 | |
x86_64: | |
movb $60, %al | |
movw $64, %di | |
syscall | |
i386: | |
movb $1, %al | |
movw $32, %bx | |
int $0x80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment