flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
raoul 04 Aug 2021, 00:10
Hi,
For further learning after 'Hello World', I am attempting a remake of JonesForth, originally writen in GAS. I am stuck on translating the following, where the defvar macro passes its arguments to a nested defcode macro: Code: .macro defcode name, namelen, flags=0, label .section .rodata .align 4 .globl name_\label name_\label : .int link // link .set link,name_\label .byte \flags+\namelen // flags + length byte .ascii "\name" // the name .align 4 // padding to next 4 byte boundary .globl \label \label : .int code_\label // codeword .text //.align 4 .globl code_\label code_\label : // assembler code follows .endm .macro defvar name, namelen, flags=0, label, initial=0 defcode \name,\namelen,\flags,\label push $var_\name NEXT .data .align 4 var_\name : .int \initial .endm ... with example uses: Code: defcode "XOR",3,,XOR // bitwise XOR pop %eax xorl %eax,(%esp) NEXT defvar "S0",2,,SZ My attempts that result in: Quote: Error: symbol already defined << link dd name_SZ >> forth.asm Code: macro defcode nm,namelen,flags:0,label { section 'rodata' readable align 8 name_#label#: link dd name_#label db flags + namelen db `nm align 8 label#: dd code_#label section 'text' readable executable code_#label#: } macro defvar name,namelen,flags:0,label,initial:0 { defcode name,namelen,flags,label push var_#name NEXT section 'data' readable writable align 8 var_#name#: dd initial } I tried to sprinkle some 'local' declarations, which modifies the error without improving my understanding of the issue at hand. Would you please help a beginner? Thanks! |
|||
![]() |
|
raoul 04 Aug 2021, 07:30
Ah yes, thank you! I was so fixated on the 'name_#label' part that I forgot about the 'link' part.
Now, I have another error but clearly I don't understand the code well enough because 'link' is used elsewhere, so back to studying I guess! :-S |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.