Use extended mnemonics and ha16/lo16.
Remove wrong comment: that's a right shift, not a left shift.
This commit is contained in:
parent
103d44c27c
commit
f1304e1a3c
|
@ -32,7 +32,7 @@ begtext:
|
||||||
|
|
||||||
lwz r3, 0(sp) ! r3 = argc
|
lwz r3, 0(sp) ! r3 = argc
|
||||||
addi r4, sp, 4 ! r4 = argv
|
addi r4, sp, 4 ! r4 = argv
|
||||||
rlwinm r5, r3, 32-2, 2, 31 ! shift left 2 bits
|
srwi r5, r3, 2
|
||||||
add r5, r5, r4
|
add r5, r5, r4
|
||||||
addi r5, r5, 8 ! r5 = env
|
addi r5, r5, 8 ! r5 = env
|
||||||
|
|
||||||
|
|
|
@ -12,16 +12,7 @@
|
||||||
|
|
||||||
.sect .text
|
.sect .text
|
||||||
|
|
||||||
EINVAL = 22
|
#define EINVAL 22
|
||||||
|
|
||||||
#define IFFALSE 4
|
|
||||||
#define IFTRUE 12
|
|
||||||
#define ALWAYS 20
|
|
||||||
|
|
||||||
#define LT 0
|
|
||||||
#define GT 1
|
|
||||||
#define EQ 2
|
|
||||||
#define OV 3
|
|
||||||
|
|
||||||
! Perform a Linux system call.
|
! Perform a Linux system call.
|
||||||
|
|
||||||
|
@ -32,21 +23,21 @@ __syscall:
|
||||||
lwz r4, 8(sp)
|
lwz r4, 8(sp)
|
||||||
lwz r5, 12(sp)
|
lwz r5, 12(sp)
|
||||||
sc 0
|
sc 0
|
||||||
bclr IFFALSE, OV, 0
|
bnslr
|
||||||
|
|
||||||
! On error, r3 contains the errno.
|
! On error, r3 contains the errno.
|
||||||
! It just so happens that errnos 1-34 are the same in Linux as in ACK.
|
! It just so happens that errnos 1-34 are the same in Linux as in ACK.
|
||||||
cmpi cr0, 0, r3, 1
|
cmpwi r3, 1
|
||||||
bc IFTRUE, LT, 2f
|
blt 2f
|
||||||
cmpi cr0, 0, r3, 34
|
cmpwi r3, 34
|
||||||
bc IFTRUE, GT, 2f
|
bgt 2f
|
||||||
|
|
||||||
3:
|
3:
|
||||||
li32 r4, _errno
|
lis r4, ha16[_errno]
|
||||||
stw r3, 0(r4)
|
stw r3, lo16[_errno](r4)
|
||||||
addi r3, r0, -1
|
li r3, -1
|
||||||
bclr ALWAYS, 0, 0
|
blr
|
||||||
|
|
||||||
2:
|
2:
|
||||||
addi r3, r0, EINVAL
|
li r3, EINVAL
|
||||||
b 3b
|
b 3b
|
||||||
|
|
|
@ -29,7 +29,7 @@ begtext:
|
||||||
|
|
||||||
lwz r3, 0(sp) ! r3 = argc
|
lwz r3, 0(sp) ! r3 = argc
|
||||||
addi r4, sp, 4 ! r4 = argv
|
addi r4, sp, 4 ! r4 = argv
|
||||||
rlwinm r5, r3, 32-2, 2, 31 ! shift left 2 bits
|
srwi r5, r3, 2
|
||||||
add r5, r5, r4
|
add r5, r5, r4
|
||||||
addi r5, r5, 8 ! r5 = env
|
addi r5, r5, 8 ! r5 = env
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
.sect .text
|
.sect .text
|
||||||
.define .set_errno
|
.define .set_errno
|
||||||
.set_errno:
|
.set_errno:
|
||||||
li32 r10, _errno
|
lis r4, ha16[_errno]
|
||||||
stw r3, 0(r10) ! set errno
|
stw r3, lo16[_errno](r4) ! set errno
|
||||||
addi r3, r0, -1 ! return -1
|
li r3, -1 ! return -1
|
||||||
bclr 20, 0, 0
|
blr
|
||||||
|
|
Loading…
Reference in a new issue