Author Topic: Maxam REPT equivalent  (Read 5166 times)

0 Members and 1 Guest are viewing this topic.

Offline ssr86

  • CPC664
  • ***
  • Posts: 120
  • Country: pl
  • Liked: 48
  • Likes Given: 21
Re: Maxam REPT equivalent
« Reply #25 on: 20:52, 23 November 13 »
Yes, that is what I had in mind. Thanks for the answer.
It's not possible so I'll do it with nested 'ifs' instead...




Offline Grim

  • CPC6128
  • ****
  • Posts: 202
  • Country: gp
  • La pak ba, bèf ka pasé
    • THERE IS NO GAME
  • Liked: 133
  • Likes Given: 67
Re: Maxam REPT equivalent
« Reply #26 on: 00:11, 24 November 13 »
Is it possible to write such a macro in Winape??:
Code: [Select]
macro load_A_with reg
   ld a,reg
endm
It is:
Code: [Select]
;;Define some of the 3-bit CPU register indexes as used by the LD r,r' instruction for convenience
_b EQU %000
_c EQU %001
_d EQU %010
_e EQU %011
_h EQU %100
_l EQU %101
;_z EQU %110
_a EQU %111

;; Add the 3-bit register index argument with the LD A,r opcode to make the final instruction
;; Note: the AND %111 is only here to sanitize the input, just in case.
macro load_a_with reg
db reg AND %111 + %01111000
mend

;; Macro usage:
load_a_with _b
load_a_with _c
load_a_with _d
load_a_with _e
load_a_with _h
load_a_with _l
load_a_with _a


There is another form of write direct which allows writing directly to sectors on a disc image.
Aye! Duly noted cap'n! :)

Offline ssr86

  • CPC664
  • ***
  • Posts: 120
  • Country: pl
  • Liked: 48
  • Likes Given: 21
Re: Maxam REPT equivalent
« Reply #27 on: 01:17, 24 November 13 »
Wah, thanks Grim :D

Offline Executioner

  • Supporter
  • 6128 Plus
  • *
  • Posts: 783
  • Country: au
  • WinAPE Developer
    • WinAPE
  • Liked: 392
  • Likes Given: 60
Re: Maxam REPT equivalent
« Reply #28 on: 00:40, 26 November 13 »
Parameters can only be numbers or characters it seems.

Interesting... I think that's an oversight, perhaps I can change it for the next release.

Offline ssr86

  • CPC664
  • ***
  • Posts: 120
  • Country: pl
  • Liked: 48
  • Likes Given: 21
Re: Maxam REPT equivalent
« Reply #29 on: 00:11, 01 February 14 »
Another question about Winape assembler...
Is there a way to use inequalities in conditional code...?
Code: [Select]
if par1<const
...
endif

Offline Bruce Abbott

  • CPC664
  • ***
  • Posts: 53
  • Country: nz
  • Liked: 85
  • Likes Given: 0
Re: Maxam REPT equivalent
« Reply #30 on: 08:35, 01 February 14 »
Is there a way to use inequalities in conditional code...?
Not directly, but you can use bitwise logical operators that produce a result of 'true' (not zero) or 'false' (zero), eg.:-

Code: [Select]
IF par1-const AND &8000
...
ENDIF
In this case, if par1-const is negative then bit 15 of the result will be set, so result AND &8000 will be true (not zero).



Offline ssr86

  • CPC664
  • ***
  • Posts: 120
  • Country: pl
  • Liked: 48
  • Likes Given: 21
Re: Maxam REPT equivalent
« Reply #31 on: 14:49, 01 February 14 »
Thank you, it helped a lot:)

But is there a way to have two inequalities checked in one 'if', or do I have to go with two 'ifs' because I can't use brackets...?
Code: [Select]
if par1<const1 AND par2<const2
...
endif



Offline Bruce Abbott

  • CPC664
  • ***
  • Posts: 53
  • Country: nz
  • Liked: 85
  • Likes Given: 0
Re: Maxam REPT equivalent
« Reply #32 on: 20:56, 01 February 14 »
Thank you, it helped a lot:)

But is there a way to have two inequalities checked in one 'if', or do I have to go with two 'ifs' because I can't use brackets...
Expressions are evaluated in strict left to right order, so it may be possible in some cases but not easy. Best to just use nested ifs. 

Offline Executioner

  • Supporter
  • 6128 Plus
  • *
  • Posts: 783
  • Country: au
  • WinAPE Developer
    • WinAPE
  • Liked: 392
  • Likes Given: 60
Re: Maxam REPT equivalent
« Reply #33 on: 02:33, 18 February 14 »
You can either use nested IFs, or use EQU for each of the conditions eg.

c1 equ par1 - const1 and #8000
c2 equ par2 - const2 and #8000
if c1 and c2
...
endif