RosettaCodeData/Task/Machine-code/S-BASIC/machine-code.basic

26 lines
693 B
Plaintext

$constant CODESIZE = 4 rem - size of our ml routine
$constant ML_LOC = 011AH rem - beginning of common data area
dim common byte ml_code(CODESIZE)
var hl, de, bc, a_psw = integer
comment
The 8080 machine language routine adds two unsigned
8-bit numbers passed as the low-order bytes in the
BC and DE registers, and leaves the result in HL.
end
ml_code(1) = 79H rem MOV A,C
ml_code(2) = 83H rem ADD E
ml_code(3) = 6FH rem MOV L,A
ml_code(4) = 0C9H rem RET
bc = 7 rem first number
de = 12 rem second number
rem - call the routine and display the result (returned in HL)
call (ML_LOC, hl, de, bc, a_psw)
print bc; " plus"; de; " equals"; hl
end