Wednesday, February 17, 2016

ESC em processing in Action Printer 2000

So now that we've found that $13A3 is the ESC processing routine, let's do some disassembly.



000013A3: 9E                 CALT    ($00BC)  get next char
000013A4: 67 19              NEI     A,$19   is it cut sheet feeder mode
000013A6: CC                 JR      $13B3
000013A7: 77 7F              EQI     A,$7F   equal to 7F delete
000013A9: 27 1F              GTI     A,$1F   not equal to 7F, are we greater than 31
000013AB: 4E 25              JRE     $13D2   so less than or equal to 31 or equal to 7F jump to 13d2
000013AD: 27 2F              GTI     A,$2F    2F=/  decimal 47
000013AF: C3                 JR      $13B3   less than equal to 47 jump to 13b3
000013B0: 27 5A              GTI     A,$5A    greater than Z  5a is 90 = Z
000013B2: CF                 JR      $13C2   so here we are from 48 to 90


Anyway, let's not get confused with too many details. We'll get the next char and compare it to $19. $19 is the ascii code for EM (or end medium). If we are equal to $19 then jump to $13b3.

000013B3: 34 62 14           LXI     HL,$1462
000013B6: 1A                 MOV     B,A
000013B7: 2D                 LDAX    (HL+)
000013B8: 67 00              NEI     A,$00
000013BA: B8                 RET     
000013BB: 48 85              LDEAX   (HL++)
000013BD: 60 FA              EQA     A,B
000013BF: F7                 JR      $13B7
000013C0: 48 28              JEA     

and this code will scan through a table beginning at $1462 in a special format of 3 byte triplets. First byte is the ESC code, and the following two bytes are the address to jump to.



At the end of the table is a 00 at $14b3 which will stop the loop if we don't find our ESC code in the table and will execute the RET at $13ba.



So looking at the first triplet, it happens to be our entry for $19.



and it points to the address $175d.
0000175D: 9E                 CALT    ($00BC)   get next
0000175E: 67 30              NEI     A,$30      
00001760: C7                 JR      $1768       is next equal "0" jump to 1768
00001761: 77 34              EQI     A,$34       is it "4"
00001763: B8                 RET                 not 4 then return
00001764: 15 02 20           ORIW    VV:02,$20   set bit 5 of $9802
00001767: B8                 RET                 done
00001768: 05 02 DF           ANIW    VV:02,$DF   clear bit 5 of $9802
0000176B: B8                 RET                 done

which very neatly implements the ESC em command.



Now to investigate the rest of the table.

No comments:

Post a Comment