Author Topic: quad macro functions  (Read 1758 times)

0 Members and 1 Guest are viewing this topic.

Brian Alvarez

  • Hero Member
  • *****
  • Posts: 586
    • PluriBASIC
quad macro functions
« on: March 18, 2020, 12:21:28 PM »

 Hello Charles, are macrofunctions supposed to support quads?

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4327
    • Oxygen Basic
Re: quad macro functions
« Reply #1 on: March 18, 2020, 01:33:22 PM »
Yes, macro functions can be of any type.

Brian Alvarez

  • Hero Member
  • *****
  • Posts: 586
    • PluriBASIC
Re: quad macro functions
« Reply #2 on: March 18, 2020, 04:09:00 PM »
 This does not compile (v1 and v2 are dwords)

Code: [Select]
macro 力R 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 力R(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 力R dword(r, v1, v2) 
  r = v1 or v2
end macro


Brian Alvarez

  • Hero Member
  • *****
  • Posts: 586
    • PluriBASIC
Re: quad macro functions
« Reply #3 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 力R2(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 力R quad(r, v1, v2) 
  r = 力R2((quad)v1, (quad)v2)
end macro

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4327
    • Oxygen Basic
Re: quad macro functions
« Reply #4 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.

Brian Alvarez

  • Hero Member
  • *****
  • Posts: 586
    • PluriBASIC
Re: quad macro functions
« Reply #5 on: March 19, 2020, 10:06:08 AM »
Would that allow bitwise operations on quads for 32bit mode?