Oxygen Basic

Programming => Problems & Solutions => Topic started by: Brian Alvarez on March 18, 2020, 12:21:28 PM

Title: quad macro functions
Post by: Brian Alvarez on March 18, 2020, 12:21:28 PM

 Hello Charles, are macrofunctions supposed to support quads?
Title: Re: quad macro functions
Post by: Charles Pegge on March 18, 2020, 01:33:22 PM
Yes, macro functions can be of any type.
Title: Re: quad macro functions
Post by: Brian Alvarez on March 18, 2020, 04:09:00 PM
 This does not compile (v1 and v2 are dwords)

Code: [Select]
macro ¤OR quad(r, v1, v2) 
  r = v1 or v2
end macro

Code: [Select]
ERROR: ASSEMBLER:
 ERR: qword [ebp-60]!!  Unidentified instruction: qword
LINE: 2083
FILE: "main source

this compiles but after a few calls to the function other areas of the program start to fall apart:

Code: [Select]
FUNCTION ¤OR(byval quad v1, v2) as quad
  addr rcx,v1
  addr rdx,v2
  mov eax,[rcx]
  or eax,[rdx]
  mov [rcx],eax
  mov eax,[rcx+3]
  or eax,[rdx+3]
  mov [rcx+3],eax
  return v1
end function

This works and it is completely stable but does not work with quads:

Code: [Select]
macro ¤OR dword(r, v1, v2) 
  r = v1 or v2
end macro

Title: Re: quad macro functions
Post by: Brian Alvarez on March 18, 2020, 04:56:29 PM
 I found a workaround but im not sure how big is the cpu footprint:

Code: [Select]
FUNCTION ¤OR2(byval quad v1, v2) as quad
  addr rcx,v1
  addr rdx,v2
  mov eax,[rcx]
  or eax,[rdx]
  mov [rcx],eax
  mov eax,[rcx+3]
  or eax,[rdx+3]
  mov [rcx+3],eax
  return v1
end function

macro ¤OR quad(r, v1, v2) 
  r = ¤OR2((quad)v1, (quad)v2)
end macro
Title: Re: quad macro functions
Post by: Charles Pegge on March 19, 2020, 12:29:21 AM
The quad type does not support bitwise operations directly. You can use sys instead for 64bit mode.
Title: Re: quad macro functions
Post by: Brian Alvarez on March 19, 2020, 10:06:08 AM
Would that allow bitwise operations on quads for 32bit mode?