68HCS12 Microcontroller Programming Question

Discussion in 'Embedded Systems and Microcontrollers' started by stupidlogic, Oct 20, 2010.

  1. stupidlogic

    Thread Starter Member

    Aug 10, 2010
    39
    0
    I need to write a program for my microcontrollers class that takes a user inputted value, unit, and desired unit. And then converts the inputted value and unit to the proper value in the desired unit.

    The problem I'm up against right now is that the conversion factor for say, inches to cm is 2.54. You can't just input a non-integer number and tell the processor to multiply it together. So I'm wondering what sort of solutions there are for representing a decimal in binary/hex, doing the required operation, and output a final number.

    I'm very new to programming in assembly language and using microcontrollers altogether so any help would be awesome. Thanks for the help!
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    <ed>Have a search for BCD (binary coded decimal) to binary algorithms. That should help with the first part.</ED>

    Multiplying by a constant is not too bad.
    There is a code generator here, not for your processor but it will give you the general idea. It generated the below for multiply by 2.54 (and some code).
    If you need to use fractional numbers you can multiply by a constant (10, 100, etc) to make it all integers then move the decimal place when you display.
    Or you can get into the whole floating point numbers thing.

    http://www.golovchenko.org/cgi-bin/constdivmul

    Code ( (Unknown Language)):
    1. ; ACC = ACC * 2.54
    2. ; Temp = TEMP
    3. ; ACC size = 8 bits
    4. ; Error = 0.5 %
    5. ; Bytes order = little endian
    6. ; Round = no
    7.  
    8. ; ALGORITHM:
    9. ; Clear accumulator
    10. ; Add input * 2 to accumulator
    11. ; Add input / 2 to accumulator
    12. ; Add input / 32 to accumulator
    13. ; Move accumulator to result
    14. ;
    15. ; Approximated constant: 2.53125, Error: 0.344488 %
    16.  
    17. ;     Input: ACC0, 8 bits
    18. ;    Output: ACC0 .. ACC1, 10 bits
    19. ; Code size: 19 instructions
     
  3. stupidlogic

    Thread Starter Member

    Aug 10, 2010
    39
    0
    Thanks for the help. I am going to try to implement that later on; it would be a lot nicer of an output. I had already used the technique of multiplying the conversions by a constant to keep working on my program and test it in the simulator.

    I'm probably going to post my code this afternoon with a few questions on where I'm getting stuck. Any help then would be appreciated, but until then... thanks!
     
  4. stupidlogic

    Thread Starter Member

    Aug 10, 2010
    39
    0
    Below I have posted my code thus far...

    The immediate problem I am having is that when it tries to multiply the inputted number by the conversion number, I get zero no matter what. Right now it's loading the wrong numbers into the accumulators I'm using and one of them always ends up zero. I can't figure out why. Any suggestions would be appreciated.

    The next problems I'm running into/going to run into is expanding the program for all the units that I need to accommodate for. I also need to have to be able to differentiate between length units and volume units. My idea for that was to maybe create a string with all the length units called length and all the volume units called volume. And then somehow compare the inputted units and desired units with those strings to see if they are contained inside. The it could go to the next sub-routine or throw an error saying that the conversion's not possible. Any ideas of how to implement this or even another more efficient idea?

    I'm very new at this so any tutorial websites or whatnot on assembly language would also be helpful. Thank you for your help!


    Here is the code:
    Code ( (Unknown Language)):
    1.  
    2. ;********************************************
    3. ; Program Description
    4. ; A user inputs a value and two unit types into
    5. ; the program and does a simple unit conversion.
    6. ; Acceptable unit abbreviations and types are:
    7. ;   Lengths: in (inches)
    8. ;            ft (feet)
    9. ;            cm (centimeters)
    10. ;            m (meters)
    11. ;   Volumes: L (liters)
    12. ;            floz (fluid ounces)
    13. ;            qrts (quarts)
    14. ;            cups (cups)
    15. ; The program also detects whether or not the
    16. ; conversion is possible (i.e., must be length
    17. ; to length) and whether or not the conversion is
    18. ; necessary (i.e., inches to inches).
    19. ;*********************************************
    20.  
    21.  
    22.  
    23. ; Set the beginning address for DATA
    24.  org $1000
    25.  
    26. ; Define all possible types of units
    27. Foot fcc 'ft'  
    28.  db 0           ; null character to terminate string
    29. Inch fcc 'in'  
    30.  db 0           ; null character to terminate string
    31. Meter fcc 'm'
    32.  db 0           ; null character to terminate string
    33. Centimeter fcc 'cm'
    34.  db 0           ; null character to terminate string
    35. Liter fcc 'L'
    36.  db 0           ; null character to terminate string
    37. Fluid_Ounce fcc 'floz'
    38.  db 0           ; null character to terminate string
    39. Quarts fcc 'qrts'
    40.  db 0           ; null character to terminate string
    41. Cups fcc 'cups'
    42.  db 0           ; null character to terminate string
    43. Length fcc 'length'
    44.  db 0           ; null character to terminate string
    45. Volume fcc 'vol'
    46.  db 0           ; null character to terminate string
    47.  
    48. ; Conversion constants
    49. ; Since a you can't have non-integer values,
    50. ; all conversion factors are multiplied by 1000
    51. ; .: all ouputs are in the (N x 10^-3) format
    52.  
    53. ; Length conversions
    54. ftIn equ #12
    55. ftM equ #305
    56. ftCm equ #30480
    57. inM equ #25
    58. inCm equ #2540
    59. mCm equ #100
    60. inFt equ #83
    61. mFt equ #3281
    62. cmFt equ #33
    63. mIn equ #39370
    64. cmIn equ #394
    65. cmM equ #10
    66.  
    67. ; Volume conversions
    68. lFloz equ #33810
    69. lQrts equ #1057
    70. lCups equ #4227
    71. flozQrts equ #31
    72. flozCups equ #125
    73. qrtsCups equ #4
    74. flozL equ #30
    75. qrtsL equ #946
    76. cupsL equ #237
    77. qrtsFloz equ #32
    78. cupsFloz equ #8
    79. cupsQrts equ #250
    80.  
    81.  
    82.  
    83. ; User designated values
    84. inputUnit fcc 'in'  ; string to identify the current unit type
    85.  db 0           ; null character to terminate string
    86. desiredUnit fcc 'ft'    ; string to identify desired unit type
    87.  db 0           ; null character to terminate string
    88. unitValue equ #1
    89.  
    90. ; Set aside space for output
    91. output ds 1
    92.  
    93.  
    94. ; Beginning address for CODE
    95.  org $2000
    96. main:
    97. ; lds #$2000        ; initializes the SP
    98.  ldx #inputUnit     ; get address of first character
    99.  ldy #desiredUnit   ; get address of first character
    100.  
    101. checkSameUnit:
    102.  ldaa 0,X   ; now A has a character in it
    103.  ldab 0,Y   ; now B has a character in it
    104.  
    105. ; compare them
    106.  cba
    107.  bne differentUnits
    108.  
    109. ; if they are the same, move to next character
    110.  inx
    111.  iny
    112.  
    113. ; If at the end of the string(s), stop.
    114. ; Look at the next char in string 1.
    115. ; If it's the NULL char, check to see
    116. ; if string 2 is NULL too.  If not,
    117. ; different strings.
    118.  
    119.  tst 0,X
    120.  beq foundNullInput     ; branch if equal
    121.  
    122.  tst 0,Y
    123.  beq foundNullDesired       ; branch if equal
    124.  
    125.  bra checkSameUnit
    126.  
    127. ; if we're here, then found a NULL in inputUnit
    128. foundNullInput:
    129.  tst 0,Y
    130.  beq sameUnits      ; if Z set, both strings have NULL
    131.  bne differentUnits
    132.  
    133. foundNullDesired:
    134.  bra differentUnits
    135.  
    136. ; if same unit, set output to 0 and stop
    137. sameUnits:
    138.  clra
    139.  ldaa #0        ; stores zero as error code
    140.  staa output
    141.  bgnd           ; bgnd halts simulator
    142.  
    143. differentUnits:
    144.  bra FttoIn     ; branch to IntoFt subroutine
    145.  
    146.  ; idea: use test function to find out which subroutine to use
    147.  
    148. FttoIn:
    149.  clra
    150.  clrb
    151.  
    152.  ldaa unitValue
    153.  ldab inFt      ;loads as zero right now
    154.  mul
    155.  std output
    156.  
    157.  
    158. ; End the program
    159.  org $FFFE
    160.  dw main
     
  5. stupidlogic

    Thread Starter Member

    Aug 10, 2010
    39
    0
    Well hey, I was able to get everything working properly. If anyone is interested in how I did it take a look below. Code is posted. Thanks for the help.

    Code ( (Unknown Language)):
    1. ; Set the beginning address for DATA
    2.  org $1000
    3.  
    4. ; Set aside space for output large enough for 16x16 bit operation
    5. outputWord1 dw 0
    6. outputWord2 dw 0
    7.  
    8. ; User designated values
    9. inputUnit fcc 'L'   ; string to identify the current unit type
    10.  db 0          
    11. desiredUnit fcc 'cm'    ; string to identify desired unit type
    12.  db 0      
    13. unitValue dw 10     ; numerical value of the current unit
    14.  
    15. ; Define all possible types of units
    16. foot fcc 'ft'  
    17.  db 0      
    18. inch fcc 'in'  
    19.  db 0      
    20. meter fcc 'm'
    21.  db 0          
    22. centimeter fcc 'cm'
    23.  db 0      
    24. liter fcc 'L'
    25.  db 0      
    26. fluidOunce fcc 'floz'
    27.  db 0      
    28. quarts fcc 'qrts'
    29.  db 0      
    30. cups fcc 'cups'
    31.  db 0  
    32.  
    33. ; error code
    34. error fcc 'ER'
    35.  db 0      
    36.  
    37.  
    38. ; Conversion constants
    39. ; Since a you can't have non-integer values,
    40. ; all conversion factors are multiplied by 1000
    41. ; .: all ouputs are in the (N x 10^-3) format
    42.  
    43. ; Length conversions
    44. ftIn dw 1200
    45. ftM dw 31
    46. ftCm dw 3048
    47. inM dw 3
    48. inCm dw 254
    49. mCm dw 10000
    50. inFt dw 8
    51. mFt dw 328
    52. cmFt dw 3
    53. mIn dw 3937
    54. cmIn dw 39
    55. cmM dw 1
    56.  
    57. ; Volume conversions
    58. lFloz dw 3381
    59. lQrts dw 106
    60. lCups dw 423
    61. flozQrts dw 3
    62. flozCups dw 13
    63. qrtsCups dw 400
    64. flozL dw 3
    65. qrtsL dw 95
    66. cupsL dw 24
    67. qrtsFloz dw 3200
    68. cupsFloz dw 800
    69. cupsQrts dw 25
    70.  
    71.  
    72.  
    73.  org $2000
    74.  
    75. ; figure out what the input unit is
    76. ; load input unit and compare to each other unit
    77. ; type.  branches when it finds which one it is
    78. findInputUnit:
    79.  ldx #inputUnit
    80.  clra
    81.  ldaa 0,X
    82.  
    83.  ldy #foot
    84.  clrb
    85.  ldab 0,Y
    86.  cba
    87.  lbeq inputIsFoot
    88.  
    89.  ldy #inch
    90.  clrb
    91.  ldab 0,Y
    92.  cba
    93.  lbeq inputIsInch
    94.  
    95.  ldy #meter
    96.  clrb
    97.  ldab 0,Y
    98.  cba
    99.  lbeq inputIsMeter
    100.  
    101.  ldy #centimeter
    102.  clrb
    103.  ldab 0,Y
    104.  cba
    105.  lbeq inputIsCentimeter
    106.  
    107.  ldy #liter
    108.  clrb
    109.  ldab 0,Y
    110.  cba
    111.  lbeq inputIsLiter
    112.  
    113.  ldy #fluidOunce
    114.  clrb
    115.  ldab 0,Y
    116.  cba
    117.  lbeq inputIsFluidOunce
    118.  
    119.  ldy #quarts
    120.  clrb
    121.  ldab 0,Y
    122.  cba
    123.  lbeq inputIsQuarts
    124.  
    125.  ldy #cups
    126.  clrb
    127.  ldab 0,Y
    128.  cba
    129.  lbeq inputIsCups
    130.  
    131.  
    132. ; use the following set of routines to find desired input
    133. ; load desired unit and compare to each other unit
    134. ; type.  branches when it finds which one it is, whether or
    135. ; not the conervsion is possible and if it's the SAME unit
    136. inputIsFoot:
    137.  ldx #desiredUnit
    138.  clra
    139.  ldaa 0,X
    140.  
    141.  ldy #foot
    142.  clrb
    143.  ldab 0,Y
    144.  cba
    145.  lbeq sameExactUnit
    146.  
    147.  ldy #inch
    148.  clrb
    149.  ldab 0,Y
    150.  cba
    151.  lbeq FttoIn
    152.  
    153.  ldy #meter
    154.  clrb
    155.  ldab 0,Y
    156.  cba
    157.  lbeq FttoM
    158.  
    159.  ldy #centimeter
    160.  clrb
    161.  ldab 0,Y
    162.  cba
    163.  lbeq FttoCm
    164.  
    165.  ldy #liter
    166.  clrb
    167.  ldab 0,Y
    168.  cba
    169.  lbeq impossibleConversion
    170.  
    171.  ldy #fluidOunce
    172.  clrb
    173.  ldab 0,Y
    174.  cba
    175.  lbeq impossibleConversion
    176.  
    177.  ldy #quarts
    178.  clrb
    179.  ldab 0,Y
    180.  cba
    181.  lbeq impossibleConversion
    182.  
    183.  ldy #cups
    184.  clrb
    185.  ldab 0,Y
    186.  cba
    187.  lbeq impossibleConversion
    188.  
    189. inputIsInch:
    190.  ldx #desiredUnit
    191.  clra
    192.  ldaa 0,X
    193.  
    194.  ldy #foot
    195.  clrb
    196.  ldab 0,Y
    197.  cba
    198.  lbeq IntoFt
    199.  
    200.  ldy #inch
    201.  clrb
    202.  ldab 0,Y
    203.  cba
    204.  lbeq sameExactUnit
    205.  
    206.  ldy #meter
    207.  clrb
    208.  ldab 0,Y
    209.  cba
    210.  lbeq IntoM
    211.  
    212.  ldy #centimeter
    213.  clrb
    214.  ldab 0,Y
    215.  cba
    216.  lbeq IntoCm
    217.  
    218.  ldy #liter
    219.  clrb
    220.  ldab 0,Y
    221.  cba
    222.  lbeq impossibleConversion
    223.  
    224.  ldy #fluidOunce
    225.  clrb
    226.  ldab 0,Y
    227.  cba
    228.  lbeq impossibleConversion
    229.  
    230.  ldy #quarts
    231.  clrb
    232.  ldab 0,Y
    233.  cba
    234.  lbeq impossibleConversion
    235.  
    236.  ldy #cups
    237.  clrb
    238.  ldab 0,Y
    239.  cba
    240.  lbeq impossibleConversion
    241.  
    242. inputIsMeter:
    243.  ldx #desiredUnit
    244.  clra
    245.  ldaa 0,X
    246.  
    247.  ldy #foot
    248.  clrb
    249.  ldab 0,Y
    250.  cba
    251.  lbeq MtoFt
    252.  
    253.  ldy #inch
    254.  clrb
    255.  ldab 0,Y
    256.  cba
    257.  lbeq MtoIn
    258.  
    259.  ldy #meter
    260.  clrb
    261.  ldab 0,Y
    262.  cba
    263.  lbeq sameExactUnit
    264.  
    265.  ldy #centimeter
    266.  clrb
    267.  ldab 0,Y
    268.  cba
    269.  lbeq MtoCm
    270.  
    271.  ldy #liter
    272.  clrb
    273.  ldab 0,Y
    274.  cba
    275.  lbeq impossibleConversion
    276.  
    277.  ldy #fluidOunce
    278.  clrb
    279.  ldab 0,Y
    280.  cba
    281.  lbeq impossibleConversion
    282.  
    283.  ldy #quarts
    284.  clrb
    285.  ldab 0,Y
    286.  cba
    287.  lbeq impossibleConversion
    288.  
    289.  ldy #cups
    290.  clrb
    291.  ldab 0,Y
    292.  cba
    293.  lbeq impossibleConversion
    294.  
    295. inputIsCentimeter:
    296.  ldx #desiredUnit
    297.  clra
    298.  ldaa 0,X
    299.  
    300.  ldy #foot
    301.  clrb
    302.  ldab 0,Y
    303.  cba
    304.  lbeq CmtoFt
    305.  
    306.  ldy #inch
    307.  clrb
    308.  ldab 0,Y
    309.  cba
    310.  lbeq CmtoIn
    311.  
    312.  ldy #meter
    313.  clrb
    314.  ldab 0,Y
    315.  cba
    316.  lbeq CmtoM
    317.  
    318.  ldy #centimeter
    319.  clrb
    320.  ldab 0,Y
    321.  cba
    322.  lbeq sameExactUnit
    323.  
    324.  ldy #liter
    325.  clrb
    326.  ldab 0,Y
    327.  cba
    328.  lbeq impossibleConversion
    329.  
    330.  ldy #fluidOunce
    331.  clrb
    332.  ldab 0,Y
    333.  cba
    334.  lbeq impossibleConversion
    335.  
    336.  ldy #quarts
    337.  clrb
    338.  ldab 0,Y
    339.  cba
    340.  lbeq impossibleConversion
    341.  
    342.  ldy #cups
    343.  clrb
    344.  ldab 0,Y
    345.  cba
    346.  lbeq impossibleConversion
    347.  
    348. inputIsLiter:
    349.  ldx #desiredUnit
    350.  clra
    351.  ldaa 0,X
    352.  
    353.  ldy #foot
    354.  clrb
    355.  ldab 0,Y
    356.  cba
    357.  lbeq impossibleConversion
    358.  
    359.  ldy #inch
    360.  clrb
    361.  ldab 0,Y
    362.  cba
    363.  lbeq impossibleConversion
    364.  
    365.  ldy #meter
    366.  clrb
    367.  ldab 0,Y
    368.  cba
    369.  lbeq impossibleConversion
    370.  
    371.  ldy #centimeter
    372.  clrb
    373.  ldab 0,Y
    374.  cba
    375.  lbeq impossibleConversion
    376.  
    377.  ldy #liter
    378.  clrb
    379.  ldab 0,Y
    380.  cba
    381.  lbeq sameExactUnit
    382.  
    383.  ldy #fluidOunce
    384.  clrb
    385.  ldab 0,Y
    386.  cba
    387.  lbeq LtoFloz
    388.  
    389.  ldy #quarts
    390.  clrb
    391.  ldab 0,Y
    392.  cba
    393.  lbeq LtoQrts
    394.  
    395.  ldy #cups
    396.  clrb
    397.  ldab 0,Y
    398.  cba
    399.  lbeq LtoCups
    400.  
    401. inputIsFluidOunce:
    402.  ldx #desiredUnit
    403.  clra
    404.  ldaa 0,X
    405.  
    406.  ldy #foot
    407.  clrb
    408.  ldab 0,Y
    409.  cba
    410.  lbeq impossibleConversion
    411.  
    412.  ldy #inch
    413.  clrb
    414.  ldab 0,Y
    415.  cba
    416.  lbeq impossibleConversion
    417.  
    418.  ldy #meter
    419.  clrb
    420.  ldab 0,Y
    421.  cba
    422.  lbeq impossibleConversion
    423.  
    424.  ldy #centimeter
    425.  clrb
    426.  ldab 0,Y
    427.  cba
    428.  lbeq impossibleConversion
    429.  
    430.  ldy #liter
    431.  clrb
    432.  ldab 0,Y
    433.  cba
    434.  lbeq FloztoL
    435.  
    436.  ldy #fluidOunce
    437.  clrb
    438.  ldab 0,Y
    439.  cba
    440.  lbeq sameExactUnit
    441.  
    442.  ldy #quarts
    443.  clrb
    444.  ldab 0,Y
    445.  cba
    446.  lbeq FloztoQrts
    447.  
    448.  ldy #cups
    449.  clrb
    450.  ldab 0,Y
    451.  cba
    452.  lbeq FloztoCups
    453.  
    454. inputIsQuarts:
    455.  ldx #desiredUnit
    456.  clra
    457.  ldaa 0,X
    458.  
    459.  ldy #foot
    460.  clrb
    461.  ldab 0,Y
    462.  cba
    463.  lbeq impossibleConversion
    464.  
    465.  ldy #inch
    466.  clrb
    467.  ldab 0,Y
    468.  cba
    469.  lbeq impossibleConversion
    470.  
    471.  ldy #meter
    472.  clrb
    473.  ldab 0,Y
    474.  cba
    475.  lbeq impossibleConversion
    476.  
    477.  ldy #centimeter
    478.  clrb
    479.  ldab 0,Y
    480.  cba
    481.  lbeq impossibleConversion
    482.  
    483.  ldy #liter
    484.  clrb
    485.  ldab 0,Y
    486.  cba
    487.  lbeq QrtstoL
    488.  
    489.  ldy #fluidOunce
    490.  clrb
    491.  ldab 0,Y
    492.  cba
    493.  lbeq QrtstoFloz
    494.  
    495.  ldy #quarts
    496.  clrb
    497.  ldab 0,Y
    498.  cba
    499.  lbeq sameExactUnit
    500.  
    501.  ldy #cups
    502.  clrb
    503.  ldab 0,Y
    504.  cba
    505.  lbeq QrtstoCups
    506.  
    507. inputIsCups:
    508.  ldx #desiredUnit
    509.  clra
    510.  ldaa 0,X
    511.  
    512.  ldy #foot
    513.  clrb
    514.  ldab 0,Y
    515.  cba
    516.  lbeq impossibleConversion
    517.  
    518.  ldy #inch
    519.  clrb
    520.  ldab 0,Y
    521.  cba
    522.  lbeq impossibleConversion
    523.  
    524.  ldy #meter
    525.  clrb
    526.  ldab 0,Y
    527.  cba
    528.  lbeq impossibleConversion
    529.  
    530.  ldy #centimeter
    531.  clrb
    532.  ldab 0,Y
    533.  cba
    534.  lbeq impossibleConversion
    535.  
    536.  ldy #liter
    537.  clrb
    538.  ldab 0,Y
    539.  cba
    540.  lbeq CupstoL
    541.  
    542.  ldy #fluidOunce
    543.  clrb
    544.  ldab 0,Y
    545.  cba
    546.  lbeq CupstoFloz
    547.  
    548.  ldy #quarts
    549.  clrb
    550.  ldab 0,Y
    551.  cba
    552.  lbeq CupstoQrts
    553.  
    554.  ldy #cups
    555.  clrb
    556.  ldab 0,Y
    557.  cba
    558.  lbeq sameExactUnit
    559.  
    560.  
    561. ; Length conversions
    562. FttoIn:
    563.  ldy unitValue
    564.  ldd ftIn
    565.  emul
    566.  sty outputWord1
    567.  std outputWord2
    568.  bgnd           ; bgnd halts simulator
    569. FttoM:
    570.  ldy unitValue
    571.  ldd ftM
    572.  emul
    573.  sty outputWord1
    574.  std outputWord2
    575.  bgnd           ; bgnd halts simulator
    576. FttoCm:
    577.  ldy unitValue
    578.  ldd ftCm
    579.  emul
    580.  sty outputWord1
    581.  std outputWord2
    582.  bgnd           ; bgnd halts simulator
    583. IntoM:
    584.  ldy unitValue
    585.  ldd inM
    586.  emul
    587.  sty outputWord1
    588.  std outputWord2
    589.  bgnd           ; bgnd halts simulator
    590. IntoCm:
    591.  ldy unitValue
    592.  ldd inCm
    593.  emul
    594.  sty outputWord1
    595.  std outputWord2
    596.  bgnd           ; bgnd halts simulator
    597. MtoCm:
    598.  ldy unitValue
    599.  ldd mCm
    600.  emul
    601.  sty outputWord1
    602.  std outputWord2
    603.  bgnd           ; bgnd halts simulator
    604. IntoFt:
    605.  ldy unitValue
    606.  ldd inFt
    607.  emul
    608.  sty outputWord1
    609.  std outputWord2
    610.  bgnd           ; bgnd halts simulator
    611. MtoFt: 
    612.  ldy unitValue
    613.  ldd mFt
    614.  emul
    615.  sty outputWord1
    616.  std outputWord2
    617.  bgnd           ; bgnd halts simulator
    618. CmtoFt:
    619.  ldy unitValue
    620.  ldd cmFt
    621.  emul
    622.  sty outputWord1
    623.  std outputWord2
    624.  bgnd           ; bgnd halts simulator
    625. MtoIn: 
    626.  ldy unitValue
    627.  ldd mIn
    628.  emul
    629.  sty outputWord1
    630.  std outputWord2
    631.  bgnd           ; bgnd halts simulator
    632. CmtoIn:  
    633.  ldy unitValue
    634.  ldd cmIn
    635.  emul
    636.  sty outputWord1
    637.  std outputWord2
    638.  bgnd           ; bgnd halts simulator
    639. CmtoM: 
    640.  ldy unitValue
    641.  ldd cmM
    642.  emul
    643.  sty outputWord1
    644.  std outputWord2
    645.  bgnd           ; bgnd halts simulator
    646.    
    647. ; Volume conversions
    648. LtoFloz:
    649.  ldy unitValue
    650.  ldd lFloz
    651.  emul
    652.  sty outputWord1
    653.  std outputWord2
    654.  bgnd           ; bgnd halts simulator
    655. LtoQrts:
    656.  ldy unitValue
    657.  ldd lQrts
    658.  emul
    659.  sty outputWord1
    660.  std outputWord2
    661.  bgnd           ; bgnd halts simulator
    662. LtoCups:
    663.  ldy unitValue
    664.  ldd lCups
    665.  emul
    666.  sty outputWord1
    667.  std outputWord2
    668.  bgnd           ; bgnd halts simulator
    669. FloztoQrts:
    670.  ldy unitValue
    671.  ldd flozQrts
    672.  emul
    673.  sty outputWord1
    674.  std outputWord2
    675.  bgnd           ; bgnd halts simulator
    676. FloztoCups:
    677.  ldy unitValue
    678.  ldd flozCups
    679.  emul
    680.  sty outputWord1
    681.  std outputWord2
    682.  bgnd           ; bgnd halts simulator
    683. QrtstoCups:
    684.  ldy unitValue
    685.  ldd qrtsCups
    686.  emul
    687.  sty outputWord1
    688.  std outputWord2
    689.  bgnd           ; bgnd halts simulator
    690. FloztoL:
    691.  ldy unitValue
    692.  ldd flozL
    693.  emul
    694.  sty outputWord1
    695.  std outputWord2
    696.  bgnd           ; bgnd halts simulator
    697. QrtstoL:
    698.  ldy unitValue
    699.  ldd qrtsL
    700.  emul
    701.  sty outputWord1
    702.  std outputWord2
    703.  bgnd           ; bgnd halts simulator
    704. CupstoL:
    705.  ldy unitValue
    706.  ldd cupsL
    707.  emul
    708.  sty outputWord1
    709.  std outputWord2
    710.  bgnd           ; bgnd halts simulator
    711. QrtstoFloz:
    712.  ldy unitValue
    713.  ldd qrtsFloz
    714.  emul
    715.  sty outputWord1
    716.  std outputWord2
    717.  bgnd           ; bgnd halts simulator
    718. CupstoFloz:
    719.  ldy unitValue
    720.  ldd cupsFloz
    721.  emul
    722.  sty outputWord1
    723.  std outputWord2
    724.  bgnd           ; bgnd halts simulator
    725. CupstoQrts:
    726.  ldy unitValue
    727.  ldd cupsQrts
    728.  emul
    729.  sty outputWord1
    730.  std outputWord2
    731.  bgnd           ; bgnd halts simulator
    732.  
    733. ; goes here if the input unit is the same as the
    734. ; desired unit
    735. sameExactUnit:
    736.  clra
    737.  clrb
    738.  ldd #unitValue
    739.  std outputWord2
    740.  bgnd           ; bgnd halts simulator
    741.  
    742. ; goes here if the conversion trying to be made
    743. ; is impossible
    744. impossibleConversion:
    745.  clra
    746.  clrb
    747.  ldd error
    748.  std outputWord1
    749.  std outputWord2
    750.  
    751.  bgnd           ; bgnd halts simulator
     
Loading...