17 lines
570 B
Text
17 lines
570 B
Text
CMDLIN: equ 80h ; Location of CP/M command line argument
|
|
puts: equ 9h ; Syscall to print a string
|
|
;;; Check if number given on command line is even or odd
|
|
org 100h
|
|
lxi h,CMDLIN ; Find length of argument
|
|
mov a,m
|
|
add l ; Look up last character (digit)
|
|
mov l,a
|
|
mov a,m ; Retrieve low digit
|
|
rar ; Rotate low bit into carry flag
|
|
mvi c,puts ; Prepare to print string
|
|
lxi d,odd ; If carry is set, then the number is odd
|
|
jc 5 ; So print 'odd'
|
|
lxi d,even ; Otherwise, the number is even
|
|
jmp 5 ; So print 'even'
|
|
even: db 'Even$' ; Strings
|
|
odd: db 'Odd$'
|