I'm just starting to learn assembler, so I started with 'Hello World' and
also printing the sum of 2 numbers. Snippet of the code is below and it
works fine:
OPEN (SYSPRINT,(OUTPUT)) Write output here
L 3,NUM1 Load first number in R3
L 4,NUM2 Load 2nd number in R4
AR 4,3 Add contents of R4 and R3 and store
* in R4
PUT SYSPRINT,MSG01 Write Hello World to SYSPRINT
*
* Output the value in RESULT
*
MVC MSG01,=C'Result= '
CVD R4,CONV1
UNPK MSG01B,CONV1+4(4)
OI MSG01B+6,X'F0'
PUT SYSPRINT,MSG01
CLOSE (SYSPRINT) Close SYSPRINT
NUM1 DC F'9' Hardcoded first number
NUM2 DC F'4' Hardcoded second number
SYSPRINT DCB DDNAME=SYSPRINT, +
MACRF=(PM), +
DSORG=PS,RECFM=F,LRECL=80
*
* Output line: Fields add to 80
* DC - Character field
* DS - Numeric field
*
*
MSG01 DC CL11'Hello World' Store string here
MSG01B DS CL7 numeric field
MSG01B2 DC C' '
MSG01C DC CL62' ' padding
END NEWTON3 End of program
But the printing part doesn't work if NUM1 & NUM2 have decimal points
(e.g. 4.3 & 6.1). If I use ADBR to add the 2 numbers and store as BFP and
try to print that, I get garbage. Can someone show what has to change in
the code for this to work? Thanks.
L 3,NUM1 Load first number in R3
L 4,NUM2 Load 2nd number in R4
ADBR 4,3 Add contents of R4 and R3 and store
* in R4