This program will poke (insert) the machine language program into memory, ask the user for 2 numbers, then call the machine language program to have the 2 numbers added together. Finally, it will display the result.
In the basic program below, line 100 & 110 ask for two numbers. Line 120 stores what the user entered into ram the assembly program will use. Once the assembly program is done, it stores the number in C902, and finally that value is displayed to the user.
The actual machine code is in the DATA lines. See the assemby section below
40 FOR A=51456 TO 51473 50 READ B 60 POKE A,B 70 NEXT A 80 DATA 0,0,0,16,201,0,87,131,218,17 90 DATA 1,87,68,218,17,2,82,55 100 INPUT "A=";A 110 INPUT "B=";B 120 POKE &C900,A,B : CALL &C903 130 PRINT "RESULT=",PEEK &C902 140 END
Assembly language source code. PockASM used to compile it.
ORG &C900
B_REG EQU 3
NUM1: DB 0 # First number that will be given by Basic program
NUM2: DB 0 # Second number that will be given by Basic program
RESULT: DB 0 # Result of the addition of the two numbers
LIDP NUM1 # DP points to first number address
LDD # A receives value of first number
LP B_REG # P points to B register
EXAB # A and B are swapped, B contains first number value
LIDL LB@NUM2 # DP now points to second number address
LDD # A receives value of second number
ADM # A and B are added, B receives the result of the addition
EXAB # A and B are swapped, A contains the result of the addition
LIDL LB@RESULT # DP now points to Result address
STD # Result receives its value
RTN # Return, exits from ML program and goes back to Basic
Copyright © 2025, Lee Patterson