Skip to content

Commit

Permalink
FIX: now get-words can be used in math expressions (fixes several bug…
Browse files Browse the repository at this point in the history
…s and limitations).
  • Loading branch information
dockimbel committed Sep 7, 2012
1 parent 22be8bb commit fabad83
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
33 changes: 26 additions & 7 deletions red-system/targets/IA-32.r
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ make target-class [
/local offset
][
if verbose >= 3 [print [">>>loading" mold value]]
alt: to logic! alt

switch type?/word value [
char! [
Expand Down Expand Up @@ -436,8 +437,8 @@ make target-class [
with-width-of value [
either compiler/any-float? compiler/get-variable-spec value [
emit-float-variable value
#{DD05} ;-- FLD [value] ; global
#{DD45} ;-- FLD [ebp+n] ; local
#{DD05} ;-- FLD [value] ; global
#{DD45} ;-- FLD [ebp+n] ; local
][
either alt [
emit-variable-poly value
Expand All @@ -453,12 +454,30 @@ make target-class [
]
get-word! [
value: to word! value
either offset: select emitter/stack value [
emit #{8D45} ;-- LEA eax, [ebp+n] ; local
emit stack-encode offset ;-- n
either 'function! = first compiler/get-type value [
either alt [
emit-variable value
#{8B15} ;-- MOV edx, [value] ; global
#{8B55} ;-- MOV edx, [ebp+n] ; local
][
emit-variable value
#{A1} ;-- MOV eax, [value] ; global
#{8B45} ;-- MOV eax, [ebp+n] ; local
]
][
emit #{B8} ;-- MOV eax, &name
emit-reloc-addr emitter/get-symbol-ref value ;-- symbol address
either offset: select emitter/stack value [
emit pick [
#{8D55} ;-- LEA edx, [ebp+n] ; local
#{8D45} ;-- LEA eax, [ebp+n] ; local
] alt
emit stack-encode offset ;-- n
][
emit pick [
#{BA} ;-- MOV edx, &name
#{B8} ;-- MOV eax, &name
] alt
emit-reloc-addr emitter/get-symbol-ref value ;-- symbol address
]
]
]
string! [
Expand Down
13 changes: 7 additions & 6 deletions red-system/targets/target-class.r
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,13 @@ target-class: context [
'reg ;-- value in accumulator
][
switch type?/word arg [
char! ['imm]
integer! ['imm]
decimal! ['imm]
word! ['ref] ;-- value needs to be fetched
block! ['reg] ;-- value in accumulator (or in alt-acc)
path! ['reg] ;-- value in accumulator (or in alt-acc)
char! ['imm]
integer! ['imm]
decimal! ['imm]
word! ['ref] ;-- value needs to be fetched
get-word! ['ref]
block! ['reg] ;-- value in accumulator (or in alt-acc)
path! ['reg] ;-- value in accumulator (or in alt-acc)
]
]
c: c + 1
Expand Down

0 comments on commit fabad83

Please sign in to comment.