Assembly Language for Beginners

(Jeff_L) #1
1.24. STRUCTURES
so it shows here structure elements accesses and their names.

Listing 1.335: Optimizing Xcode 4.6.3 (LLVM) (Thumb-2 mode)
var_38 = -0x38
var_34 = -0x34

PUSH {R7,LR}
MOV R7, SP
SUB SP, SP, #0x30
MOVS R0, #0 ; time_t *
BLX _time
ADD R1, SP, #0x38+var_34 ; struct tm *
STR R0, [SP,#0x38+var_38]
MOV R0, SP ; time_t *
BLX _localtime_r
LDR R1, [SP,#0x38+var_34.tm_year]
MOV R0, 0xF44 ; "Year: %d\n"
ADD R0, PC ; char *
ADDW R1, R1, #0x76C
BLX _printf
LDR R1, [SP,#0x38+var_34.tm_mon]
MOV R0, 0xF3A ; "Month: %d\n"
ADD R0, PC ; char *
BLX _printf
LDR R1, [SP,#0x38+var_34.tm_mday]
MOV R0, 0xF35 ; "Day: %d\n"
ADD R0, PC ; char *
BLX _printf
LDR R1, [SP,#0x38+var_34.tm_hour]
MOV R0, 0xF2E ; "Hour: %d\n"
ADD R0, PC ; char *
BLX _printf
LDR R1, [SP,#0x38+var_34.tm_min]
MOV R0, 0xF28 ; "Minutes: %d\n"
ADD R0, PC ; char *
BLX _printf
LDR R1, [SP,#0x38+var_34]
MOV R0, 0xF25 ; "Seconds: %d\n"
ADD R0, PC ; char *
BLX _printf
ADD SP, SP, #0x30
POP {R7,PC}

...

00000000 tm struc ; (sizeof=0x2C, standard type)
00000000 tm_sec DCD?
00000004 tm_min DCD?
00000008 tm_hour DCD?
0000000C tm_mday DCD?
00000010 tm_mon DCD?
00000014 tm_year DCD?
00000018 tm_wday DCD?
0000001C tm_yday DCD?
00000020 tm_isdst DCD?
00000024 tm_gmtoff DCD?
00000028 tm_zone DCD? ; offset
0000002C tm ends

MIPS

Listing 1.336: Optimizing GCC 4.4.5 (IDA)

1 main:
2
3 ; IDA is not aware of structure field names, we named them manually:
4
5 var_40 = -0x40

Free download pdf