Author Topic: assembly conversions  (Read 6926 times)

0 Members and 1 Guest are viewing this topic.

Brian Alvarez

  • Guest
Re: assembly conversions
« Reply #15 on: August 22, 2020, 02:38:12 AM »
Thanks Charles, ill give it another go this afternoon.

Charles Pegge

  • Guest
Re: assembly conversions
« Reply #16 on: August 22, 2020, 05:36:44 AM »
mods in Tokenize:

at the start:
Code: [Select]
'    ASCIIZ PTR addrptr
'    @addrptr = (STRPTR(sourceinput))
sys addrptr=STRPTR(sourceinput)
    push ebx
    mov edi, w
    mov esi, addrptr

at the end:
Code: [Select]
storekeyword:
    inc edi
    mov a, esi
    mov c, cl
    mov l, edx
    mov w, edi
    mov k, ah
pop ebx
mbox "ok1"
    ¤UDT_SETV(dictionary, dictionary.m(w), (0), DWORD, (a), 4)
    ¤UDT_SETV(dictionary, dictionary.m(w), (4), INTEGER, (l), 2)
    ¤UDT_SETV(dictionary, dictionary.m(w), (6), BYTE, ¤BytOvf(k), 1)
    ¤PRINTSTR("=================", 1)
    ¤PRINTSTR(STR$(w, null), 1)
    ¤PRINTSTR(STR$(a, null), 1)
    ¤PRINTSTR(STR$(c, null), 1)
    ¤PRINTSTR(STR$(l, null), 1)
    ¤PRINTSTR(STR$(k, null), 1)
'    jmp checknext
'can't get here with that jump
mbox "ok2"
    RETURN ¤RETVAL
END FUNCTION

Brian Alvarez

  • Guest
Re: assembly conversions
« Reply #17 on: August 22, 2020, 02:53:32 PM »
 Ok i think i got the conversions working. I now need to convert the behavior of MOV for BASIC. It makes no sense, i think the guides are oudated...

 In some flavors MOV passes the variable byval and in order to pass its address to a register it requires LEA...  in such cases INC increases its value and you can move the value back to a variable using MOV back. Makes sense.

 In some other codes, using MOV pasess the address of the variable to a register, and using INC increases the address. It  requires a special syntax to increase its value (INC with the address directly does nothing) and LEA is not required... This also makes sense but i dont know what guide to follow.

Brian Alvarez

  • Guest
Re: assembly conversions
« Reply #18 on: August 22, 2020, 03:07:07 PM »

 Yup. The sample tokenizer now compiles fine for PowerBASIC and Oxygen without tweakings required. Ill try some benchmarks later. :)

Charles Pegge

  • Guest
Re: assembly conversions
« Reply #19 on: August 22, 2020, 03:59:52 PM »
A typical direct local variable might be [ebp-108] and lea (load effective address) would resolve its absolute address by subtracting 108 from the ebp value, and storing this value in the target register.

lea ecx,[ebp-108]

you could now use [ecx] to access the variable.

mov eax,[ecx]
...
inc ecx 'next byte

Brian Alvarez

  • Guest
Re: assembly conversions
« Reply #20 on: August 22, 2020, 05:05:26 PM »
 Thanks Charles, I think I have implemented that and few other tricks. However i have a question. I can do,

Code: [Select]
mov ebx, dwordvar
 I can also do:

Code: [Select]
mov ch, [esi]
and:

Code: [Select]
mov ch, 64
 But i am having problems doing:

Code: [Select]
mov ch, bytevar
 How can i pass a byte value from a byte variable into the subregister ch and the other 8 bit ones? I imagine i can create a copy into another register, but is there a more direct way without creating a copy?
« Last Edit: August 22, 2020, 05:30:01 PM by Brian Alvarez »

Brian Alvarez

  • Guest
Re: assembly conversions
« Reply #21 on: August 22, 2020, 06:28:22 PM »

 Basically i am doing this (see image attached).

 I am backing up and restoring registers correctly between ASM/BASIC code.

 s is a byte variable.

Code: [Select]
mov ch, s
 But it doesnt seem to work.

 The whole rest works marvelously! :)

Charles Pegge

  • Guest
Re: assembly conversions
« Reply #22 on: August 23, 2020, 12:02:31 AM »
How have you defined s. Is it a direct integer or byte?

Brian Alvarez

  • Guest
Re: assembly conversions
« Reply #23 on: August 23, 2020, 03:17:27 AM »
It is defined as:

Code: [Select]
byte s

Charles Pegge

  • Guest
Re: assembly conversions
« Reply #24 on: August 23, 2020, 05:39:43 AM »
is s local? If not, assign to a local byte.

Brian Alvarez

  • Guest
Re: assembly conversions
« Reply #25 on: August 23, 2020, 05:47:05 AM »

Got it. It worked. :)

JRS

  • Guest
Re: assembly conversions
« Reply #26 on: August 23, 2020, 07:55:49 AM »
Watching you guys work together is better than going to the movies.  8)


Brian Alvarez

  • Guest
Re: assembly conversions
« Reply #27 on: August 23, 2020, 08:11:43 AM »
 PowerBASIC's TIMER function displays slightly different measurements, but so far Oxygen is leading the benchmarks.  :o :o :o :o

 Hopefully this keeps like this when i fiish debugging completely the conversions and i test using GetTickCount().  :)

« Last Edit: August 23, 2020, 08:48:55 AM by Brian Alvarez »

JRS

  • Guest
Re: assembly conversions
« Reply #28 on: August 23, 2020, 10:47:43 AM »
It would be interesting to see how FreeBasic compares between PB and O2.

Would BCX be a good reference to use as a C translated BASIC?
« Last Edit: August 23, 2020, 10:57:31 AM by John »

Charles Pegge

  • Guest
Re: assembly conversions
« Reply #29 on: August 23, 2020, 11:10:33 AM »
In FreeBasic, Assembler blocks require asm .. end asm, and the variable names are contained within square brackets.

thus:

Code: [Select]
dim as long a
asm
  mov eax,[a]
  inc eax
  mov [a],eax
end asm
...
[code]