Programming and Assembly Issues
Programming and Assembly Issues
1 (2004)
http://www.CodeBreakers-Journal.com
Abstract
The 64-Bit technology introduces several new and and complex tasks for software-developers. Even that the hardware
developing industry claims that future software development
should take care about the new introduced compiler systems,
it is necessary to have a deep inside view on how the
new underlaying 64-Bit assembly language works. This paper
describes what 64-Bit means for future software devlopments,
how 64-Bit influences assembly programming and how to port
applications programmed under 32-Bit to 64-Bit. It is heavy
R operationsysbased on the IA architecture and the Windows
tem.
Keywords: Assembly; 64-Bit; win64; Itanium; Athlon64; PortR Linux; EPIC
ing win32 to win64; Windows ;
I. Introduction
Fig. 1.
The AMD x86-64 differes from the IA-64 structure in important details (See figure 1). The developer has...
c 2004 and published by the CodeBreakers-Journal. Single print or electronic copies for personal use only are permitted. Reproduction and
Copyright
distribution without permission is prohibited.
assembly indirect
mnemonic access
--------------------------------------------application
ar
n
branch
b
n
control
cr
n
CPU identification
cpuid
y
data breakpoint
dbr
y
instriction breakpoint
ibr
y
data TLB translation
dtr
y
floating point
f
n
general
r
n
instruction TLB translation itr
y
protection key
pkr
y
performance monitor config pmc
y
performance monitor data
pmd
y
predicate
p
n
region
rr
y
the gp register.
and
In addition to the 32 static general-purpose registers,
the IA-64 also has 96 dynamic general-purpose
registers [...]. Dynamic means that a given register
name doesnt always refer to the exact same physical
register on the CPU. That is, a register such as
r34 in one function is likely to be assigned to a
completely different physical register than r34 in
another function.
For the dynamic registers he states:
Fig. 2.
AR0-AR7
AR8-AR15
AR16
equ AR.KR0-AR.KR7
equ AR.RSC
AR17
equ AR.BSP
AR18
equ AR.BSPRESTORE
AR19
AR20
AR21
equ AR.RNAT
equ AR.FCR
AR22,AR23
AR24
AR25
equ AR.EFLAG
equ AR.CSD
AR26
equ AR.SSD
AR27
AR28
AR29
AR30
AR31
AR32
equ
equ
equ
equ
equ AR.CCV
AR33-AR35
AR36
AR37-AR39
AR40
AR41-AR43
AR44
AR45-AR63
AR64
AR65
AR66
AR67-AR127
Fig. 3.
AR.CFLG
AR.FSR
AR.FIR
AR.FDR
equ AR.UNAT
equ AR.FPSR
equ AR.ITC
equ AR.PFS
equ AR.LC
equ AR.EC
kernel registers
RESERVED
register stack
configuration
backing store pointer
(read only)
backing store pointer
mem stores
RSE NaT collection
RESERVED
IA-32 floating-point
control
RESERVED
IA-32 EFLAG
IA-32 code segment
descriptor ||
compare and store data
IA-32 stack segment
descriptor
IA-32 combined CR0 and CR4
IA-32 floating point status
IA-32 floating point instr.
IA-32 floating point data
RESERVED
compare and exchange
compare value
RESERVED
user NaT collection
RESERVED
floatint point status
RESERVED
interval time counter
RESERVED / AR48- IGNORED
previous function state
loop count
epilog count
RESERVED / AR112- IGNORED
c 2004 and published by the CodeBreakers-Journal. Single print or electronic copies for personal use only are permitted. Reproduction and
Copyright
distribution without permission is prohibited.
R C++
After cleaning up some name mangling the Intel
Compiler produces the following assembly code [7]:
4
c 2004 and published by the CodeBreakers-Journal. Single print or electronic copies for personal use only are permitted. Reproduction and
Copyright
distribution without permission is prohibited.
whereas the large variant result into the following larger code
snippet where the variable itself is allocated in a separate
section of the file and a pointer to the variable is placed into
the small globals variables section of the module [3]:
addl
ld8
ld4
can be optimized to
add r19=1,r0 //0: 20 6
add r16=4,r33 //0: 21 31
add r18=-1,r32 //0: 21 32
{ .mmi
add r19=1,r0 //0: 20 6
add r16=4,r33 //0: 21 31
add r18=-1,r32 ;; //0: 21 32
}
5
c 2004 and published by the CodeBreakers-Journal. Single print or electronic copies for personal use only are permitted. Reproduction and
Copyright
distribution without permission is prohibited.
References
2004.
6
c 2004 and published by the CodeBreakers-Journal. Single print or electronic copies for personal use only are permitted. Reproduction and
Copyright
distribution without permission is prohibited.