mirror of
https://github.com/pkivolowitz/asm_book.git
synced 2026-06-21 01:46:46 +08:00
added macro to fetch the address of errno
This commit is contained in:
parent
e73fac71b5
commit
b6b5b96c56
7 changed files with 73 additions and 2 deletions
|
|
@ -185,10 +185,21 @@ library, use this macro in this way:
|
|||
|
||||
`CRT strlen`
|
||||
|
||||
An underscore is prepended.
|
||||
An underscore is prepended on the Mac.
|
||||
|
||||
## Declaring `main()`
|
||||
|
||||
Put `MAIN` on a line by itself. Notice there is no colon.
|
||||
|
||||
An underscore is prepended.
|
||||
An underscore is prepended on the Mac.
|
||||
|
||||
## `errno`
|
||||
|
||||
The externally defined `errno` is accessed via a CRT function which
|
||||
isn't seen when coding in C and C++. The function is named differently
|
||||
on Mac versus Linux. To get the address of `errno` use:
|
||||
|
||||
`ERRNO_ADDR`
|
||||
|
||||
This macro makes the correct CRT call and leaves the address of `errno`
|
||||
in `x0`.
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -75,6 +75,18 @@ main:
|
|||
#endif
|
||||
.endm
|
||||
|
||||
/* Fetching the address of the externally defined errno is quite
|
||||
different on Apple and Linux. This macro leaves the address of
|
||||
errno in x0.
|
||||
*/
|
||||
.macro ERRNO_ADDR
|
||||
#if defined(__APPLE__)
|
||||
bl ___error
|
||||
#else
|
||||
bl __errno_location
|
||||
#endif
|
||||
.endm
|
||||
|
||||
.macro CRT label
|
||||
#if defined(__APPLE__)
|
||||
bl _\label
|
||||
|
|
|
|||
|
|
@ -75,6 +75,18 @@ main:
|
|||
#endif
|
||||
.endm
|
||||
|
||||
/* Fetching the address of the externally defined errno is quite
|
||||
different on Apple and Linux. This macro leaves the address of
|
||||
errno in x0.
|
||||
*/
|
||||
.macro ERRNO_ADDR
|
||||
#if defined(__APPLE__)
|
||||
bl ___error
|
||||
#else
|
||||
bl __errno_location
|
||||
#endif
|
||||
.endm
|
||||
|
||||
.macro CRT label
|
||||
#if defined(__APPLE__)
|
||||
bl _\label
|
||||
|
|
|
|||
|
|
@ -75,6 +75,18 @@ main:
|
|||
#endif
|
||||
.endm
|
||||
|
||||
/* Fetching the address of the externally defined errno is quite
|
||||
different on Apple and Linux. This macro leaves the address of
|
||||
errno in x0.
|
||||
*/
|
||||
.macro ERRNO_ADDR
|
||||
#if defined(__APPLE__)
|
||||
bl ___error
|
||||
#else
|
||||
bl __errno_location
|
||||
#endif
|
||||
.endm
|
||||
|
||||
.macro CRT label
|
||||
#if defined(__APPLE__)
|
||||
bl _\label
|
||||
|
|
|
|||
|
|
@ -75,6 +75,18 @@ main:
|
|||
#endif
|
||||
.endm
|
||||
|
||||
/* Fetching the address of the externally defined errno is quite
|
||||
different on Apple and Linux. This macro leaves the address of
|
||||
errno in x0.
|
||||
*/
|
||||
.macro ERRNO_ADDR
|
||||
#if defined(__APPLE__)
|
||||
bl ___error
|
||||
#else
|
||||
bl __errno_location
|
||||
#endif
|
||||
.endm
|
||||
|
||||
.macro CRT label
|
||||
#if defined(__APPLE__)
|
||||
bl _\label
|
||||
|
|
|
|||
|
|
@ -75,6 +75,18 @@ main:
|
|||
#endif
|
||||
.endm
|
||||
|
||||
/* Fetching the address of the externally defined errno is quite
|
||||
different on Apple and Linux. This macro leaves the address of
|
||||
errno in x0.
|
||||
*/
|
||||
.macro ERRNO_ADDR
|
||||
#if defined(__APPLE__)
|
||||
bl ___error
|
||||
#else
|
||||
bl __errno_location
|
||||
#endif
|
||||
.endm
|
||||
|
||||
.macro CRT label
|
||||
#if defined(__APPLE__)
|
||||
bl _\label
|
||||
|
|
|
|||
Loading…
Reference in a new issue