Skip to content

Processor Abuse

January 1, 2018

My C compiler can generate a LOT of code. I don’t really mind as long as it works but sometimes I look under the covers for fun.

The 8 bit version of the transpose from pixie format to LCD format cycles through 8 C statements like the following.
B[1]=B[0] = (A[0] & 128) | (A[1] & 128)>>1 | (A[2] & 128)>>2 | (A[3] & 128)>>3 |
(A[4] & 128)>>4 | (A[5] & 128)>>5 | (A[6] & 128)>>6 | (A[7] )>>7;

That generates over 600 lines of listing – maybe 500 instructions. That and its 7 companions gets iterated 16X8 times for each screen conversion so about 1000X500 instructions. There’s a bunch of other code around it but that alone is enough to account for the time for each pass. The thing is, even though the 1802 is handicapped for multi-bit shifting and memory addressing, the statement has only four one byte inputs(A[0]=A[1] etc.) and four one byte outputs. Even I should be able to code it up in a manageable stretch of assembly code.

Assume for the sake of argument that A[0]=A[1] is in the high byte of R8, A[2]=A[3] is in the low byte, A[4] and A[6] are in R9, then the operation on A[0] and A[2] would be something like:

  GHI R8    ;A[0]
  ANI 128
  STR R2    ;work area on the stack
  SHR
  OR
  STR R2    ;work area now has (A[0] & 128) | (A[0] & 128)>>1

  GLO R8     ;A[2]
  ANI 128
  SHR
  SHR
  OR
  STR R2
  SHR 
  OR
  STR R2    ;work area now has (A[0] & 128) | (A[1] & 128)>>1 | (A[2] & 128)>>2 | (A[3] & 128)>>3

with two more blocks for A[4] and A[6] – maybe a total of about 40 instructions. Huh, that’s not much more than a 10 to 1 improvement and it would be a pain to write.

     445/     36F : (MACRO)             	ldaD R11,128; reg:acon
     445/     36F : F8 80                       ldi     (128)&255
     445/     371 : AB                          plo     R11
     445/     372 : F8 00                       ldi     (128)>>8; was/256
     445/     374 : BB                          phi     R11
     446/     375 : (MACRO)             	ld1 R10,'O',sp,(66)
     446/     375 : =>TRUE                      if      ('O'='O')
     446/     375 :  (MACRO-2)                          ldAX    memAddr,SP,(66)
     446/     375 : 82                          glo     SP
     446/     376 : FC 42                       adi     ((66))#256
     446/     378 : AE                          plo     MEMADDR
     446/     379 : 92                          ghi     SP
     446/     37A : 7C 00                       adci    ((66))>>8; was/256
     446/     37C : BE                          phi     MEMADDR
     446/     37D : =>FALSE                     else
     446/     37D :                                     ldAD    memAddr,SP
     446/     37D : [446]                       endif
     446/     37D : 0E                          ldn     memAddr
     446/     37E : AA                          plo     R10
     447/     37F : (MACRO)             	zExt R10 ;CVUI2: widen unsigned char to signed int (zero extend)
     447/     37F : F8 00                       ldi     0
     447/     381 : BA                          phi     R10
     448/     382 : (MACRO)             	alu2 R10,R10,R11,and,and
     448/     382 : 22                          dec     sp ;make a work ares
     448/     383 : 8B                          glo     R11
     448/     384 : 52                          str     sp
     448/     385 : 8A                          glo     R10
     448/     386 : F2                          AND             ;calculate the low order byte
     448/     387 : AA                          plo     R10
     448/     388 : 9B                          ghi     R11
     448/     389 : 52                          str     sp
     448/     38A : 9A                          ghi     R10
 AS V1.42 Beta [Bld 123] - source file pixie8main.asm - page 9 - 1/1/2018 14:47:05

     448/     38B : F2                          AND             ;calculate the high byte
     448/     38C : BA                          phi     R10
     448/     38D : 12                          inc     sp      ;release the work area
     449/     38E : (MACRO)             	ld1 R9,'O',sp,(67)
     449/     38E : =>TRUE                      if      ('O'='O')
     449/     38E :  (MACRO-2)                          ldAX    memAddr,SP,(67)
     449/     38E : 82                          glo     SP
     449/     38F : FC 43                       adi     ((67))#256
     449/     391 : AE                          plo     MEMADDR
     449/     392 : 92                          ghi     SP
     449/     393 : 7C 00                       adci    ((67))>>8; was/256
     449/     395 : BE                          phi     MEMADDR
     449/     396 : =>FALSE                     else
     449/     396 :                                     ldAD    memAddr,SP
     449/     396 : [449]                       endif
     449/     396 : 0E                          ldn     memAddr
     449/     397 : A9                          plo     R9
     450/     398 : (MACRO)             	zExt R9 ;CVUI2: widen unsigned char to signed int (zero extend)
     450/     398 : F8 00                       ldi     0
     450/     39A : B9                          phi     R9
     451/     39B : (MACRO)             	alu2 R9,R9,R11,and,and
     451/     39B : 22                          dec     sp ;make a work ares
     451/     39C : 8B                          glo     R11
     451/     39D : 52                          str     sp
     451/     39E : 89                          glo     R9
     451/     39F : F2                          AND             ;calculate the low order byte
     451/     3A0 : A9                          plo     R9
     451/     3A1 : 9B                          ghi     R11
     451/     3A2 : 52                          str     sp
     451/     3A3 : 99                          ghi     R9
     451/     3A4 : F2                          AND             ;calculate the high byte
     451/     3A5 : B9                          phi     R9
     451/     3A6 : 12                          inc     sp      ;release the work area
     452/     3A7 : (MACRO)             	shrI2I R9,1
     452/     3A7 :                             rept    1
     452/     3A7 :                             shrI2   R9
     452/     3A7 :                             endm
     452/     3A7 :  (MACRO-2)                  shrI2   R9
     452/     3A7 : 99                          ghi     R9
     452/     3A8 : FE                          shl             ;set DF to the sign
     452/     3A9 : 99                          ghi     R9     ;get the top byte back
     452/     3AA : 76                          shrc            ;shift one bit extending the sign
     452/     3AB : B9                          phi     R9
     452/     3AC : 89                          glo     R9
     452/     3AD : 76                          shrc
     452/     3AE : A9                          plo     R9
     453/     3AF : (MACRO)             	alu2 R10,R10,R9,or,or
     453/     3AF : 22                          dec     sp ;make a work ares
     453/     3B0 : 89                          glo     R9
     453/     3B1 : 52                          str     sp
     453/     3B2 : 8A                          glo     R10
     453/     3B3 : F1                          OR             ;calculate the low order byte
     453/     3B4 : AA                          plo     R10
     453/     3B5 : 99                          ghi     R9
     453/     3B6 : 52                          str     sp
     453/     3B7 : 9A                          ghi     R10
     453/     3B8 : F1                          OR             ;calculate the high byte
     453/     3B9 : BA                          phi     R10
     453/     3BA : 12                          inc     sp      ;release the work area
     454/     3BB : (MACRO)             	ld1 R9,'O',sp,(68)
 AS V1.42 Beta [Bld 123] - source file pixie8main.asm - page 10 - 1/1/2018 14:47:05

     454/     3BB : =>TRUE                      if      ('O'='O')
     454/     3BB :  (MACRO-2)                          ldAX    memAddr,SP,(68)
     454/     3BB : 82                          glo     SP
     454/     3BC : FC 44                       adi     ((68))#256
     454/     3BE : AE                          plo     MEMADDR
     454/     3BF : 92                          ghi     SP
     454/     3C0 : 7C 00                       adci    ((68))>>8; was/256
     454/     3C2 : BE                          phi     MEMADDR
     454/     3C3 : =>FALSE                     else
     454/     3C3 :                                     ldAD    memAddr,SP
     454/     3C3 : [454]                       endif
     454/     3C3 : 0E                          ldn     memAddr
     454/     3C4 : A9                          plo     R9
     455/     3C5 : (MACRO)             	zExt R9 ;CVUI2: widen unsigned char to signed int (zero extend)
     455/     3C5 : F8 00                       ldi     0
     455/     3C7 : B9                          phi     R9
     456/     3C8 : (MACRO)             	alu2 R9,R9,R11,and,and
     456/     3C8 : 22                          dec     sp ;make a work ares
     456/     3C9 : 8B                          glo     R11
     456/     3CA : 52                          str     sp
     456/     3CB : 89                          glo     R9
     456/     3CC : F2                          AND             ;calculate the low order byte
     456/     3CD : A9                          plo     R9
     456/     3CE : 9B                          ghi     R11
     456/     3CF : 52                          str     sp
     456/     3D0 : 99                          ghi     R9
     456/     3D1 : F2                          AND             ;calculate the high byte
     456/     3D2 : B9                          phi     R9
     456/     3D3 : 12                          inc     sp      ;release the work area
     457/     3D4 : (MACRO)             	shrI2I R9,2
     457/     3D4 :                             rept    2
     457/     3D4 :                             shrI2   R9
     457/     3D4 :                             endm
     457/     3D4 :  (MACRO-2)                  shrI2   R9
     457/     3D4 : 99                          ghi     R9
     457/     3D5 : FE                          shl             ;set DF to the sign
     457/     3D6 : 99                          ghi     R9     ;get the top byte back
     457/     3D7 : 76                          shrc            ;shift one bit extending the sign
     457/     3D8 : B9                          phi     R9
     457/     3D9 : 89                          glo     R9
     457/     3DA : 76                          shrc
     457/     3DB : A9                          plo     R9
     457/     3DC :  (MACRO-2)                  shrI2   R9
     457/     3DC : 99                          ghi     R9
     457/     3DD : FE                          shl             ;set DF to the sign
     457/     3DE : 99                          ghi     R9     ;get the top byte back
     457/     3DF : 76                          shrc            ;shift one bit extending the sign
     457/     3E0 : B9                          phi     R9
     457/     3E1 : 89                          glo     R9
     457/     3E2 : 76                          shrc
     457/     3E3 : A9                          plo     R9
     458/     3E4 : (MACRO)             	alu2 R10,R10,R9,or,or
     458/     3E4 : 22                          dec     sp ;make a work ares
     458/     3E5 : 89                          glo     R9
     458/     3E6 : 52                          str     sp
     458/     3E7 : 8A                          glo     R10
     458/     3E8 : F1                          OR             ;calculate the low order byte
     458/     3E9 : AA                          plo     R10
     458/     3EA : 99                          ghi     R9
     458/     3EB : 52                          str     sp
 AS V1.42 Beta [Bld 123] - source file pixie8main.asm - page 11 - 1/1/2018 14:47:05

     458/     3EC : 9A                          ghi     R10
     458/     3ED : F1                          OR             ;calculate the high byte
     458/     3EE : BA                          phi     R10
     458/     3EF : 12                          inc     sp      ;release the work area
     459/     3F0 : (MACRO)             	ld1 R9,'O',sp,(69)
     459/     3F0 : =>TRUE                      if      ('O'='O')
     459/     3F0 :  (MACRO-2)                          ldAX    memAddr,SP,(69)
     459/     3F0 : 82                          glo     SP
     459/     3F1 : FC 45                       adi     ((69))#256
     459/     3F3 : AE                          plo     MEMADDR
     459/     3F4 : 92                          ghi     SP
     459/     3F5 : 7C 00                       adci    ((69))>>8; was/256
     459/     3F7 : BE                          phi     MEMADDR
     459/     3F8 : =>FALSE                     else
     459/     3F8 :                                     ldAD    memAddr,SP
     459/     3F8 : [459]                       endif
     459/     3F8 : 0E                          ldn     memAddr
     459/     3F9 : A9                          plo     R9
     460/     3FA : (MACRO)             	zExt R9 ;CVUI2: widen unsigned char to signed int (zero extend)
     460/     3FA : F8 00                       ldi     0
     460/     3FC : B9                          phi     R9
     461/     3FD : (MACRO)             	alu2 R9,R9,R11,and,and
     461/     3FD : 22                          dec     sp ;make a work ares
     461/     3FE : 8B                          glo     R11
     461/     3FF : 52                          str     sp
     461/     400 : 89                          glo     R9
     461/     401 : F2                          AND             ;calculate the low order byte
     461/     402 : A9                          plo     R9
     461/     403 : 9B                          ghi     R11
     461/     404 : 52                          str     sp
     461/     405 : 99                          ghi     R9
     461/     406 : F2                          AND             ;calculate the high byte
     461/     407 : B9                          phi     R9
     461/     408 : 12                          inc     sp      ;release the work area
     462/     409 : (MACRO)             	shrI2I R9,3
     462/     409 :                             rept    3
     462/     409 :                             shrI2   R9
     462/     409 :                             endm
     462/     409 :  (MACRO-2)                  shrI2   R9
     462/     409 : 99                          ghi     R9
     462/     40A : FE                          shl             ;set DF to the sign
     462/     40B : 99                          ghi     R9     ;get the top byte back
     462/     40C : 76                          shrc            ;shift one bit extending the sign
     462/     40D : B9                          phi     R9
     462/     40E : 89                          glo     R9
     462/     40F : 76                          shrc
     462/     410 : A9                          plo     R9
     462/     411 :  (MACRO-2)                  shrI2   R9
     462/     411 : 99                          ghi     R9
     462/     412 : FE                          shl             ;set DF to the sign
     462/     413 : 99                          ghi     R9     ;get the top byte back
     462/     414 : 76                          shrc            ;shift one bit extending the sign
     462/     415 : B9                          phi     R9
     462/     416 : 89                          glo     R9
     462/     417 : 76                          shrc
     462/     418 : A9                          plo     R9
     462/     419 :  (MACRO-2)                  shrI2   R9
     462/     419 : 99                          ghi     R9
     462/     41A : FE                          shl             ;set DF to the sign
     462/     41B : 99                          ghi     R9     ;get the top byte back
 AS V1.42 Beta [Bld 123] - source file pixie8main.asm - page 12 - 1/1/2018 14:47:05

     462/     41C : 76                          shrc            ;shift one bit extending the sign
     462/     41D : B9                          phi     R9
     462/     41E : 89                          glo     R9
     462/     41F : 76                          shrc
     462/     420 : A9                          plo     R9
     463/     421 : (MACRO)             	alu2 R10,R10,R9,or,or
     463/     421 : 22                          dec     sp ;make a work ares
     463/     422 : 89                          glo     R9
     463/     423 : 52                          str     sp
     463/     424 : 8A                          glo     R10
     463/     425 : F1                          OR             ;calculate the low order byte
     463/     426 : AA                          plo     R10
     463/     427 : 99                          ghi     R9
     463/     428 : 52                          str     sp
     463/     429 : 9A                          ghi     R10
     463/     42A : F1                          OR             ;calculate the high byte
     463/     42B : BA                          phi     R10
     463/     42C : 12                          inc     sp      ;release the work area
     464/     42D : (MACRO)             	ld1 R9,'O',sp,(70)
     464/     42D : =>TRUE                      if      ('O'='O')
     464/     42D :  (MACRO-2)                          ldAX    memAddr,SP,(70)
     464/     42D : 82                          glo     SP
     464/     42E : FC 46                       adi     ((70))#256
     464/     430 : AE                          plo     MEMADDR
     464/     431 : 92                          ghi     SP
     464/     432 : 7C 00                       adci    ((70))>>8; was/256
     464/     434 : BE                          phi     MEMADDR
     464/     435 : =>FALSE                     else
     464/     435 :                                     ldAD    memAddr,SP
     464/     435 : [464]                       endif
     464/     435 : 0E                          ldn     memAddr
     464/     436 : A9                          plo     R9
     465/     437 : (MACRO)             	zExt R9 ;CVUI2: widen unsigned char to signed int (zero extend)
     465/     437 : F8 00                       ldi     0
     465/     439 : B9                          phi     R9
     466/     43A : (MACRO)             	alu2 R9,R9,R11,and,and
     466/     43A : 22                          dec     sp ;make a work ares
     466/     43B : 8B                          glo     R11
     466/     43C : 52                          str     sp
     466/     43D : 89                          glo     R9
     466/     43E : F2                          AND             ;calculate the low order byte
     466/     43F : A9                          plo     R9
     466/     440 : 9B                          ghi     R11
     466/     441 : 52                          str     sp
     466/     442 : 99                          ghi     R9
     466/     443 : F2                          AND             ;calculate the high byte
     466/     444 : B9                          phi     R9
     466/     445 : 12                          inc     sp      ;release the work area
     467/     446 : (MACRO)             	shrI2I R9,4
     467/     446 :                             rept    4
     467/     446 :                             shrI2   R9
     467/     446 :                             endm
     467/     446 :  (MACRO-2)                  shrI2   R9
     467/     446 : 99                          ghi     R9
     467/     447 : FE                          shl             ;set DF to the sign
     467/     448 : 99                          ghi     R9     ;get the top byte back
     467/     449 : 76                          shrc            ;shift one bit extending the sign
     467/     44A : B9                          phi     R9
     467/     44B : 89                          glo     R9
     467/     44C : 76                          shrc
 AS V1.42 Beta [Bld 123] - source file pixie8main.asm - page 13 - 1/1/2018 14:47:05

     467/     44D : A9                          plo     R9
     467/     44E :  (MACRO-2)                  shrI2   R9
     467/     44E : 99                          ghi     R9
     467/     44F : FE                          shl             ;set DF to the sign
     467/     450 : 99                          ghi     R9     ;get the top byte back
     467/     451 : 76                          shrc            ;shift one bit extending the sign
     467/     452 : B9                          phi     R9
     467/     453 : 89                          glo     R9
     467/     454 : 76                          shrc
     467/     455 : A9                          plo     R9
     467/     456 :  (MACRO-2)                  shrI2   R9
     467/     456 : 99                          ghi     R9
     467/     457 : FE                          shl             ;set DF to the sign
     467/     458 : 99                          ghi     R9     ;get the top byte back
     467/     459 : 76                          shrc            ;shift one bit extending the sign
     467/     45A : B9                          phi     R9
     467/     45B : 89                          glo     R9
     467/     45C : 76                          shrc
     467/     45D : A9                          plo     R9
     467/     45E :  (MACRO-2)                  shrI2   R9
     467/     45E : 99                          ghi     R9
     467/     45F : FE                          shl             ;set DF to the sign
     467/     460 : 99                          ghi     R9     ;get the top byte back
     467/     461 : 76                          shrc            ;shift one bit extending the sign
     467/     462 : B9                          phi     R9
     467/     463 : 89                          glo     R9
     467/     464 : 76                          shrc
     467/     465 : A9                          plo     R9
     468/     466 : (MACRO)             	alu2 R10,R10,R9,or,or
     468/     466 : 22                          dec     sp ;make a work ares
     468/     467 : 89                          glo     R9
     468/     468 : 52                          str     sp
     468/     469 : 8A                          glo     R10
     468/     46A : F1                          OR             ;calculate the low order byte
     468/     46B : AA                          plo     R10
     468/     46C : 99                          ghi     R9
     468/     46D : 52                          str     sp
     468/     46E : 9A                          ghi     R10
     468/     46F : F1                          OR             ;calculate the high byte
     468/     470 : BA                          phi     R10
     468/     471 : 12                          inc     sp      ;release the work area
     469/     472 : (MACRO)             	ld1 R9,'O',sp,(71)
     469/     472 : =>TRUE                      if      ('O'='O')
     469/     472 :  (MACRO-2)                          ldAX    memAddr,SP,(71)
     469/     472 : 82                          glo     SP
     469/     473 : FC 47                       adi     ((71))#256
     469/     475 : AE                          plo     MEMADDR
     469/     476 : 92                          ghi     SP
     469/     477 : 7C 00                       adci    ((71))>>8; was/256
     469/     479 : BE                          phi     MEMADDR
     469/     47A : =>FALSE                     else
     469/     47A :                                     ldAD    memAddr,SP
     469/     47A : [469]                       endif
     469/     47A : 0E                          ldn     memAddr
     469/     47B : A9                          plo     R9
     470/     47C : (MACRO)             	zExt R9 ;CVUI2: widen unsigned char to signed int (zero extend)
     470/     47C : F8 00                       ldi     0
     470/     47E : B9                          phi     R9
     471/     47F : (MACRO)             	alu2 R9,R9,R11,and,and
     471/     47F : 22                          dec     sp ;make a work ares
 AS V1.42 Beta [Bld 123] - source file pixie8main.asm - page 14 - 1/1/2018 14:47:05

     471/     480 : 8B                          glo     R11
     471/     481 : 52                          str     sp
     471/     482 : 89                          glo     R9
     471/     483 : F2                          AND             ;calculate the low order byte
     471/     484 : A9                          plo     R9
     471/     485 : 9B                          ghi     R11
     471/     486 : 52                          str     sp
     471/     487 : 99                          ghi     R9
     471/     488 : F2                          AND             ;calculate the high byte
     471/     489 : B9                          phi     R9
     471/     48A : 12                          inc     sp      ;release the work area
     472/     48B : (MACRO)             	shrI2I R9,5
     472/     48B :                             rept    5
     472/     48B :                             shrI2   R9
     472/     48B :                             endm
     472/     48B :  (MACRO-2)                  shrI2   R9
     472/     48B : 99                          ghi     R9
     472/     48C : FE                          shl             ;set DF to the sign
     472/     48D : 99                          ghi     R9     ;get the top byte back
     472/     48E : 76                          shrc            ;shift one bit extending the sign
     472/     48F : B9                          phi     R9
     472/     490 : 89                          glo     R9
     472/     491 : 76                          shrc
     472/     492 : A9                          plo     R9
     472/     493 :  (MACRO-2)                  shrI2   R9
     472/     493 : 99                          ghi     R9
     472/     494 : FE                          shl             ;set DF to the sign
     472/     495 : 99                          ghi     R9     ;get the top byte back
     472/     496 : 76                          shrc            ;shift one bit extending the sign
     472/     497 : B9                          phi     R9
     472/     498 : 89                          glo     R9
     472/     499 : 76                          shrc
     472/     49A : A9                          plo     R9
     472/     49B :  (MACRO-2)                  shrI2   R9
     472/     49B : 99                          ghi     R9
     472/     49C : FE                          shl             ;set DF to the sign
     472/     49D : 99                          ghi     R9     ;get the top byte back
     472/     49E : 76                          shrc            ;shift one bit extending the sign
     472/     49F : B9                          phi     R9
     472/     4A0 : 89                          glo     R9
     472/     4A1 : 76                          shrc
     472/     4A2 : A9                          plo     R9
     472/     4A3 :  (MACRO-2)                  shrI2   R9
     472/     4A3 : 99                          ghi     R9
     472/     4A4 : FE                          shl             ;set DF to the sign
     472/     4A5 : 99                          ghi     R9     ;get the top byte back
     472/     4A6 : 76                          shrc            ;shift one bit extending the sign
     472/     4A7 : B9                          phi     R9
     472/     4A8 : 89                          glo     R9
     472/     4A9 : 76                          shrc
     472/     4AA : A9                          plo     R9
     472/     4AB :  (MACRO-2)                  shrI2   R9
     472/     4AB : 99                          ghi     R9
     472/     4AC : FE                          shl             ;set DF to the sign
     472/     4AD : 99                          ghi     R9     ;get the top byte back
     472/     4AE : 76                          shrc            ;shift one bit extending the sign
     472/     4AF : B9                          phi     R9
     472/     4B0 : 89                          glo     R9
     472/     4B1 : 76                          shrc
     472/     4B2 : A9                          plo     R9
 AS V1.42 Beta [Bld 123] - source file pixie8main.asm - page 15 - 1/1/2018 14:47:05

     473/     4B3 : (MACRO)             	alu2 R10,R10,R9,or,or
     473/     4B3 : 22                          dec     sp ;make a work ares
     473/     4B4 : 89                          glo     R9
     473/     4B5 : 52                          str     sp
     473/     4B6 : 8A                          glo     R10
     473/     4B7 : F1                          OR             ;calculate the low order byte
     473/     4B8 : AA                          plo     R10
     473/     4B9 : 99                          ghi     R9
     473/     4BA : 52                          str     sp
     473/     4BB : 9A                          ghi     R10
     473/     4BC : F1                          OR             ;calculate the high byte
     473/     4BD : BA                          phi     R10
     473/     4BE : 12                          inc     sp      ;release the work area
     474/     4BF : (MACRO)             	ld1 R9,'O',sp,(72)
     474/     4BF : =>TRUE                      if      ('O'='O')
     474/     4BF :  (MACRO-2)                          ldAX    memAddr,SP,(72)
     474/     4BF : 82                          glo     SP
     474/     4C0 : FC 48                       adi     ((72))#256
     474/     4C2 : AE                          plo     MEMADDR
     474/     4C3 : 92                          ghi     SP
     474/     4C4 : 7C 00                       adci    ((72))>>8; was/256
     474/     4C6 : BE                          phi     MEMADDR
     474/     4C7 : =>FALSE                     else
     474/     4C7 :                                     ldAD    memAddr,SP
     474/     4C7 : [474]                       endif
     474/     4C7 : 0E                          ldn     memAddr
     474/     4C8 : A9                          plo     R9
     475/     4C9 : (MACRO)             	zExt R9 ;CVUI2: widen unsigned char to signed int (zero extend)
     475/     4C9 : F8 00                       ldi     0
     475/     4CB : B9                          phi     R9
     476/     4CC : (MACRO)             	alu2 R11,R9,R11,and,and
     476/     4CC : 22                          dec     sp ;make a work ares
     476/     4CD : 8B                          glo     R11
     476/     4CE : 52                          str     sp
     476/     4CF : 89                          glo     R9
     476/     4D0 : F2                          AND             ;calculate the low order byte
     476/     4D1 : AB                          plo     R11
     476/     4D2 : 9B                          ghi     R11
     476/     4D3 : 52                          str     sp
     476/     4D4 : 99                          ghi     R9
     476/     4D5 : F2                          AND             ;calculate the high byte
     476/     4D6 : BB                          phi     R11
     476/     4D7 : 12                          inc     sp      ;release the work area
     477/     4D8 : (MACRO)             	shrI2I R11,6
     477/     4D8 :                             rept    6
     477/     4D8 :                             shrI2   R11
     477/     4D8 :                             endm
     477/     4D8 :  (MACRO-2)                  shrI2   R11
     477/     4D8 : 9B                          ghi     R11
     477/     4D9 : FE                          shl             ;set DF to the sign
     477/     4DA : 9B                          ghi     R11     ;get the top byte back
     477/     4DB : 76                          shrc            ;shift one bit extending the sign
     477/     4DC : BB                          phi     R11
     477/     4DD : 8B                          glo     R11
     477/     4DE : 76                          shrc
     477/     4DF : AB                          plo     R11
     477/     4E0 :  (MACRO-2)                  shrI2   R11
     477/     4E0 : 9B                          ghi     R11
     477/     4E1 : FE                          shl             ;set DF to the sign
     477/     4E2 : 9B                          ghi     R11     ;get the top byte back
 AS V1.42 Beta [Bld 123] - source file pixie8main.asm - page 16 - 1/1/2018 14:47:05

     477/     4E3 : 76                          shrc            ;shift one bit extending the sign
     477/     4E4 : BB                          phi     R11
     477/     4E5 : 8B                          glo     R11
     477/     4E6 : 76                          shrc
     477/     4E7 : AB                          plo     R11
     477/     4E8 :  (MACRO-2)                  shrI2   R11
     477/     4E8 : 9B                          ghi     R11
     477/     4E9 : FE                          shl             ;set DF to the sign
     477/     4EA : 9B                          ghi     R11     ;get the top byte back
     477/     4EB : 76                          shrc            ;shift one bit extending the sign
     477/     4EC : BB                          phi     R11
     477/     4ED : 8B                          glo     R11
     477/     4EE : 76                          shrc
     477/     4EF : AB                          plo     R11
     477/     4F0 :  (MACRO-2)                  shrI2   R11
     477/     4F0 : 9B                          ghi     R11
     477/     4F1 : FE                          shl             ;set DF to the sign
     477/     4F2 : 9B                          ghi     R11     ;get the top byte back
     477/     4F3 : 76                          shrc            ;shift one bit extending the sign
     477/     4F4 : BB                          phi     R11
     477/     4F5 : 8B                          glo     R11
     477/     4F6 : 76                          shrc
     477/     4F7 : AB                          plo     R11
     477/     4F8 :  (MACRO-2)                  shrI2   R11
     477/     4F8 : 9B                          ghi     R11
     477/     4F9 : FE                          shl             ;set DF to the sign
     477/     4FA : 9B                          ghi     R11     ;get the top byte back
     477/     4FB : 76                          shrc            ;shift one bit extending the sign
     477/     4FC : BB                          phi     R11
     477/     4FD : 8B                          glo     R11
     477/     4FE : 76                          shrc
     477/     4FF : AB                          plo     R11
     477/     500 :  (MACRO-2)                  shrI2   R11
     477/     500 : 9B                          ghi     R11
     477/     501 : FE                          shl             ;set DF to the sign
     477/     502 : 9B                          ghi     R11     ;get the top byte back
     477/     503 : 76                          shrc            ;shift one bit extending the sign
     477/     504 : BB                          phi     R11
     477/     505 : 8B                          glo     R11
     477/     506 : 76                          shrc
     477/     507 : AB                          plo     R11
     478/     508 : (MACRO)             	alu2 R11,R10,R11,or,or
     478/     508 : 22                          dec     sp ;make a work ares
     478/     509 : 8B                          glo     R11
     478/     50A : 52                          str     sp
     478/     50B : 8A                          glo     R10
     478/     50C : F1                          OR             ;calculate the low order byte
     478/     50D : AB                          plo     R11
     478/     50E : 9B                          ghi     R11
     478/     50F : 52                          str     sp
     478/     510 : 9A                          ghi     R10
     478/     511 : F1                          OR             ;calculate the high byte
     478/     512 : BB                          phi     R11
     478/     513 : 12                          inc     sp      ;release the work area
     479/     514 : (MACRO)             	ld1 R10,'O',sp,(73)
     479/     514 : =>TRUE                      if      ('O'='O')
     479/     514 :  (MACRO-2)                          ldAX    memAddr,SP,(73)
     479/     514 : 82                          glo     SP
     479/     515 : FC 49                       adi     ((73))#256
     479/     517 : AE                          plo     MEMADDR
 AS V1.42 Beta [Bld 123] - source file pixie8main.asm - page 17 - 1/1/2018 14:47:05

     479/     518 : 92                          ghi     SP
     479/     519 : 7C 00                       adci    ((73))>>8; was/256
     479/     51B : BE                          phi     MEMADDR
     479/     51C : =>FALSE                     else
     479/     51C :                                     ldAD    memAddr,SP
     479/     51C : [479]                       endif
     479/     51C : 0E                          ldn     memAddr
     479/     51D : AA                          plo     R10
     480/     51E : (MACRO)             	zExt R10 ;CVUI2: widen unsigned char to signed int (zero extend)
     480/     51E : F8 00                       ldi     0
     480/     520 : BA                          phi     R10
     481/     521 : (MACRO)             	shrI2I R10,7
     481/     521 :                             rept    7
     481/     521 :                             shrI2   R10
     481/     521 :                             endm
     481/     521 :  (MACRO-2)                  shrI2   R10
     481/     521 : 9A                          ghi     R10
     481/     522 : FE                          shl             ;set DF to the sign
     481/     523 : 9A                          ghi     R10     ;get the top byte back
     481/     524 : 76                          shrc            ;shift one bit extending the sign
     481/     525 : BA                          phi     R10
     481/     526 : 8A                          glo     R10
     481/     527 : 76                          shrc
     481/     528 : AA                          plo     R10
     481/     529 :  (MACRO-2)                  shrI2   R10
     481/     529 : 9A                          ghi     R10
     481/     52A : FE                          shl             ;set DF to the sign
     481/     52B : 9A                          ghi     R10     ;get the top byte back
     481/     52C : 76                          shrc            ;shift one bit extending the sign
     481/     52D : BA                          phi     R10
     481/     52E : 8A                          glo     R10
     481/     52F : 76                          shrc
     481/     530 : AA                          plo     R10
     481/     531 :  (MACRO-2)                  shrI2   R10
     481/     531 : 9A                          ghi     R10
     481/     532 : FE                          shl             ;set DF to the sign
     481/     533 : 9A                          ghi     R10     ;get the top byte back
     481/     534 : 76                          shrc            ;shift one bit extending the sign
     481/     535 : BA                          phi     R10
     481/     536 : 8A                          glo     R10
     481/     537 : 76                          shrc
     481/     538 : AA                          plo     R10
     481/     539 :  (MACRO-2)                  shrI2   R10
     481/     539 : 9A                          ghi     R10
     481/     53A : FE                          shl             ;set DF to the sign
     481/     53B : 9A                          ghi     R10     ;get the top byte back
     481/     53C : 76                          shrc            ;shift one bit extending the sign
     481/     53D : BA                          phi     R10
     481/     53E : 8A                          glo     R10
     481/     53F : 76                          shrc
     481/     540 : AA                          plo     R10
     481/     541 :  (MACRO-2)                  shrI2   R10
     481/     541 : 9A                          ghi     R10
     481/     542 : FE                          shl             ;set DF to the sign
     481/     543 : 9A                          ghi     R10     ;get the top byte back
     481/     544 : 76                          shrc            ;shift one bit extending the sign
     481/     545 : BA                          phi     R10
     481/     546 : 8A                          glo     R10
     481/     547 : 76                          shrc
     481/     548 : AA                          plo     R10
 AS V1.42 Beta [Bld 123] - source file pixie8main.asm - page 18 - 1/1/2018 14:47:05

     481/     549 :  (MACRO-2)                  shrI2   R10
     481/     549 : 9A                          ghi     R10
     481/     54A : FE                          shl             ;set DF to the sign
     481/     54B : 9A                          ghi     R10     ;get the top byte back
     481/     54C : 76                          shrc            ;shift one bit extending the sign
     481/     54D : BA                          phi     R10
     481/     54E : 8A                          glo     R10
     481/     54F : 76                          shrc
     481/     550 : AA                          plo     R10
     481/     551 :  (MACRO-2)                  shrI2   R10
     481/     551 : 9A                          ghi     R10
     481/     552 : FE                          shl             ;set DF to the sign
     481/     553 : 9A                          ghi     R10     ;get the top byte back
     481/     554 : 76                          shrc            ;shift one bit extending the sign
     481/     555 : BA                          phi     R10
     481/     556 : 8A                          glo     R10
     481/     557 : 76                          shrc
     481/     558 : AA                          plo     R10
     482/     559 : (MACRO)             	alu2 R11,R11,R10,or,or
     482/     559 : 22                          dec     sp ;make a work ares
     482/     55A : 8A                          glo     R10
     482/     55B : 52                          str     sp
     482/     55C : 8B                          glo     R11
     482/     55D : F1                          OR             ;calculate the low order byte
     482/     55E : AB                          plo     R11
     482/     55F : 9A                          ghi     R10
     482/     560 : 52                          str     sp
     482/     561 : 9B                          ghi     R11
     482/     562 : F1                          OR             ;calculate the high byte
     482/     563 : BB                          phi     R11
     482/     564 : 12                          inc     sp      ;release the work area
     483/     565 : (MACRO)             	ldA2 R10,'O',sp,(50); reg:addr
     483/     565 :                     ;Oct 13 (50) added to ldAD call
     483/     565 : =>TRUE                      if      ('O'='O')
     483/     565 :  (MACRO-2)                          ldAX    R10,SP,(50)
     483/     565 : 82                          glo     SP
     483/     566 : FC 32                       adi     ((50))#256
     483/     568 : AA                          plo     R10
     483/     569 : 92                          ghi     SP
     483/     56A : 7C 00                       adci    ((50))>>8; was/256
     483/     56C : BA                          phi     R10
     483/     56D : =>FALSE                     else
     483/     56D :                                     ldAD    R10,SP+(50)
     483/     56D : [483]                       endif
     484/     56D : (MACRO)             	str1 R11,R10; ASGNU1(indaddr,reg)		DH
     484/     56D : 8B                          glo     R11
     484/     56E : 5A                          str     R10
     485/     56F : (MACRO)             	ldA2 R10,'O',sp,(51); reg:addr
     485/     56F :                     ;Oct 13 (51) added to ldAD call
     485/     56F : =>TRUE                      if      ('O'='O')
     485/     56F :  (MACRO-2)                          ldAX    R10,SP,(51)
     485/     56F : 82                          glo     SP
     485/     570 : FC 33                       adi     ((51))#256
     485/     572 : AA                          plo     R10
     485/     573 : 92                          ghi     SP
     485/     574 : 7C 00                       adci    ((51))>>8; was/256
     485/     576 : BA                          phi     R10
     485/     577 : =>FALSE                     else
     485/     577 :                                     ldAD    R10,SP+(51)
     485/     577 : [485]                       endif
 AS V1.42 Beta [Bld 123] - source file pixie8main.asm - page 19 - 1/1/2018 14:47:05

     486/     577 : (MACRO)             	str1 R11,R10; ASGNU1(indaddr,reg)		DH
     486/     577 : 8B                          glo     R11
     486/     578 : 5A                          str     R10
     487/     579 :                     ;asm(" macexp off\n");

I always want the last word so that wordpress doesn’t eat my code!

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: