feat(vm/compiler): export su_power function in case user needs it

This commit is contained in:
5684185+vsariola@users.noreply.github.com 2024-04-05 15:49:00 +03:00
parent beb84d7652
commit 6d4529971c
3 changed files with 18 additions and 7 deletions

View File

@ -21,6 +21,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Dbgain unit, which allows defining the gain in decibels (-40 dB to +40dB)
- `+` and `-` keys add/subtract values in order editor and pattern editor
([#65][i65])
- The function `su_power` is exported so people can reuse it in the main code;
however, as it assumes the parameter passed in st0 on the x87 stack and
similarly returns it value in st0 on the x87 stack, to my knowledge there is
no calling convention that would correspond this behaviour, so you need to
define a header for it yourself and take care of putting the float value on
x87 stack.
### Fixed
- When recording notes from VSTI, no track was created for instruments that had

View File

@ -114,6 +114,7 @@ su_op_advance_finish:
; Output: st0 : 2^x
;-------------------------------------------------------------------------------
{{- if not (.HasCall "su_nonlinear_map")}}{{.SectText "su_power"}}{{end}}
{{.Export "su_power" 0}}
su_power:
fld1 ; 1 x
fld st1 ; x 1 x

View File

@ -353,6 +353,16 @@ func (p *X86Macros) FmtStack() string {
return b.String()
}
func (p *X86Macros) Export(name string, numParams int) string {
if !p.Amd64 && p.OS == "windows" {
return fmt.Sprintf("global _%[1]v@%[2]v\n_%[1]v@%[2]v:", name, numParams*4)
}
if p.OS == "darwin" {
return fmt.Sprintf("global _%[1]v\n_%[1]v:", name)
}
return fmt.Sprintf("global %[1]v\n%[1]v:", name)
}
func (p *X86Macros) ExportFunc(name string, params ...string) string {
numRegisters := 0 // in 32-bit systems, we use stdcall: everything in stack
switch {
@ -371,13 +381,7 @@ func (p *X86Macros) ExportFunc(name string, params ...string) string {
reverseParams[len(params)-1-i] = param
}
p.Stacklocs = append(reverseParams, "retaddr_"+name) // in 32-bit, we use stdcall and parameters are in the stack
if !p.Amd64 && p.OS == "windows" {
return fmt.Sprintf("%[1]v\nglobal _%[2]v@%[3]v\n_%[2]v@%[3]v:", p.SectText(name), name, len(params)*4)
}
if p.OS == "darwin" {
return fmt.Sprintf("%[1]v\nglobal _%[2]v\n_%[2]v:", p.SectText(name), name)
}
return fmt.Sprintf("%[1]v\nglobal %[2]v\n%[2]v:", p.SectText(name), name)
return fmt.Sprintf("%[1]v\n%[2]v", p.SectText(name), p.Export(name, len(params)))
}
func (p *X86Macros) Input(unit string, port string) (string, error) {