Author Topic: Assemby code failed  (Read 3613 times)

0 Members and 2 Guests are viewing this topic.

Peter

  • Guest
Assemby code failed
« on: September 10, 2012, 11:25:44 AM »
Deleted
« Last Edit: May 05, 2015, 11:44:48 AM by Peter »

jumpandrun

  • Guest
Re: Assemby code failed
« Reply #1 on: December 24, 2012, 09:56:04 AM »
Hi & wanted to reuse this thread bcause my ? is about a prob with asm:

OB seems not to understand i.e. "lodsb" & family; also, i.e. lea reg, var + imm yields lea reg, var

Does OB have anonymous labels and relative branching (i.e. branch backward/forward to next/nearest label)?




X
« Last Edit: December 24, 2012, 10:25:25 AM by jumpandrun »

Charles Pegge

  • Guest
Re: Assemby code failed
« Reply #2 on: December 24, 2012, 08:54:54 PM »
Unfinished work

Now supported:

rep repnz repz repe repne
ins lods movs outs cmps stos scas
insb lodsb movsb outsb cmpsb stosb scasb
insw lodsw movsw outsw cmpsw stosw scasw
insd lodsd movsd outsd cmpsd stosd scasd
insq lodsq movsq outsq cmpsq stosq scasq   (64bit)



Code: [Select]

sys a[100]
sys b

indexbase 0

a[0]=0x32210
a[1]=0x32211
a[2]=0x32212


lea esi,a ' same as lea esi,[a]
lodsb

'print hex al '10

def offs 4
lea esi,[@a+offs]
lodsb

'print hex al '11

mov ecx,3
lea esi,[@a+0]
lea edi,[@a+40]
(
 lods
 stos
 dec ecx
 jnz repeat
)

'print hex a[11] '32211

mov ecx,3
mov eax,0x12345678
lea edi,[@a+80]
rep stos

print hex a[22] '12345678


Charles
« Last Edit: December 25, 2012, 01:29:03 PM by Charles Pegge »

jumpandrun

  • Guest
Re: Assemby code failed
« Reply #3 on: December 25, 2012, 02:12:12 AM »
Excellent support as always. Thank you Sir.

So, what else is unfinished :D Just kidding.

Charles Pegge

  • Guest
Re: Assemby code failed
« Reply #4 on: December 25, 2012, 10:56:10 AM »
Ok Peter,

You can use pushf and popf - same opcodes: 9c 9d

Charles Pegge

  • Guest
Re: Assemby code failed
« Reply #5 on: December 25, 2012, 01:21:50 PM »
 :o

It was using an integer start number - should have adopted float. Sorry!

(pushfd popfd should now work too)
« Last Edit: December 25, 2012, 09:29:29 PM by Charles Pegge »

Charles Pegge

  • Guest
Re: Assemby code failed
« Reply #6 on: December 25, 2012, 09:31:52 PM »
And again
« Last Edit: December 27, 2012, 03:00:03 AM by Charles Pegge »

jumpandrun

  • Guest
Re: Assemby code failed
« Reply #7 on: December 26, 2012, 03:58:47 AM »
This is also cool:

does not work:

Code: [Select]
int a = 1

mov eax, @a
add [eax], 10

print a

but this does:

Code: [Select]
int a = 1
int* p
@p = @a
p = 1

mov eax, @a
add [eax], 10

print a

Charles Pegge

  • Guest
Re: Assemby code failed
« Reply #8 on: December 26, 2012, 04:45:34 AM »
Hi Jumpandrun,

expressions like mov eax,@a are not cuurently supported but you can do lea eax,a if a is direct.

use a basic expression to resolve the address of a variable, direct or indirect. It always works

sys p=@a

Code: [Select]
function f(sys*a) as sys
sys p=@a
mov ecx,p
return [ecx+4]
end function


indexbase 1

sys aa[10]={1,2,3,4,5,6,7,8,9,10}

print f aa[2] 'result: 3

Charles
« Last Edit: December 26, 2012, 05:14:37 AM by Charles Pegge »

Charles Pegge

  • Guest
Re: Assemby code failed
« Reply #9 on: December 26, 2012, 05:19:14 AM »

You can expose any part of a program to view the assembly code by using ### block markers . (using Scite F7)

Code: [Select]
###
function f(sys*a) as sys
sys p=@a
mov ecx,p
return [ecx+4]
end function
###
--->
Code: [Select]
#view
'_3


'FUNCTION F

jmp fwd _over_
o2 !10
.f#sys
(
push ebp
mov ebp,esp
add esp,-20
lea edi,[ebp-16]
xor eax,eax
mov [edi],eax
lea edi,[ebp-20]
xor eax,eax
mov [edi],eax
lea edi,[ebp+8]
mov eax,[edi]
mov [ebp-20],eax
'_5
mov ecx,[ebp-20]
'_6
mov eax,[ecx+4]
jmp fwd _return_
'_7

._exit_
mov eax,[ebp-16]
._return_
mov esp,ebp
pop ebp
ret 4

)
._over_
'_8
#endv

Charles

Charles Pegge

  • Guest
Re: Assemby code failed
« Reply #10 on: December 27, 2012, 02:57:27 AM »
Christmas Present :)

I have created a pseudo-instruction: addr
Example:

sys a=42
addr ecx,a
print [ecx] 'result 42

It will work with byval and byref variables.

Code: [Select]
type tt
  sys w,x,y,z
end type

tt a={1,2,3,4}

function fy(tt*v) as sys
  addr ecx,v.y
  return [ecx]
end function

print fy a 'result 3


X
« Last Edit: December 27, 2012, 03:02:57 AM by Charles Pegge »