those who understand the following assembler 68k code are invited to talk about IT with me.
those who don't understand it are invited to do so as well of course.
however, stop fucking questioning my IT skills, please !
the code looks a bit messy, however it was written in a text editor and there it is quite tidy.
* ========================
ORG $F000 ;
* ========================
NOLIST
* Display the current LCD Display
Harness MOVEA.L #Display,A0 ; Point to start of Display
MOVEQ #3,D3 ; Count = 3
HDLoop MOVE.B (A0)+,D2 ; Read the first 2-Digits
MOVE.B D2,D1
LSR.B #4,D1
BSR HDigit ; Display first digit
MOVE.B D2,D1
BSR HDigit ; Display second digit
DBRA D3,HDLoop ; until Count--
* Display the Harness Prompt
LEA HPrompt,A0 ; Point to String
BSR HString ; Display it
* Read a key from the keyboard
MOVE.B #5,D0 ; Wait for char from (PC) keyboard
TRAP #15
* Process the Key
CMPI.B #'0',D1 ; Is it It may be a command
CMPI.B #'9',D1 ; No => Is it > '9' ?
BGT HCmd ; Yes => May be a command
ANDI.B #$0F,D1 ; Must be a Numeric Key
MOVE.B D1,D2 ; Save it in D2
LEA HCRLF,A0 ; Point to CR/LF (newline)
BSR HString ; Display it
* Call Students' code with D2
HKey MOVE.L #Program,D0 ; Simulate rubbish in high nibble
MOVE.B HPtr,D0
ADDQ #1,D0
MOVE.B D0,HPtr
MOVEA.L D0,A0
MOVE.B (A0),D0
ANDI.B #$F0,D0
OR.B D2,D0
MOVE.B D0,KeyCode ;
CLR.W D0
CLR.W D2
JSR Keyboard ; Call Students code
BRA Harness ; Display Status
* Check the Command Table for the Key
HCmd CMPI.B #'a',D1 ; Is the Key Upper Case
BLT HCmd1
ANDI.B #$DF,D1 ; No => Convert to Uppercase
HCmd1 LEA HCMDTBL,A0 ; Point to Command Table
HCmd2 CMP.B (A0)+,D1 ; Is it first char?
BEQ HDoCmd ; Yes => Do Command
CMP.B (A0),D1 ; No => Is it second char?
BEQ HDoCmd ; Yes => Do Command
HCmd3 CMPI.B #0,(A0)+ ; Scan though to the next
BNE HCmd3 ; entry in the table
CMPI.B #0,(A0) ; End of table?
BNE HCmd2 ; No => Check for command
LEA HCRLF,A0 ; Yes => Ignore it
BSR HString
BRA Harness
HDoCmd ADDA.W #1,A0
MOVE.B (A0)+,D2 ; Read Key Code
BSR HString ; Display Command
LEA HCRLF,A0 ; Display a Newline (\n)
BSR HString
CMPI.B #$10,D2 ; It is a Harness function ?
BLT HKey ;
* Harness Function: 0 - Clear Key
CMPI.B #$10,D2 ; Is it the clear key?
BNE HQuit ; No => Must be Quit
HClr JSR Clear ;
BRA Harness
* Harness Function: 1 - Quit / Exit Harness
HQuit STOP #$2000
* ===================================================
* Harness Subroutines
* ===================================================
* ====
* Display ASCIIZ string
* A0 => Pointer to first byte of zero terminated string
* A0 return to caller
HStr1 MOVEQ #6,D0
TRAP #15 ; No => Display char
BRA HString
* ====
* Display a single hexadecimal digit
* D1 => Lower Nibble is hex digit to display
* A1 Display it
CLR.L D0 ; Clear Index value
LEA HCTBL,A1 ; Point to Char Table
MOVE.L D1,D0 ; Copy Key code into index
SUB.B #$0A,D0 ; Convert Code into index
ADDA.L D0,A1 ; Index into Table
MOVE.B (A1),D1 ; Read Char from Table
BRA HChar ; Display it
HDec ADD.B #'0',D1 ; Make it an ASCII Char
HChar MOVEQ #6,D0 ; putchar(D1)
TRAP #15
RTS
* ===================================================
* Private Data Section for the Test Harness
* ===================================================
Hptr DC.L $4000
HPrompt DC.B ' ? ',0
HCRLF DC.B 13,10,0
HCTBL DC.B '??o Er'
HCMDTBL DC.B '*','M',$0A,' Multiply',0
DC.B '/','D',$0B,' Divide',0
DC.B '-','S',$0C,' Subtract',0
DC.B '+','A',$0D,' Add',0
DC.B '=','E',$0F,' Equals',0
DC.B 'C','C',$10,' Clear',0
DC.B 'Q','Q',$11,' Quit',0
DC.B 'X','X',$11,' Exit',0
DC.B 0
LIST
---
Signature seized by order of the Hague